OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "minidump/minidump_writer_util.h" | 24 #include "minidump/minidump_writer_util.h" |
25 #include "package.h" | 25 #include "package.h" |
26 #include "snapshot/process_snapshot.h" | 26 #include "snapshot/process_snapshot.h" |
27 #include "snapshot/system_snapshot.h" | 27 #include "snapshot/system_snapshot.h" |
28 #include "util/file/file_writer.h" | 28 #include "util/file/file_writer.h" |
29 #include "util/numeric/in_range_cast.h" | 29 #include "util/numeric/in_range_cast.h" |
30 #include "util/numeric/safe_assignment.h" | 30 #include "util/numeric/safe_assignment.h" |
31 | 31 |
32 #if defined(OS_MACOSX) | 32 #if defined(OS_MACOSX) |
33 #include <AvailabilityMacros.h> | 33 #include <AvailabilityMacros.h> |
| 34 #elif defined(OS_ANDROID) |
| 35 #include <android/api-level.h> |
34 #endif | 36 #endif |
35 | 37 |
36 namespace crashpad { | 38 namespace crashpad { |
37 namespace { | 39 namespace { |
38 | 40 |
39 uint32_t TimevalToRoundedSeconds(const timeval& tv) { | 41 uint32_t TimevalToRoundedSeconds(const timeval& tv) { |
40 uint32_t seconds = | 42 uint32_t seconds = |
41 InRangeCast<uint32_t>(tv.tv_sec, std::numeric_limits<uint32_t>::max()); | 43 InRangeCast<uint32_t>(tv.tv_sec, std::numeric_limits<uint32_t>::max()); |
42 const int kMicrosecondsPerSecond = static_cast<int>(1E6); | 44 const int kMicrosecondsPerSecond = static_cast<int>(1E6); |
43 if (tv.tv_usec >= kMicrosecondsPerSecond / 2 && | 45 if (tv.tv_usec >= kMicrosecondsPerSecond / 2 && |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // For MINIDUMP_MISC_INFO_4::DbgBldStr. dbghelp produces strings like | 94 // For MINIDUMP_MISC_INFO_4::DbgBldStr. dbghelp produces strings like |
93 // “dbghelp.i386,6.3.9600.16520” and “dbghelp.amd64,6.3.9600.16520”. Mimic that | 95 // “dbghelp.i386,6.3.9600.16520” and “dbghelp.amd64,6.3.9600.16520”. Mimic that |
94 // format, and add the OS that wrote the minidump along with any relevant | 96 // format, and add the OS that wrote the minidump along with any relevant |
95 // platform-specific data describing the compilation environment. | 97 // platform-specific data describing the compilation environment. |
96 std::string MinidumpMiscInfoDebugBuildString() { | 98 std::string MinidumpMiscInfoDebugBuildString() { |
97 // Caution: the minidump file format only has room for 39 UTF-16 code units | 99 // Caution: the minidump file format only has room for 39 UTF-16 code units |
98 // plus a UTF-16 NUL terminator. Don’t let strings get longer than this, or | 100 // plus a UTF-16 NUL terminator. Don’t let strings get longer than this, or |
99 // they will be truncated and a message will be logged. | 101 // they will be truncated and a message will be logged. |
100 #if defined(OS_MACOSX) | 102 #if defined(OS_MACOSX) |
101 const char kOS[] = "mac"; | 103 const char kOS[] = "mac"; |
| 104 #elif defined(OS_ANDROID) |
| 105 const char kOS[] = "android"; |
102 #elif defined(OS_LINUX) | 106 #elif defined(OS_LINUX) |
103 const char kOS[] = "linux"; | 107 const char kOS[] = "linux"; |
104 #elif defined(OS_WIN) | 108 #elif defined(OS_WIN) |
105 const char kOS[] = "win"; | 109 const char kOS[] = "win"; |
106 #else | 110 #else |
107 #error define kOS for this operating system | 111 #error define kOS for this operating system |
108 #endif | 112 #endif |
109 | 113 |
110 #if defined(ARCH_CPU_X86) | 114 #if defined(ARCH_CPU_X86) |
111 const char kCPU[] = "i386"; | 115 const char kCPU[] = "i386"; |
112 #elif defined(ARCH_CPU_X86_64) | 116 #elif defined(ARCH_CPU_X86_64) |
113 const char kCPU[] = "amd64"; | 117 const char kCPU[] = "amd64"; |
| 118 #elif defined(ARCH_CPU_ARMEL) |
| 119 const char kCPU[] = "arm"; |
| 120 #elif defined(ARCH_CPU_ARM64) |
| 121 const char kCPU[] = "arm64"; |
114 #else | 122 #else |
115 #error define kCPU for this CPU | 123 #error define kCPU for this CPU |
116 #endif | 124 #endif |
117 | 125 |
118 std::string debug_build_string = base::StringPrintf("%s.%s,%s,%s", | 126 std::string debug_build_string = base::StringPrintf("%s.%s,%s,%s", |
119 PACKAGE_TARNAME, | 127 PACKAGE_TARNAME, |
120 kCPU, | 128 kCPU, |
121 PACKAGE_VERSION, | 129 PACKAGE_VERSION, |
122 kOS); | 130 kOS); |
123 | 131 |
124 #if defined(OS_MACOSX) | 132 #if defined(OS_MACOSX) |
125 debug_build_string += base::StringPrintf( | 133 debug_build_string += base::StringPrintf( |
126 ",%d,%d", | 134 ",%d,%d", |
127 AvailabilityVersionToMacOSXMinorVersion(MAC_OS_X_VERSION_MIN_REQUIRED), | 135 AvailabilityVersionToMacOSXMinorVersion(MAC_OS_X_VERSION_MIN_REQUIRED), |
128 AvailabilityVersionToMacOSXMinorVersion(MAC_OS_X_VERSION_MAX_ALLOWED)); | 136 AvailabilityVersionToMacOSXMinorVersion(MAC_OS_X_VERSION_MAX_ALLOWED)); |
| 137 #elif defined(OS_ANDROID) |
| 138 debug_build_string += base::StringPrintf(",%d", __ANDROID_API__); |
129 #endif | 139 #endif |
130 | 140 |
131 return debug_build_string; | 141 return debug_build_string; |
132 } | 142 } |
133 | 143 |
134 } // namespace internal | 144 } // namespace internal |
135 | 145 |
136 MinidumpMiscInfoWriter::MinidumpMiscInfoWriter() | 146 MinidumpMiscInfoWriter::MinidumpMiscInfoWriter() |
137 : MinidumpStreamWriter(), misc_info_() { | 147 : MinidumpStreamWriter(), misc_info_() { |
138 } | 148 } |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 MINIDUMP_MISC3_TIMEZONE | MINIDUMP_MISC3_PROTECTED_PROCESS)) { | 370 MINIDUMP_MISC3_TIMEZONE | MINIDUMP_MISC3_PROTECTED_PROCESS)) { |
361 return sizeof(MINIDUMP_MISC_INFO_3); | 371 return sizeof(MINIDUMP_MISC_INFO_3); |
362 } | 372 } |
363 if (misc_info_.Flags1 & MINIDUMP_MISC1_PROCESSOR_POWER_INFO) { | 373 if (misc_info_.Flags1 & MINIDUMP_MISC1_PROCESSOR_POWER_INFO) { |
364 return sizeof(MINIDUMP_MISC_INFO_2); | 374 return sizeof(MINIDUMP_MISC_INFO_2); |
365 } | 375 } |
366 return sizeof(MINIDUMP_MISC_INFO); | 376 return sizeof(MINIDUMP_MISC_INFO); |
367 } | 377 } |
368 | 378 |
369 } // namespace crashpad | 379 } // namespace crashpad |
OLD | NEW |