• R/O
  • HTTP
  • SSH
  • HTTPS

thirdparty-breakpad: Commit

Breakpad, a crash reporter, from Google.

Original home: https://chromium.googlesource.com/breakpad/breakpad/


Commit MetaInfo

Révision3d6076efc24ec6c74cba7729121bf45512a15ba2 (tree)
l'heure2017-10-17 19:22:46
AuteurTobias Sargeant <tobiasjs@goog...>
CommiterTobias Sargeant

Message de Log

Add -s flag to microdump_stackwalk for dumping stack contents.

Note that the current MicrodumpProcessor::Process implementation has a
bug due to the fact that it creates a local Microdump instance, and then
holds onto a pointer to the object returned by microdump.GetMemory()
which is destroyed when microdump goes out of scope. This CL fixes the
crash by making Microdump outlive MicrodumpProcessor, which is the same
pattern that Minidump/MinidumpProcessor uses.

Bug: google-breakpad:748
Change-Id: I554b46d309649cf404523722bd9ee39e17a10139
Reviewed-on: https://chromium-review.googlesource.com/720809
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>

Change Summary

Modification

--- a/src/google_breakpad/processor/microdump.h
+++ b/src/google_breakpad/processor/microdump.h
@@ -133,4 +133,3 @@ class Microdump {
133133 } // namespace google_breakpad
134134
135135 #endif // GOOGLE_BREAKPAD_PROCESSOR_MICRODUMP_H__
136-
--- a/src/google_breakpad/processor/microdump_processor.h
+++ b/src/google_breakpad/processor/microdump_processor.h
@@ -40,9 +40,10 @@
4040
4141 namespace google_breakpad {
4242
43+class Microdump;
4344 class ProcessState;
4445 class StackFrameSymbolizer;
45-
46+
4647 class MicrodumpProcessor {
4748 public:
4849 // Initializes the MicrodumpProcessor with a stack frame symbolizer.
@@ -52,7 +53,7 @@ class MicrodumpProcessor {
5253 virtual ~MicrodumpProcessor();
5354
5455 // Processes the microdump contents and fills process_state with the result.
55- google_breakpad::ProcessResult Process(const string& microdump_contents,
56+ google_breakpad::ProcessResult Process(Microdump* microdump,
5657 ProcessState* process_state);
5758 private:
5859 StackFrameSymbolizer* frame_symbolizer_;
--- a/src/processor/microdump.cc
+++ b/src/processor/microdump.cc
@@ -394,4 +394,3 @@ Microdump::Microdump(const string& contents)
394394 }
395395
396396 } // namespace google_breakpad
397-
--- a/src/processor/microdump_processor.cc
+++ b/src/processor/microdump_processor.cc
@@ -54,24 +54,18 @@ MicrodumpProcessor::MicrodumpProcessor(StackFrameSymbolizer* frame_symbolizer)
5454
5555 MicrodumpProcessor::~MicrodumpProcessor() {}
5656
57-ProcessResult MicrodumpProcessor::Process(const string &microdump_contents,
57+ProcessResult MicrodumpProcessor::Process(Microdump *microdump,
5858 ProcessState* process_state) {
5959 assert(process_state);
6060
6161 process_state->Clear();
6262
63- if (microdump_contents.empty()) {
64- BPLOG(ERROR) << "Microdump is empty.";
65- return PROCESS_ERROR_MINIDUMP_NOT_FOUND;
66- }
67-
68- Microdump microdump(microdump_contents);
69- process_state->modules_ = microdump.GetModules()->Copy();
63+ process_state->modules_ = microdump->GetModules()->Copy();
7064 scoped_ptr<Stackwalker> stackwalker(
7165 Stackwalker::StackwalkerForCPU(
7266 &process_state->system_info_,
73- microdump.GetContext(),
74- microdump.GetMemory(),
67+ microdump->GetContext(),
68+ microdump->GetMemory(),
7569 process_state->modules_,
7670 /* unloaded_modules= */ NULL,
7771 frame_symbolizer_));
@@ -90,12 +84,12 @@ ProcessResult MicrodumpProcessor::Process(const string &microdump_contents,
9084 }
9185
9286 process_state->threads_.push_back(stack.release());
93- process_state->thread_memory_regions_.push_back(microdump.GetMemory());
87+ process_state->thread_memory_regions_.push_back(microdump->GetMemory());
9488 process_state->crashed_ = true;
9589 process_state->requesting_thread_ = 0;
96- process_state->system_info_ = *microdump.GetSystemInfo();
97- process_state->crash_reason_ = microdump.GetCrashReason();
98- process_state->crash_address_ = microdump.GetCrashAddress();
90+ process_state->system_info_ = *microdump->GetSystemInfo();
91+ process_state->crash_reason_ = microdump->GetCrashReason();
92+ process_state->crash_address_ = microdump->GetCrashAddress();
9993
10094 return PROCESS_OK;
10195 }
--- a/src/processor/microdump_processor_unittest.cc
+++ b/src/processor/microdump_processor_unittest.cc
@@ -37,6 +37,7 @@
3737 #include "breakpad_googletest_includes.h"
3838 #include "google_breakpad/processor/basic_source_line_resolver.h"
3939 #include "google_breakpad/processor/call_stack.h"
40+#include "google_breakpad/processor/microdump.h"
4041 #include "google_breakpad/processor/microdump_processor.h"
4142 #include "google_breakpad/processor/process_state.h"
4243 #include "google_breakpad/processor/stack_frame.h"
@@ -47,6 +48,7 @@
4748 namespace {
4849
4950 using google_breakpad::BasicSourceLineResolver;
51+using google_breakpad::Microdump;
5052 using google_breakpad::MicrodumpProcessor;
5153 using google_breakpad::ProcessState;
5254 using google_breakpad::SimpleSymbolSupplier;
@@ -83,7 +85,8 @@ class MicrodumpProcessorTest : public ::testing::Test {
8385 StackFrameSymbolizer frame_symbolizer(&supplier, &resolver);
8486 MicrodumpProcessor processor(&frame_symbolizer);
8587
86- return processor.Process(microdump_contents, state);
88+ Microdump microdump(microdump_contents);
89+ return processor.Process(&microdump, state);
8790 }
8891
8992 void AnalyzeDump(const string& microdump_file_name, bool omit_symbols,
@@ -109,13 +112,6 @@ class MicrodumpProcessorTest : public ::testing::Test {
109112 string files_path_;
110113 };
111114
112-TEST_F(MicrodumpProcessorTest, TestProcess_Empty) {
113- ProcessState state;
114- google_breakpad::ProcessResult result =
115- ProcessMicrodump("", "", &state);
116- ASSERT_EQ(google_breakpad::PROCESS_ERROR_MINIDUMP_NOT_FOUND, result);
117-}
118-
119115 TEST_F(MicrodumpProcessorTest, TestProcess_Invalid) {
120116 ProcessState state;
121117 google_breakpad::ProcessResult result =
--- a/src/processor/microdump_stackwalk.cc
+++ b/src/processor/microdump_stackwalk.cc
@@ -41,6 +41,7 @@
4141 #include "common/scoped_ptr.h"
4242 #include "common/using_std_string.h"
4343 #include "google_breakpad/processor/basic_source_line_resolver.h"
44+#include "google_breakpad/processor/microdump.h"
4445 #include "google_breakpad/processor/microdump_processor.h"
4546 #include "google_breakpad/processor/process_state.h"
4647 #include "google_breakpad/processor/stack_frame_symbolizer.h"
@@ -53,12 +54,14 @@ namespace {
5354
5455 struct Options {
5556 bool machine_readable;
57+ bool output_stack_contents;
5658
5759 string microdump_file;
5860 std::vector<string> symbol_paths;
5961 };
6062
6163 using google_breakpad::BasicSourceLineResolver;
64+using google_breakpad::Microdump;
6265 using google_breakpad::MicrodumpProcessor;
6366 using google_breakpad::ProcessResult;
6467 using google_breakpad::ProcessState;
@@ -81,6 +84,10 @@ int PrintMicrodumpProcess(const Options& options) {
8184 std::vector<char> bytes;
8285 file_stream.seekg(0, std::ios_base::end);
8386 bytes.resize(file_stream.tellg());
87+ if (bytes.empty()) {
88+ BPLOG(ERROR) << "Microdump is empty.";
89+ return 1;
90+ }
8491 file_stream.seekg(0, std::ios_base::beg);
8592 file_stream.read(&bytes[0], bytes.size());
8693 string microdump_content(&bytes[0], bytes.size());
@@ -94,14 +101,15 @@ int PrintMicrodumpProcess(const Options& options) {
94101 StackFrameSymbolizer frame_symbolizer(symbol_supplier.get(), &resolver);
95102 ProcessState process_state;
96103 MicrodumpProcessor microdump_processor(&frame_symbolizer);
97- ProcessResult res = microdump_processor.Process(microdump_content,
104+ Microdump microdump(microdump_content);
105+ ProcessResult res = microdump_processor.Process(&microdump,
98106 &process_state);
99107
100108 if (res == google_breakpad::PROCESS_OK) {
101109 if (options.machine_readable) {
102110 PrintProcessStateMachineReadable(process_state);
103111 } else {
104- PrintProcessState(process_state, false, &resolver);
112+ PrintProcessState(process_state, options.output_stack_contents, &resolver);
105113 }
106114 return 0;
107115 }
@@ -120,7 +128,8 @@ static void Usage(int argc, const char *argv[], bool error) {
120128 "\n"
121129 "Options:\n"
122130 "\n"
123- " -m Output in machine-readable format\n",
131+ " -m Output in machine-readable format\n"
132+ " -s Output stack contents\n",
124133 basename(argv[0]));
125134 }
126135
@@ -128,8 +137,9 @@ static void SetupOptions(int argc, const char *argv[], Options* options) {
128137 int ch;
129138
130139 options->machine_readable = false;
140+ options->output_stack_contents = false;
131141
132- while ((ch = getopt(argc, (char * const *)argv, "hm")) != -1) {
142+ while ((ch = getopt(argc, (char * const *)argv, "hms")) != -1) {
133143 switch (ch) {
134144 case 'h':
135145 Usage(argc, argv, false);
@@ -139,6 +149,9 @@ static void SetupOptions(int argc, const char *argv[], Options* options) {
139149 case 'm':
140150 options->machine_readable = true;
141151 break;
152+ case 's':
153+ options->output_stack_contents = true;
154+ break;
142155
143156 case '?':
144157 Usage(argc, argv, true);
Afficher sur ancien navigateur de dépôt.