OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 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 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_EXTENSIONS_H_ |
| 16 #define CRASHPAD_MINIDUMP_MINIDUMP_EXTENSIONS_H_ |
| 17 |
| 18 #include <dbghelp.h> |
| 19 #include <stdint.h> |
| 20 #include <winnt.h> |
| 21 |
| 22 #include "util/misc/uuid.h" |
| 23 |
| 24 namespace crashpad { |
| 25 |
| 26 //! \brief Minidump stream type values for MINIDUMP_DIRECTORY::StreamType. Each |
| 27 //! stream structure has a corresponding stream type value to identify it. |
| 28 //! |
| 29 //! \sa MINIDUMP_STREAM_TYPE |
| 30 enum MinidumpStreamType { |
| 31 //! \brief The stream type for MINIDUMP_THREAD_LIST. |
| 32 //! |
| 33 //! \sa ThreadListStream |
| 34 kMinidumpStreamTypeThreadList = ThreadListStream, |
| 35 |
| 36 //! \brief The stream type for MINIDUMP_MODULE_LIST. |
| 37 //! |
| 38 //! \sa ModuleListStream |
| 39 kMinidumpStreamTypeModuleList = ModuleListStream, |
| 40 |
| 41 //! \brief The stream type for MINIDUMP_MEMORY_LIST. |
| 42 //! |
| 43 //! \sa MemoryListStream |
| 44 kMinidumpStreamTypeMemoryList = MemoryListStream, |
| 45 |
| 46 //! \brief The stream type for MINIDUMP_EXCEPTION_STREAM. |
| 47 //! |
| 48 //! \sa ExceptionStream |
| 49 kMinidumpStreamTypeException = ExceptionStream, |
| 50 |
| 51 //! \brief The stream type for MINIDUMP_SYSTEM_INFO. |
| 52 //! |
| 53 //! \sa SystemInfoStream |
| 54 kMinidumpStreamTypeSystemInfo = SystemInfoStream, |
| 55 |
| 56 //! \brief The stream type for MINIDUMP_MISC_INFO, MINIDUMP_MISC_INFO_2, |
| 57 //! MINIDUMP_MISC_INFO_3, and MINIDUMP_MISC_INFO_4. |
| 58 //! |
| 59 //! \sa MiscInfoStream |
| 60 kMinidumpStreamTypeMiscInfo = MiscInfoStream, |
| 61 |
| 62 // 0x4350 = "CP" |
| 63 |
| 64 //! \brief The stream type for MinidumpCrashpadInfo. |
| 65 kMinidumpStreamTypeCrashpadInfo = 0x43500001, |
| 66 }; |
| 67 |
| 68 //! \brief A variable-length UTF-8-encoded string carried within a minidump |
| 69 //! file. |
| 70 //! |
| 71 //! \sa MINIDUMP_STRING |
| 72 struct __attribute__((packed, aligned(4))) MinidumpUTF8String { |
| 73 // The field names do not conform to typical style, they match the names used |
| 74 // in MINIDUMP_STRING. This makes it easier to operate on MINIDUMP_STRING (for |
| 75 // UTF-16 strings) and MinidumpUTF8String using templates. |
| 76 |
| 77 //! \brief The length of the #Buffer field in bytes, not including the `NUL` |
| 78 //! terminator. |
| 79 //! |
| 80 //! \note This field is interpreted as a byte count, not a count of Unicode |
| 81 //! code points. |
| 82 uint32_t Length; |
| 83 |
| 84 //! \brief The string, encoded in UTF-8, and terminated with a `NUL` byte. |
| 85 uint8_t Buffer[0]; |
| 86 }; |
| 87 |
| 88 //! \brief CPU type values for MINIDUMP_SYSTEM_INFO::ProcessorArchitecture. |
| 89 //! |
| 90 //! \sa \ref PROCESSOR_ARCHITECTURE_x "PROCESSOR_ARCHITECTURE_*" |
| 91 enum MinidumpCPUArchitecture : uint16_t { |
| 92 //! \brief 32-bit x86. |
| 93 //! |
| 94 //! These systems identify their CPUs generically as “x86” or “ia32”, or with |
| 95 //! more specific names such as “i386”, “i486”, “i586”, and “i686”. |
| 96 kMinidumpCPUArchitectureX86 = PROCESSOR_ARCHITECTURE_INTEL, |
| 97 |
| 98 kMinidumpCPUArchitectureMIPS = PROCESSOR_ARCHITECTURE_MIPS, |
| 99 kMinidumpCPUArchitectureAlpha = PROCESSOR_ARCHITECTURE_ALPHA, |
| 100 |
| 101 //! \brief 32-bit PowerPC. |
| 102 //! |
| 103 //! These systems identify their CPUs generically as “ppc”, or with more |
| 104 //! specific names such as “ppc6xx”, “ppc7xx”, and “ppc74xx”. |
| 105 kMinidumpCPUArchitecturePPC = PROCESSOR_ARCHITECTURE_PPC, |
| 106 |
| 107 kMinidumpCPUArchitectureSHx = PROCESSOR_ARCHITECTURE_SHX, |
| 108 |
| 109 //! \brief 32-bit ARM. |
| 110 //! |
| 111 //! These systems identify their CPUs generically as “arm”, or with more |
| 112 //! specific names such as “armv6” and “armv7”. |
| 113 kMinidumpCPUArchitectureARM = PROCESSOR_ARCHITECTURE_ARM, |
| 114 |
| 115 kMinidumpCPUArchitectureIA64 = PROCESSOR_ARCHITECTURE_IA64, |
| 116 kMinidumpCPUArchitectureAlpha64 = PROCESSOR_ARCHITECTURE_ALPHA64, |
| 117 kMinidumpCPUArchitectureMSIL = PROCESSOR_ARCHITECTURE_MSIL, |
| 118 |
| 119 //! \brief 64-bit x86. |
| 120 //! |
| 121 //! These systems identify their CPUs as “x86_64”, “amd64”, or “x64”. |
| 122 kMinidumpCPUArchitectureAMD64 = PROCESSOR_ARCHITECTURE_AMD64, |
| 123 |
| 124 kMinidumpCPUArchitectureX86Win64 = PROCESSOR_ARCHITECTURE_IA32_ON_WIN64, |
| 125 kMinidumpCPUArchitectureNeutral = PROCESSOR_ARCHITECTURE_NEUTRAL, |
| 126 kMinidumpCPUArchitectureSPARC = 0x8001, |
| 127 |
| 128 //! \brief 64-bit PowerPC. |
| 129 //! |
| 130 //! These systems identify their CPUs generically as “ppc64”, or with more |
| 131 //! specific names such as “ppc970”. |
| 132 kMinidumpCPUArchitecturePPC64 = 0x8002, |
| 133 |
| 134 //! \brief 64-bit ARM. |
| 135 //! |
| 136 //! These systems identify their CPUs generically as “arm64” or “aarch64”, or |
| 137 //! with more specific names such as “armv8”. |
| 138 kMinidumpCPUArchitectureARM64 = 0x8003, |
| 139 |
| 140 //! \brief Unknown CPU architecture. |
| 141 kMinidumpCPUArchitectureUnknown = PROCESSOR_ARCHITECTURE_UNKNOWN, |
| 142 }; |
| 143 |
| 144 //! \brief Operating system type values for MINIDUMP_SYSTEM_INFO::ProductType. |
| 145 //! |
| 146 //! \sa \ref VER_NT_x "VER_NT_*" |
| 147 enum MinidumpOSType : uint8_t { |
| 148 //! \brief A “desktop” or “workstation” system. |
| 149 kMinidumpOSTypeWorkstation = VER_NT_WORKSTATION, |
| 150 |
| 151 //! \brief A “domain controller” system. Windows-specific. |
| 152 kMinidumpOSTypeDomainController = VER_NT_DOMAIN_CONTROLLER, |
| 153 |
| 154 //! \brief A “server” system. |
| 155 kMinidumpOSTypeServer = VER_NT_SERVER, |
| 156 }; |
| 157 |
| 158 //! \brief Operating system family values for MINIDUMP_SYSTEM_INFO::PlatformId. |
| 159 //! |
| 160 //! \sa \ref VER_PLATFORM_x "VER_PLATFORM_*" |
| 161 enum MinidumpOS : uint32_t { |
| 162 //! \brief Windows 3.1. |
| 163 kMinidumpOSWin32s = VER_PLATFORM_WIN32s, |
| 164 |
| 165 //! \brief Windows 95, Windows 98, and Windows Me. |
| 166 kMinidumpOSWin32Windows = VER_PLATFORM_WIN32_WINDOWS, |
| 167 |
| 168 //! \brief Windows NT, Windows 2000, and later. |
| 169 kMinidumpOSWin32NT = VER_PLATFORM_WIN32_NT, |
| 170 |
| 171 kMinidumpOSUnix = 0x8000, |
| 172 |
| 173 //! \brief Mac OS X, Darwin for traditional systems. |
| 174 kMinidumpOSMacOSX = 0x8101, |
| 175 |
| 176 //! \brief iOS, Darwin for mobile devices. |
| 177 kMinidumpOSiOS = 0x8102, |
| 178 |
| 179 //! \brief Linux, not including Android. |
| 180 kMinidumpOSLinux = 0x8201, |
| 181 |
| 182 kMinidumpOSSolaris = 0x8202, |
| 183 |
| 184 //! \brief Android. |
| 185 kMinidumpOSAndroid = 0x8203, |
| 186 |
| 187 kMinidumpOSPS3 = 0x8204, |
| 188 |
| 189 //! \brief Native Client (NaCl). |
| 190 kMinidumpOSNaCl = 0x8205, |
| 191 |
| 192 //! \brief Unknown operating system. |
| 193 kMinidumpOSUnknown = 0xffffffff, |
| 194 }; |
| 195 |
| 196 //! \brief A CodeView record linking to a `.pdb` 2.0 file. |
| 197 //! |
| 198 //! This format provides an indirect link to debugging data by referencing an |
| 199 //! external `.pdb` file by its name, timestamp, and age. This structure may be |
| 200 //! pointed to by MINIDUMP_MODULE::CvRecord. It has been superseded by |
| 201 //! MinidumpModuleCodeViewRecordPDB70. |
| 202 //! |
| 203 //! For more information about this structure and format, see <a |
| 204 //! href="http://www.debuginfo.com/articles/debuginfomatch.html#pdbfiles">Matchi
ng |
| 205 //! Debug Information</a>, PDB Files, and <a |
| 206 //! href="http://undocumented.rawol.com/sbs-w2k-1-windows-2000-debugging-support
.pdf#page=63">Undocumented |
| 207 //! Windows 2000 Secrets</a>, Windows 2000 Debugging Support/Microsoft Symbol |
| 208 //! File Internals/CodeView Subsections. |
| 209 //! |
| 210 //! \sa IMAGE_DEBUG_MISC |
| 211 struct MinidumpModuleCodeViewRecordPDB20 { |
| 212 //! \brief The magic number identifying this structure version, stored in |
| 213 //! #signature. |
| 214 //! |
| 215 //! In a hex dump, this will appear as “NB10” when produced by a little-endian |
| 216 //! machine. |
| 217 static const uint32_t kSignature = '01BN'; |
| 218 |
| 219 //! \brief The magic number identifying this structure version, the value of |
| 220 //! #kSignature. |
| 221 uint32_t signature; |
| 222 |
| 223 //! \brief The offset to CodeView data. |
| 224 //! |
| 225 //! In this structure, this field always has the value `0` because no CodeView |
| 226 //! data is present, there is only a link to CodeView data stored in an |
| 227 //! external file. |
| 228 uint32_t offset; |
| 229 |
| 230 //! \brief The time that the `.pdb` file was created, in `time_t` format, the |
| 231 //! number of seconds since the POSIX epoch. |
| 232 uint32_t timestamp; |
| 233 |
| 234 //! \brief The revision of the `.pdb` file. |
| 235 //! |
| 236 //! A `.pdb` file’s age indicates incremental changes to it. When a `.pdb` |
| 237 //! file is created, it has age `1`, and subsequent updates increase this |
| 238 //! value. |
| 239 uint32_t age; |
| 240 |
| 241 //! \brief The path or file name of the `.pdb` file associated with the |
| 242 //! module. |
| 243 //! |
| 244 //! This is a NUL-terminated string. On Windows, it will be encoded in the |
| 245 //! code page of the system that linked the module. On other operating |
| 246 //! systems, UTF-8 may be used. |
| 247 uint8_t pdb_name[1]; |
| 248 }; |
| 249 |
| 250 //! \brief A CodeView record linking to a `.pdb` 7.0 file. |
| 251 //! |
| 252 //! This format provides an indirect link to debugging data by referencing an |
| 253 //! external `.pdb` file by its name, %UUID, and age. This structure may be |
| 254 //! pointed to by MINIDUMP_MODULE::CvRecord. |
| 255 //! |
| 256 //! For more information about this structure and format, see <a |
| 257 //! href="http://www.debuginfo.com/articles/debuginfomatch.html#pdbfiles">Matchi
ng |
| 258 //! Debug Information</a>, PDB Files. |
| 259 //! |
| 260 //! \sa MinidumpModuleCodeViewRecordPDB20 |
| 261 //! \sa IMAGE_DEBUG_MISC |
| 262 struct MinidumpModuleCodeViewRecordPDB70 { |
| 263 //! \brief The magic number identifying this structure version, stored in |
| 264 //! #signature. |
| 265 //! |
| 266 //! In a hex dump, this will appear as “RSDS” when produced by a little-endian |
| 267 //! machine. |
| 268 static const uint32_t kSignature = 'SDSR'; |
| 269 |
| 270 //! \brief The magic number identifying this structure version, the value of |
| 271 //! #kSignature. |
| 272 uint32_t signature; |
| 273 |
| 274 //! \brief The `.pdb` file’s unique identifier. |
| 275 UUID uuid; |
| 276 |
| 277 //! \brief The revision of the `.pdb` file. |
| 278 //! |
| 279 //! A `.pdb` file’s age indicates incremental changes to it. When a `.pdb` |
| 280 //! file is created, it has age `1`, and subsequent updates increase this |
| 281 //! value. |
| 282 uint32_t age; |
| 283 |
| 284 //! \brief The path or file name of the `.pdb` file associated with the |
| 285 //! module. |
| 286 //! |
| 287 //! This is a NUL-terminated string. On Windows, it will be encoded in the |
| 288 //! code page of the system that linked the module. On other operating |
| 289 //! systems, UTF-8 may be used. |
| 290 uint8_t pdb_name[1]; |
| 291 }; |
| 292 |
| 293 //! \brief A key-value pair. |
| 294 struct __attribute__((packed, aligned(4))) MinidumpSimpleStringDictionaryEntry { |
| 295 //! \brief ::RVA of a MinidumpUTF8String containing the key of a key-value |
| 296 //! pair. |
| 297 RVA key; |
| 298 |
| 299 //! \brief ::RVA of a MinidumpUTF8String containing the value of a key-value |
| 300 //! pair. |
| 301 RVA value; |
| 302 }; |
| 303 |
| 304 //! \brief A list of key-value pairs. |
| 305 struct __attribute__((packed, aligned(4))) MinidumpSimpleStringDictionary { |
| 306 //! \brief The number of key-value pairs present. |
| 307 uint32_t count; |
| 308 |
| 309 //! \brief A list of MinidumpSimpleStringDictionaryEntry entries. |
| 310 MinidumpSimpleStringDictionaryEntry entries[0]; |
| 311 }; |
| 312 |
| 313 //! \brief Additional Crashpad-specific information carried within a minidump |
| 314 //! file. |
| 315 struct __attribute__((packed, aligned(4))) MinidumpCrashpadInfo { |
| 316 //! \brief The size of the entire structure, in bytes. |
| 317 //! |
| 318 //! \sa version |
| 319 uint32_t size; |
| 320 |
| 321 //! \brief The structure’s version number. This can be used to determine which |
| 322 //! other fields in the structure are valid. |
| 323 //! |
| 324 //! \sa size |
| 325 uint32_t version; |
| 326 |
| 327 //! \brief A MinidumpSimpleStringDictionary pointing to strings interpreted as |
| 328 //! key-value pairs. The process that crashed controlled the data that |
| 329 //! appears here. |
| 330 //! |
| 331 //! If MINIDUMP_LOCATION_DESCRIPTOR::DataSize is `0`, no key-value pairs are |
| 332 //! present, and MINIDUMP_LOCATION_DESCRIPTOR::Rva should not be consulted. |
| 333 //! |
| 334 //! This field is present when #version is at least `1`. |
| 335 MINIDUMP_LOCATION_DESCRIPTOR simple_annotations; |
| 336 }; |
| 337 |
| 338 } // namespace crashpad |
| 339 |
| 340 #endif // CRASHPAD_MINIDUMP_MINIDUMP_EXTENSIONS_H_ |
OLD | NEW |