OLD | NEW |
---|---|
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 Loading... | |
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 } | |
101 else if (machine_readable) { | |
Lei Zhang
2016/01/29 20:27:37
nit: merge with prev line
David Yen
2016/01/29 20:36:26
Done.
| |
98 PrintProcessStateMachineReadable(process_state); | 102 PrintProcessStateMachineReadable(process_state); |
99 } else { | 103 } else { |
100 PrintProcessState(process_state, output_stack_contents, &resolver); | 104 PrintProcessState(process_state, output_stack_contents, &resolver); |
101 } | 105 } |
102 | 106 |
103 return true; | 107 return true; |
104 } | 108 } |
105 | 109 |
106 void usage(const char *program_name) { | 110 void usage(const char *program_name) { |
107 fprintf(stderr, "usage: %s [-m|-s] <minidump-file> [symbol-path ...]\n" | 111 fprintf(stderr, "usage: %s [-m|-s] <minidump-file> [symbol-path ...]\n" |
Lei Zhang
2016/01/29 20:27:37
Update this to mention -b
David Yen
2016/01/29 20:36:26
Done.
| |
108 " -m : Output in machine-readable format\n" | 112 " -m : Output in machine-readable format\n" |
109 " -s : Output stack contents\n", | 113 " -s : Output stack contents\n" |
114 " -b : Output contained binary modules\n", | |
110 program_name); | 115 program_name); |
111 } | 116 } |
112 | 117 |
113 } // namespace | 118 } // namespace |
114 | 119 |
115 int main(int argc, char **argv) { | 120 int main(int argc, char **argv) { |
116 BPLOG_INIT(&argc, &argv); | 121 BPLOG_INIT(&argc, &argv); |
117 | 122 |
118 if (argc < 2) { | 123 if (argc < 2) { |
119 usage(argv[0]); | 124 usage(argv[0]); |
120 return 1; | 125 return 1; |
121 } | 126 } |
122 | 127 |
123 const char *minidump_file; | 128 const char *minidump_file; |
124 bool machine_readable = false; | 129 bool machine_readable = false; |
125 bool output_stack_contents = false; | 130 bool output_stack_contents = false; |
131 bool output_modules_only = false; | |
126 int symbol_path_arg; | 132 int symbol_path_arg; |
127 | 133 |
128 if (strcmp(argv[1], "-m") == 0) { | 134 if (strcmp(argv[1], "-m") == 0) { |
129 if (argc < 3) { | 135 if (argc < 3) { |
130 usage(argv[0]); | 136 usage(argv[0]); |
131 return 1; | 137 return 1; |
132 } | 138 } |
133 | 139 |
134 machine_readable = true; | 140 machine_readable = true; |
135 minidump_file = argv[2]; | 141 minidump_file = argv[2]; |
136 symbol_path_arg = 3; | 142 symbol_path_arg = 3; |
137 } else if (strcmp(argv[1], "-s") == 0) { | 143 } else if (strcmp(argv[1], "-s") == 0) { |
138 if (argc < 3) { | 144 if (argc < 3) { |
139 usage(argv[0]); | 145 usage(argv[0]); |
140 return 1; | 146 return 1; |
141 } | 147 } |
142 | 148 |
143 output_stack_contents = true; | 149 output_stack_contents = true; |
144 minidump_file = argv[2]; | 150 minidump_file = argv[2]; |
145 symbol_path_arg = 3; | 151 symbol_path_arg = 3; |
146 } else { | 152 } if (strcmp(argv[1], "-b") == 0) { |
Lei Zhang
2016/01/29 20:27:37
else if?
David Yen
2016/01/29 20:36:26
Done. I think this is what was breaking the other
| |
153 if (argc < 3) { | |
154 usage(argv[0]); | |
155 return 1; | |
156 } | |
157 | |
158 output_modules_only = true; | |
159 minidump_file = argv[2]; | |
160 symbol_path_arg = 3; | |
161 }else { | |
147 minidump_file = argv[1]; | 162 minidump_file = argv[1]; |
148 symbol_path_arg = 2; | 163 symbol_path_arg = 2; |
149 } | 164 } |
150 | 165 |
151 // extra arguments are symbol paths | 166 // extra arguments are symbol paths |
152 std::vector<string> symbol_paths; | 167 std::vector<string> symbol_paths; |
153 if (argc > symbol_path_arg) { | 168 if (argc > symbol_path_arg) { |
154 for (int argi = symbol_path_arg; argi < argc; ++argi) | 169 for (int argi = symbol_path_arg; argi < argc; ++argi) |
155 symbol_paths.push_back(argv[argi]); | 170 symbol_paths.push_back(argv[argi]); |
156 } | 171 } |
157 | 172 |
158 return PrintMinidumpProcess(minidump_file, | 173 return PrintMinidumpProcess(minidump_file, |
159 symbol_paths, | 174 symbol_paths, |
160 machine_readable, | 175 machine_readable, |
161 output_stack_contents) ? 0 : 1; | 176 output_stack_contents, |
177 output_modules_only) ? 0 : 1; | |
162 } | 178 } |
OLD | NEW |