Created
November 1, 2024 12:27
-
-
Save deepak1556/e99cf2408f0b592a5003f77c8421820a to your computer and use it in GitHub Desktop.
Support Crashpad stability report in minidump_dump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/third_party/breakpad/BUILD.gn b/third_party/breakpad/BUILD.gn | |
index d7d27abb8eca3..b3340dbbf8036 100644 | |
--- a/third_party/breakpad/BUILD.gn | |
+++ b/third_party/breakpad/BUILD.gn | |
@@ -417,6 +417,10 @@ if (!is_win) { | |
# There are some warnings in this code. | |
configs -= [ "//build/config/compiler:chromium_code" ] | |
configs += [ "//build/config/compiler:no_chromium_code" ] | |
+ | |
+ deps = [ | |
+ "//components/stability_report:stability_report_proto" | |
+ ] | |
} | |
} else if (current_toolchain == default_toolchain) { | |
# The default toolchain builds the system-allocator binaries, which are |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/google_breakpad/processor/minidump.h b/src/google_breakpad/processor/minidump.h | |
index e523ab36..d9e387d0 100644 | |
--- a/src/google_breakpad/processor/minidump.h | |
+++ b/src/google_breakpad/processor/minidump.h | |
@@ -1301,6 +1301,7 @@ class Minidump { | |
virtual MinidumpBreakpadInfo* GetBreakpadInfo(); | |
virtual MinidumpMemoryInfoList* GetMemoryInfoList(); | |
MinidumpCrashpadInfo* GetCrashpadInfo(); | |
+ void PrintStabilityReport(); | |
// The next method also calls GetStream, but is exclusive for Linux dumps. | |
virtual MinidumpLinuxMapsList* GetLinuxMapsList(); | |
diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc | |
index 22dce762..751449c0 100644 | |
--- a/src/processor/minidump.cc | |
+++ b/src/processor/minidump.cc | |
@@ -72,6 +72,7 @@ | |
#include "processor/basic_code_modules.h" | |
#include "processor/convert_old_arm64_context.h" | |
#include "processor/logging.h" | |
+#include "components/stability_report/stability_report.pb.h" | |
namespace google_breakpad { | |
@@ -5937,6 +5938,56 @@ MinidumpCrashpadInfo* Minidump::GetCrashpadInfo() { | |
return GetStream(&crashpad_info); | |
} | |
+void Minidump::PrintStabilityReport() { | |
+ uint32_t stream_type = 0x4B6B0002; | |
+ MinidumpStreamMap::iterator iterator = stream_map_->find(stream_type); | |
+ if (iterator == stream_map_->end()) { | |
+ // This stream type didn't exist in the directory. | |
+ BPLOG(INFO) << "GetStream: type " << stream_type << " not present"; | |
+ return; | |
+ } | |
+ | |
+ uint32_t stream_length; | |
+ if (!SeekToStreamType(stream_type, &stream_length)) { | |
+ BPLOG(ERROR) << "GetStream could not seek to stream type " << stream_type; | |
+ } | |
+ | |
+ std::vector<uint8_t> stream_data(stream_length); | |
+ if (ReadBytes(stream_data.data(), stream_length)) { | |
+ stability_report::StabilityReport report; | |
+ if (report.ParseFromArray(stream_data.data(), stream_data.size())) { | |
+ using stability_report::ProcessState; | |
+ using stability_report::SystemMemoryState; | |
+ printf("MDCrashpadStabilityReport\n"); | |
+ if (report.process_states_size()) { | |
+ for ( const ProcessState& process_state : report.process_states()) { | |
+ printf(" process_id = %" PRId64 "\n", process_state.process_id()); | |
+ if (process_state.has_memory_state()) { | |
+ if (process_state.memory_state().has_windows_memory()) { | |
+ const ProcessState::MemoryState::WindowsMemory& process_memory = | |
+ process_state.memory_state().windows_memory(); | |
+ printf(" process memory private usage = %d\n", process_memory.process_private_usage()); | |
+ printf(" process memory peak workingset size = %d\n", process_memory.process_peak_workingset_size()); | |
+ printf(" process pagefile usage = %d\n", process_memory.process_peak_pagefile_usage()); | |
+ printf(" process memory allocation attempt = %d\n", process_memory.process_allocation_attempt()); | |
+ } | |
+ } | |
+ } | |
+ } | |
+ if (report.has_system_memory_state()) { | |
+ if (report.system_memory_state().has_windows_memory()) { | |
+ const SystemMemoryState::WindowsMemory& system_memory = | |
+ report.system_memory_state().windows_memory(); | |
+ printf(" system commit limit = %d\n", system_memory.system_commit_limit()); | |
+ printf(" system commit remaining = %d\n", system_memory.system_commit_remaining()); | |
+ } | |
+ } | |
+ } else { | |
+ BPLOG(ERROR) << "Stability report could not be parsed"; | |
+ } | |
+ } | |
+} | |
+ | |
static const char* get_stream_name(uint32_t stream_type) { | |
switch (stream_type) { | |
case MD_UNUSED_STREAM: | |
@@ -6011,6 +6062,8 @@ static const char* get_stream_name(uint32_t stream_type) { | |
return "MD_LINUX_DSO_DEBUG"; | |
case MD_CRASHPAD_INFO_STREAM: | |
return "MD_CRASHPAD_INFO_STREAM"; | |
+ case 0x4B6B0002: | |
+ return "MD_CRASHPAD_STABILITY_REPORT"; | |
default: | |
return "unknown"; | |
} | |
diff --git a/src/processor/minidump_dump.cc b/src/processor/minidump_dump.cc | |
index d3c33ad4..39cbfb73 100644 | |
--- a/src/processor/minidump_dump.cc | |
+++ b/src/processor/minidump_dump.cc | |
@@ -202,6 +202,8 @@ static bool PrintMinidumpDump(const Options& options) { | |
crashpad_info->Print(); | |
} | |
+ minidump.PrintStabilityReport(); | |
+ | |
DumpRawStream(&minidump, | |
MD_LINUX_CMD_LINE, | |
"MD_LINUX_CMD_LINE", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment