mmentovai | 3261e8b | 2006-09-06 02:56:44 +0000 | [diff] [blame] | 1 | // Copyright (C) 2006 Google Inc. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // minidump_dump.cc: Print the contents of a minidump file in somewhat |
| 16 | // readable text. |
| 17 | // |
| 18 | // Author: Mark Mentovai |
| 19 | |
mmentovai | 3261e8b | 2006-09-06 02:56:44 +0000 | [diff] [blame] | 20 | #include <stdlib.h> |
| 21 | #include <stdio.h> |
mmentovai | 6dd21d3 | 2006-09-08 16:41:17 +0000 | [diff] [blame] | 22 | |
| 23 | #include <string> |
mmentovai | 3261e8b | 2006-09-06 02:56:44 +0000 | [diff] [blame] | 24 | |
| 25 | #include "processor/minidump.h" |
| 26 | |
| 27 | |
mmentovai | 6dd21d3 | 2006-09-08 16:41:17 +0000 | [diff] [blame] | 28 | using std::string; |
mmentovai | 3261e8b | 2006-09-06 02:56:44 +0000 | [diff] [blame] | 29 | using namespace google_airbag; |
| 30 | |
| 31 | |
| 32 | int main(int argc, char** argv) { |
| 33 | if (argc != 2) { |
| 34 | fprintf(stderr, "usage: %s <file>\n", argv[0]); |
| 35 | exit(1); |
| 36 | } |
| 37 | |
mmentovai | 6dd21d3 | 2006-09-08 16:41:17 +0000 | [diff] [blame] | 38 | Minidump minidump(argv[1]); |
mmentovai | 3261e8b | 2006-09-06 02:56:44 +0000 | [diff] [blame] | 39 | if (!minidump.Read()) { |
| 40 | printf("minidump.Read() failed\n"); |
| 41 | exit(1); |
| 42 | } |
| 43 | minidump.Print(); |
| 44 | |
| 45 | int error = 0; |
| 46 | |
| 47 | MinidumpThreadList* threadList = minidump.GetThreadList(); |
| 48 | if (!threadList) { |
| 49 | error |= 1 << 2; |
| 50 | printf("minidump.GetThreadList() failed\n"); |
| 51 | } else { |
| 52 | threadList->Print(); |
| 53 | } |
| 54 | |
| 55 | MinidumpModuleList* moduleList = minidump.GetModuleList(); |
| 56 | if (!moduleList) { |
| 57 | error |= 1 << 3; |
| 58 | printf("minidump.GetModuleList() failed\n"); |
| 59 | } else { |
| 60 | moduleList->Print(); |
| 61 | } |
| 62 | |
| 63 | MinidumpMemoryList* memoryList = minidump.GetMemoryList(); |
| 64 | if (!memoryList) { |
| 65 | error |= 1 << 4; |
| 66 | printf("minidump.GetMemoryList() failed\n"); |
| 67 | } else { |
| 68 | memoryList->Print(); |
| 69 | } |
| 70 | |
| 71 | MinidumpException* exception = minidump.GetException(); |
| 72 | if (!exception) { |
| 73 | error |= 1 << 5; |
| 74 | printf("minidump.GetException() failed\n"); |
| 75 | } else { |
| 76 | exception->Print(); |
| 77 | } |
| 78 | |
| 79 | MinidumpSystemInfo* systemInfo = minidump.GetSystemInfo(); |
| 80 | if (!systemInfo) { |
| 81 | error |= 1 << 6; |
| 82 | printf("minidump.GetSystemInfo() failed\n"); |
| 83 | } else { |
| 84 | systemInfo->Print(); |
| 85 | } |
| 86 | |
| 87 | MinidumpMiscInfo* miscInfo = minidump.GetMiscInfo(); |
| 88 | if (!miscInfo) { |
| 89 | error |= 1 << 7; |
| 90 | printf("minidump.GetMiscInfo() failed\n"); |
| 91 | } else { |
| 92 | miscInfo->Print(); |
| 93 | } |
| 94 | |
| 95 | // Use return instead of exit to allow destructors to run. |
| 96 | return(error); |
| 97 | } |