Left: | ||
Right: |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 // return value of PrintRegister. Note that PrintRegister will print a | 82 // return value of PrintRegister. Note that PrintRegister will print a |
83 // newline before the first register (with |sequence| set to 0) is printed. | 83 // newline before the first register (with |sequence| set to 0) is printed. |
84 // The caller is responsible for printing the final newline after a set | 84 // The caller is responsible for printing the final newline after a set |
85 // of registers is completely printed, regardless of the number of calls | 85 // of registers is completely printed, regardless of the number of calls |
86 // to PrintRegister. | 86 // to PrintRegister. |
87 static int PrintRegister(const char *name, u_int32_t value, int sequence) { | 87 static int PrintRegister(const char *name, u_int32_t value, int sequence) { |
88 if (sequence % 4 == 0) { | 88 if (sequence % 4 == 0) { |
89 printf("\n "); | 89 printf("\n "); |
90 } | 90 } |
91 printf(" %5s = 0x%08x", name, value); | 91 printf(" %5s = 0x%08x", name, value); |
92 | |
93 return ++sequence; | |
94 } | |
95 | |
96 // PrintRegister64 does the same thing, but for 64-bit registers. | |
97 static int PrintRegister64(const char *name, u_int64_t value, int sequence) { | |
98 if (sequence % 2 == 0) { | |
Mark Mentovai
2011/01/28 19:45:28
Maybe you should leave this at sequence % 4, and…
| |
99 printf("\n "); | |
100 } | |
101 printf(" %5s = 0x%016" PRIx64 , name, value); | |
102 | |
92 return ++sequence; | 103 return ++sequence; |
Mark Mentovai
2011/01/28 19:45:28
make this return sequence + 2.
Would that properl
| |
93 } | 104 } |
94 | 105 |
95 // StripSeparator takes a string |original| and returns a copy | 106 // StripSeparator takes a string |original| and returns a copy |
96 // of the string with all occurences of |kOutputSeparator| removed. | 107 // of the string with all occurences of |kOutputSeparator| removed. |
97 static string StripSeparator(const string &original) { | 108 static string StripSeparator(const string &original) { |
98 string result = original; | 109 string result = original; |
99 string::size_type position = 0; | 110 string::size_type position = 0; |
100 while ((position = result.find(kOutputSeparator, position)) != string::npos) { | 111 while ((position = result.find(kOutputSeparator, position)) != string::npos) { |
101 result.erase(position, 1); | 112 result.erase(position, 1); |
102 } | 113 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 | 183 |
173 if (frame_ppc->context_validity & StackFramePPC::CONTEXT_VALID_SRR0) | 184 if (frame_ppc->context_validity & StackFramePPC::CONTEXT_VALID_SRR0) |
174 sequence = PrintRegister("srr0", frame_ppc->context.srr0, sequence); | 185 sequence = PrintRegister("srr0", frame_ppc->context.srr0, sequence); |
175 if (frame_ppc->context_validity & StackFramePPC::CONTEXT_VALID_GPR1) | 186 if (frame_ppc->context_validity & StackFramePPC::CONTEXT_VALID_GPR1) |
176 sequence = PrintRegister("r1", frame_ppc->context.gpr[1], sequence); | 187 sequence = PrintRegister("r1", frame_ppc->context.gpr[1], sequence); |
177 } else if (cpu == "amd64") { | 188 } else if (cpu == "amd64") { |
178 const StackFrameAMD64 *frame_amd64 = | 189 const StackFrameAMD64 *frame_amd64 = |
179 reinterpret_cast<const StackFrameAMD64*>(frame); | 190 reinterpret_cast<const StackFrameAMD64*>(frame); |
180 | 191 |
181 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RBX) | 192 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RBX) |
182 sequence = PrintRegister("rbx", frame_amd64->context.rbx, sequence); | 193 sequence = PrintRegister64("rbx", frame_amd64->context.rbx, sequence); |
183 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_R12) | 194 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_R12) |
184 sequence = PrintRegister("r12", frame_amd64->context.r12, sequence); | 195 sequence = PrintRegister64("r12", frame_amd64->context.r12, sequence); |
185 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_R13) | 196 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_R13) |
186 sequence = PrintRegister("r13", frame_amd64->context.r13, sequence); | 197 sequence = PrintRegister64("r13", frame_amd64->context.r13, sequence); |
187 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_R14) | 198 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_R14) |
188 sequence = PrintRegister("r14", frame_amd64->context.r14, sequence); | 199 sequence = PrintRegister64("r14", frame_amd64->context.r14, sequence); |
189 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_R15) | 200 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_R15) |
190 sequence = PrintRegister("r15", frame_amd64->context.r15, sequence); | 201 sequence = PrintRegister64("r15", frame_amd64->context.r15, sequence); |
191 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RIP) | 202 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RIP) |
192 sequence = PrintRegister("rip", frame_amd64->context.rip, sequence); | 203 sequence = PrintRegister64("rip", frame_amd64->context.rip, sequence); |
193 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RSP) | 204 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RSP) |
194 sequence = PrintRegister("rsp", frame_amd64->context.rsp, sequence); | 205 sequence = PrintRegister64("rsp", frame_amd64->context.rsp, sequence); |
195 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RBP) | 206 if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RBP) |
196 sequence = PrintRegister("rbp", frame_amd64->context.rbp, sequence); | 207 sequence = PrintRegister64("rbp", frame_amd64->context.rbp, sequence); |
197 } else if (cpu == "sparc") { | 208 } else if (cpu == "sparc") { |
198 const StackFrameSPARC *frame_sparc = | 209 const StackFrameSPARC *frame_sparc = |
199 reinterpret_cast<const StackFrameSPARC*>(frame); | 210 reinterpret_cast<const StackFrameSPARC*>(frame); |
200 | 211 |
201 if (frame_sparc->context_validity & StackFrameSPARC::CONTEXT_VALID_SP) | 212 if (frame_sparc->context_validity & StackFrameSPARC::CONTEXT_VALID_SP) |
202 sequence = PrintRegister("sp", frame_sparc->context.g_r[14], sequence); | 213 sequence = PrintRegister("sp", frame_sparc->context.g_r[14], sequence); |
203 if (frame_sparc->context_validity & StackFrameSPARC::CONTEXT_VALID_FP) | 214 if (frame_sparc->context_validity & StackFrameSPARC::CONTEXT_VALID_FP) |
204 sequence = PrintRegister("fp", frame_sparc->context.g_r[30], sequence); | 215 sequence = PrintRegister("fp", frame_sparc->context.g_r[30], sequence); |
205 if (frame_sparc->context_validity & StackFrameSPARC::CONTEXT_VALID_PC) | 216 if (frame_sparc->context_validity & StackFrameSPARC::CONTEXT_VALID_PC) |
206 sequence = PrintRegister("pc", frame_sparc->context.pc, sequence); | 217 sequence = PrintRegister("pc", frame_sparc->context.pc, sequence); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 std::vector<std::string> symbol_paths; | 569 std::vector<std::string> symbol_paths; |
559 if (argc > symbol_path_arg) { | 570 if (argc > symbol_path_arg) { |
560 for (int argi = symbol_path_arg; argi < argc; ++argi) | 571 for (int argi = symbol_path_arg; argi < argc; ++argi) |
561 symbol_paths.push_back(argv[argi]); | 572 symbol_paths.push_back(argv[argi]); |
562 } | 573 } |
563 | 574 |
564 return PrintMinidumpProcess(minidump_file, | 575 return PrintMinidumpProcess(minidump_file, |
565 symbol_paths, | 576 symbol_paths, |
566 machine_readable) ? 0 : 1; | 577 machine_readable) ? 0 : 1; |
567 } | 578 } |
OLD | NEW |