diff --git a/src/processor/microdump_stackwalk.cc b/src/processor/microdump_stackwalk.cc index 03fa77e1..34b6fb94 100644 --- a/src/processor/microdump_stackwalk.cc +++ b/src/processor/microdump_stackwalk.cc @@ -110,7 +110,10 @@ int PrintMicrodumpProcess(const Options& options) { if (options.machine_readable) { PrintProcessStateMachineReadable(process_state); } else { - PrintProcessState(process_state, options.output_stack_contents, &resolver); + // Microdump has only one thread, |output_requesting_thread_only|'s value + // has no effect. + PrintProcessState(process_state, options.output_stack_contents, + /*output_requesting_thread_only=*/false, &resolver); } return 0; } diff --git a/src/processor/minidump_stackwalk.cc b/src/processor/minidump_stackwalk.cc index aedd0271..270a2b85 100644 --- a/src/processor/minidump_stackwalk.cc +++ b/src/processor/minidump_stackwalk.cc @@ -57,6 +57,7 @@ namespace { struct Options { bool machine_readable; bool output_stack_contents; + bool output_requesting_thread_only; string minidump_file; std::vector symbol_paths; @@ -111,7 +112,8 @@ bool PrintMinidumpProcess(const Options& options) { if (options.machine_readable) { PrintProcessStateMachineReadable(process_state); } else { - PrintProcessState(process_state, options.output_stack_contents, &resolver); + PrintProcessState(process_state, options.output_stack_contents, + options.output_requesting_thread_only, &resolver); } return true; @@ -128,7 +130,8 @@ static void Usage(int argc, const char *argv[], bool error) { "Options:\n" "\n" " -m Output in machine-readable format\n" - " -s Output stack contents\n", + " -s Output stack contents\n" + " -c Output thread that causes crash or dump only\n", google_breakpad::BaseName(argv[0]).c_str()); } @@ -137,14 +140,18 @@ static void SetupOptions(int argc, const char *argv[], Options* options) { options->machine_readable = false; options->output_stack_contents = false; + options->output_requesting_thread_only = false; - while ((ch = getopt(argc, (char * const*)argv, "hms")) != -1) { + while ((ch = getopt(argc, (char * const*)argv, "chms")) != -1) { switch (ch) { case 'h': Usage(argc, argv, false); exit(0); break; + case 'c': + options->output_requesting_thread_only = true; + break; case 'm': options->machine_readable = true; break; diff --git a/src/processor/stackwalk_common.cc b/src/processor/stackwalk_common.cc index 90475720..a7609b9c 100644 --- a/src/processor/stackwalk_common.cc +++ b/src/processor/stackwalk_common.cc @@ -786,6 +786,7 @@ static void PrintModulesMachineReadable(const CodeModules* modules) { void PrintProcessState(const ProcessState& process_state, bool output_stack_contents, + bool output_requesting_thread_only, SourceLineResolverInterface* resolver) { // Print OS and CPU information. string cpu = process_state.system_info()->cpu; @@ -856,17 +857,19 @@ void PrintProcessState(const ProcessState& process_state, process_state.modules(), resolver); } - // Print all of the threads in the dump. - int thread_count = process_state.threads()->size(); - for (int thread_index = 0; thread_index < thread_count; ++thread_index) { - if (thread_index != requesting_thread) { - // Don't print the crash thread again, it was already printed. - printf("\n"); - printf("Thread %d\n", thread_index); - PrintStack(process_state.threads()->at(thread_index), cpu, - output_stack_contents, - process_state.thread_memory_regions()->at(thread_index), - process_state.modules(), resolver); + if (!output_requesting_thread_only) { + // Print all of the threads in the dump. + int thread_count = process_state.threads()->size(); + for (int thread_index = 0; thread_index < thread_count; ++thread_index) { + if (thread_index != requesting_thread) { + // Don't print the crash thread again, it was already printed. + printf("\n"); + printf("Thread %d\n", thread_index); + PrintStack(process_state.threads()->at(thread_index), cpu, + output_stack_contents, + process_state.thread_memory_regions()->at(thread_index), + process_state.modules(), resolver); + } } } diff --git a/src/processor/stackwalk_common.h b/src/processor/stackwalk_common.h index a74f7b6d..998f89b0 100644 --- a/src/processor/stackwalk_common.h +++ b/src/processor/stackwalk_common.h @@ -42,6 +42,7 @@ class SourceLineResolverInterface; void PrintProcessStateMachineReadable(const ProcessState& process_state); void PrintProcessState(const ProcessState& process_state, bool output_stack_contents, + bool output_requesting_thread_only, SourceLineResolverInterface* resolver); } // namespace google_breakpad