Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(751)

Side by Side Diff: src/processor/minidump_stackwalk.cc

Issue 1650713002: Added a switch to dump minidump modules in minidump_stackwalk. (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/processor/stackwalk_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 Google Inc. 1 // Copyright (c) 2010 Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // is specified, it is made available for use by the MinidumpProcessor. 64 // is specified, it is made available for use by the MinidumpProcessor.
65 // 65 //
66 // Returns the value of MinidumpProcessor::Process. If processing succeeds, 66 // Returns the value of MinidumpProcessor::Process. If processing succeeds,
67 // prints identifying OS and CPU information from the minidump, crash 67 // prints identifying OS and CPU information from the minidump, crash
68 // information if the minidump was produced as a result of a crash, and 68 // information if the minidump was produced as a result of a crash, and
69 // call stacks for each thread contained in the minidump. All information 69 // call stacks for each thread contained in the minidump. All information
70 // is printed to stdout. 70 // is printed to stdout.
71 bool PrintMinidumpProcess(const string &minidump_file, 71 bool PrintMinidumpProcess(const string &minidump_file,
72 const std::vector<string> &symbol_paths, 72 const std::vector<string> &symbol_paths,
73 bool machine_readable, 73 bool machine_readable,
74 bool output_stack_contents) { 74 bool output_stack_contents,
75 bool output_modules_only) {
75 scoped_ptr<SimpleSymbolSupplier> symbol_supplier; 76 scoped_ptr<SimpleSymbolSupplier> symbol_supplier;
76 if (!symbol_paths.empty()) { 77 if (!symbol_paths.empty()) {
77 // TODO(mmentovai): check existence of symbol_path if specified? 78 // TODO(mmentovai): check existence of symbol_path if specified?
78 symbol_supplier.reset(new SimpleSymbolSupplier(symbol_paths)); 79 symbol_supplier.reset(new SimpleSymbolSupplier(symbol_paths));
79 } 80 }
80 81
81 BasicSourceLineResolver resolver; 82 BasicSourceLineResolver resolver;
82 MinidumpProcessor minidump_processor(symbol_supplier.get(), &resolver); 83 MinidumpProcessor minidump_processor(symbol_supplier.get(), &resolver);
83 84
84 // Process the minidump. 85 // Process the minidump.
85 Minidump dump(minidump_file); 86 Minidump dump(minidump_file);
86 if (!dump.Read()) { 87 if (!dump.Read()) {
87 BPLOG(ERROR) << "Minidump " << dump.path() << " could not be read"; 88 BPLOG(ERROR) << "Minidump " << dump.path() << " could not be read";
88 return false; 89 return false;
89 } 90 }
90 ProcessState process_state; 91 ProcessState process_state;
91 if (minidump_processor.Process(&dump, &process_state) != 92 if (minidump_processor.Process(&dump, &process_state) !=
92 google_breakpad::PROCESS_OK) { 93 google_breakpad::PROCESS_OK) {
93 BPLOG(ERROR) << "MinidumpProcessor::Process failed"; 94 BPLOG(ERROR) << "MinidumpProcessor::Process failed";
94 return false; 95 return false;
95 } 96 }
96 97
97 if (machine_readable) { 98 if (output_modules_only) {
99 PrintProcessModules(process_state);
100 } else if (machine_readable) {
98 PrintProcessStateMachineReadable(process_state); 101 PrintProcessStateMachineReadable(process_state);
99 } else { 102 } else {
100 PrintProcessState(process_state, output_stack_contents, &resolver); 103 PrintProcessState(process_state, output_stack_contents, &resolver);
101 } 104 }
102 105
103 return true; 106 return true;
104 } 107 }
105 108
106 void usage(const char *program_name) { 109 void usage(const char *program_name) {
107 fprintf(stderr, "usage: %s [-m|-s] <minidump-file> [symbol-path ...]\n" 110 fprintf(stderr, "usage: %s [-m|-s|-b] <minidump-file> [symbol-path ...]\n"
108 " -m : Output in machine-readable format\n" 111 " -m : Output in machine-readable format\n"
109 " -s : Output stack contents\n", 112 " -s : Output stack contents\n"
113 " -b : Output contained full module paths\n",
110 program_name); 114 program_name);
111 } 115 }
112 116
113 } // namespace 117 } // namespace
114 118
115 int main(int argc, char **argv) { 119 int main(int argc, char **argv) {
116 BPLOG_INIT(&argc, &argv); 120 BPLOG_INIT(&argc, &argv);
117 121
118 if (argc < 2) { 122 if (argc < 2) {
119 usage(argv[0]); 123 usage(argv[0]);
120 return 1; 124 return 1;
121 } 125 }
122 126
123 const char *minidump_file; 127 const char *minidump_file;
124 bool machine_readable = false; 128 bool machine_readable = false;
125 bool output_stack_contents = false; 129 bool output_stack_contents = false;
130 bool output_modules_only = false;
126 int symbol_path_arg; 131 int symbol_path_arg;
127 132
128 if (strcmp(argv[1], "-m") == 0) { 133 if (strcmp(argv[1], "-m") == 0) {
129 if (argc < 3) { 134 if (argc < 3) {
130 usage(argv[0]); 135 usage(argv[0]);
131 return 1; 136 return 1;
132 } 137 }
133 138
134 machine_readable = true; 139 machine_readable = true;
135 minidump_file = argv[2]; 140 minidump_file = argv[2];
136 symbol_path_arg = 3; 141 symbol_path_arg = 3;
137 } else if (strcmp(argv[1], "-s") == 0) { 142 } else if (strcmp(argv[1], "-s") == 0) {
138 if (argc < 3) { 143 if (argc < 3) {
139 usage(argv[0]); 144 usage(argv[0]);
140 return 1; 145 return 1;
141 } 146 }
142 147
143 output_stack_contents = true; 148 output_stack_contents = true;
144 minidump_file = argv[2]; 149 minidump_file = argv[2];
145 symbol_path_arg = 3; 150 symbol_path_arg = 3;
151 } else if (strcmp(argv[1], "-b") == 0) {
152 if (argc < 3) {
153 usage(argv[0]);
154 return 1;
155 }
156
157 output_modules_only = true;
158 minidump_file = argv[2];
159 symbol_path_arg = 3;
146 } else { 160 } else {
147 minidump_file = argv[1]; 161 minidump_file = argv[1];
148 symbol_path_arg = 2; 162 symbol_path_arg = 2;
149 } 163 }
150 164
151 // extra arguments are symbol paths 165 // extra arguments are symbol paths
152 std::vector<string> symbol_paths; 166 std::vector<string> symbol_paths;
153 if (argc > symbol_path_arg) { 167 if (argc > symbol_path_arg) {
154 for (int argi = symbol_path_arg; argi < argc; ++argi) 168 for (int argi = symbol_path_arg; argi < argc; ++argi)
155 symbol_paths.push_back(argv[argi]); 169 symbol_paths.push_back(argv[argi]);
156 } 170 }
157 171
158 return PrintMinidumpProcess(minidump_file, 172 return PrintMinidumpProcess(minidump_file,
159 symbol_paths, 173 symbol_paths,
160 machine_readable, 174 machine_readable,
161 output_stack_contents) ? 0 : 1; 175 output_stack_contents,
176 output_modules_only) ? 0 : 1;
162 } 177 }
OLDNEW
« no previous file with comments | « no previous file | src/processor/stackwalk_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698