/thirdparty/breakpad/google_breakpad/common/minidump_format.h

http://github.com/tomahawk-player/tomahawk · C Header · 794 lines · 399 code · 121 blank · 274 comment · 0 complexity · 567f323ffd137a096a04c1cd74cec5d2 MD5 · raw file

  1. /* Copyright (c) 2006, Google Inc.
  2. * All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following disclaimer
  12. * in the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Google Inc. nor the names of its
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
  29. /* minidump_format.h: A cross-platform reimplementation of minidump-related
  30. * portions of DbgHelp.h from the Windows Platform SDK.
  31. *
  32. * (This is C99 source, please don't corrupt it with C++.)
  33. *
  34. * Structures that are defined by Microsoft to contain a zero-length array
  35. * are instead defined here to contain an array with one element, as
  36. * zero-length arrays are forbidden by standard C and C++. In these cases,
  37. * *_minsize constants are provided to be used in place of sizeof. For a
  38. * cleaner interface to these sizes when using C++, see minidump_size.h.
  39. *
  40. * These structures are also sufficient to populate minidump files.
  41. *
  42. * These definitions may be extended to support handling minidump files
  43. * for other CPUs and other operating systems.
  44. *
  45. * Because precise data type sizes are crucial for this implementation to
  46. * function properly and portably in terms of interoperability with minidumps
  47. * produced by DbgHelp on Windows, a set of primitive types with known sizes
  48. * are used as the basis of each structure defined by this file. DbgHelp
  49. * on Windows is assumed to be the reference implementation; this file
  50. * seeks to provide a cross-platform compatible implementation. To avoid
  51. * collisions with the types and values defined and used by DbgHelp in the
  52. * event that this implementation is used on Windows, each type and value
  53. * defined here is given a new name, beginning with "MD". Names of the
  54. * equivalent types and values in the Windows Platform SDK are given in
  55. * comments.
  56. *
  57. * Author: Mark Mentovai */
  58. #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__
  59. #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__
  60. #include <stddef.h>
  61. #include "google_breakpad/common/breakpad_types.h"
  62. #if defined(_MSC_VER)
  63. /* Disable "zero-sized array in struct/union" warnings when compiling in
  64. * MSVC. DbgHelp.h does this too. */
  65. #pragma warning(push)
  66. #pragma warning(disable:4200)
  67. #endif /* _MSC_VER */
  68. /*
  69. * guiddef.h
  70. */
  71. typedef struct {
  72. u_int32_t data1;
  73. u_int16_t data2;
  74. u_int16_t data3;
  75. u_int8_t data4[8];
  76. } MDGUID; /* GUID */
  77. /*
  78. * WinNT.h
  79. */
  80. /* Non-x86 CPU identifiers found in the high 24 bits of
  81. * (MDRawContext*).context_flags. These aren't used by Breakpad, but are
  82. * defined here for reference, to avoid assigning values that conflict
  83. * (although some values already conflict). */
  84. #define MD_CONTEXT_IA64 0x00080000 /* CONTEXT_IA64 */
  85. /* Additional values from winnt.h in the Windows CE 5.0 SDK: */
  86. #define MD_CONTEXT_SHX 0x000000c0 /* CONTEXT_SH4 (Super-H, includes SH3) */
  87. #define MD_CONTEXT_MIPS 0x00010000 /* CONTEXT_R4000 (same value as x86?) */
  88. #define MD_CONTEXT_ALPHA 0x00020000 /* CONTEXT_ALPHA */
  89. /* As of Windows 7 SP1, the number of flag bits has increased to
  90. * include 0x40 (CONTEXT_XSTATE):
  91. * http://msdn.microsoft.com/en-us/library/hh134238%28v=vs.85%29.aspx */
  92. #define MD_CONTEXT_CPU_MASK 0xffffff00
  93. /* This is a base type for MDRawContextX86 and MDRawContextPPC. This
  94. * structure should never be allocated directly. The actual structure type
  95. * can be determined by examining the context_flags field. */
  96. typedef struct {
  97. u_int32_t context_flags;
  98. } MDRawContextBase;
  99. #include "minidump_cpu_amd64.h"
  100. #include "minidump_cpu_arm.h"
  101. #include "minidump_cpu_ppc.h"
  102. #include "minidump_cpu_ppc64.h"
  103. #include "minidump_cpu_sparc.h"
  104. #include "minidump_cpu_x86.h"
  105. /*
  106. * WinVer.h
  107. */
  108. typedef struct {
  109. u_int32_t signature;
  110. u_int32_t struct_version;
  111. u_int32_t file_version_hi;
  112. u_int32_t file_version_lo;
  113. u_int32_t product_version_hi;
  114. u_int32_t product_version_lo;
  115. u_int32_t file_flags_mask; /* Identifies valid bits in fileFlags */
  116. u_int32_t file_flags;
  117. u_int32_t file_os;
  118. u_int32_t file_type;
  119. u_int32_t file_subtype;
  120. u_int32_t file_date_hi;
  121. u_int32_t file_date_lo;
  122. } MDVSFixedFileInfo; /* VS_FIXEDFILEINFO */
  123. /* For (MDVSFixedFileInfo).signature */
  124. #define MD_VSFIXEDFILEINFO_SIGNATURE 0xfeef04bd
  125. /* VS_FFI_SIGNATURE */
  126. /* For (MDVSFixedFileInfo).version */
  127. #define MD_VSFIXEDFILEINFO_VERSION 0x00010000
  128. /* VS_FFI_STRUCVERSION */
  129. /* For (MDVSFixedFileInfo).file_flags_mask and
  130. * (MDVSFixedFileInfo).file_flags */
  131. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_DEBUG 0x00000001
  132. /* VS_FF_DEBUG */
  133. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRERELEASE 0x00000002
  134. /* VS_FF_PRERELEASE */
  135. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_PATCHED 0x00000004
  136. /* VS_FF_PATCHED */
  137. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRIVATEBUILD 0x00000008
  138. /* VS_FF_PRIVATEBUILD */
  139. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_INFOINFERRED 0x00000010
  140. /* VS_FF_INFOINFERRED */
  141. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_SPECIALBUILD 0x00000020
  142. /* VS_FF_SPECIALBUILD */
  143. /* For (MDVSFixedFileInfo).file_os: high 16 bits */
  144. #define MD_VSFIXEDFILEINFO_FILE_OS_UNKNOWN 0 /* VOS_UNKNOWN */
  145. #define MD_VSFIXEDFILEINFO_FILE_OS_DOS (1 << 16) /* VOS_DOS */
  146. #define MD_VSFIXEDFILEINFO_FILE_OS_OS216 (2 << 16) /* VOS_OS216 */
  147. #define MD_VSFIXEDFILEINFO_FILE_OS_OS232 (3 << 16) /* VOS_OS232 */
  148. #define MD_VSFIXEDFILEINFO_FILE_OS_NT (4 << 16) /* VOS_NT */
  149. #define MD_VSFIXEDFILEINFO_FILE_OS_WINCE (5 << 16) /* VOS_WINCE */
  150. /* Low 16 bits */
  151. #define MD_VSFIXEDFILEINFO_FILE_OS__BASE 0 /* VOS__BASE */
  152. #define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS16 1 /* VOS__WINDOWS16 */
  153. #define MD_VSFIXEDFILEINFO_FILE_OS__PM16 2 /* VOS__PM16 */
  154. #define MD_VSFIXEDFILEINFO_FILE_OS__PM32 3 /* VOS__PM32 */
  155. #define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS32 4 /* VOS__WINDOWS32 */
  156. /* For (MDVSFixedFileInfo).file_type */
  157. #define MD_VSFIXEDFILEINFO_FILE_TYPE_UNKNOWN 0 /* VFT_UNKNOWN */
  158. #define MD_VSFIXEDFILEINFO_FILE_TYPE_APP 1 /* VFT_APP */
  159. #define MD_VSFIXEDFILEINFO_FILE_TYPE_DLL 2 /* VFT_DLL */
  160. #define MD_VSFIXEDFILEINFO_FILE_TYPE_DRV 3 /* VFT_DLL */
  161. #define MD_VSFIXEDFILEINFO_FILE_TYPE_FONT 4 /* VFT_FONT */
  162. #define MD_VSFIXEDFILEINFO_FILE_TYPE_VXD 5 /* VFT_VXD */
  163. #define MD_VSFIXEDFILEINFO_FILE_TYPE_STATIC_LIB 7 /* VFT_STATIC_LIB */
  164. /* For (MDVSFixedFileInfo).file_subtype */
  165. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_UNKNOWN 0
  166. /* VFT2_UNKNOWN */
  167. /* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_DRV */
  168. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_PRINTER 1
  169. /* VFT2_DRV_PRINTER */
  170. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_KEYBOARD 2
  171. /* VFT2_DRV_KEYBOARD */
  172. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_LANGUAGE 3
  173. /* VFT2_DRV_LANGUAGE */
  174. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_DISPLAY 4
  175. /* VFT2_DRV_DISPLAY */
  176. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_MOUSE 5
  177. /* VFT2_DRV_MOUSE */
  178. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_NETWORK 6
  179. /* VFT2_DRV_NETWORK */
  180. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SYSTEM 7
  181. /* VFT2_DRV_SYSTEM */
  182. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INSTALLABLE 8
  183. /* VFT2_DRV_INSTALLABLE */
  184. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SOUND 9
  185. /* VFT2_DRV_SOUND */
  186. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_COMM 10
  187. /* VFT2_DRV_COMM */
  188. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INPUTMETHOD 11
  189. /* VFT2_DRV_INPUTMETHOD */
  190. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_VERSIONED_PRINTER 12
  191. /* VFT2_DRV_VERSIONED_PRINTER */
  192. /* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_FONT */
  193. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_RASTER 1
  194. /* VFT2_FONT_RASTER */
  195. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_VECTOR 2
  196. /* VFT2_FONT_VECTOR */
  197. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_TRUETYPE 3
  198. /* VFT2_FONT_TRUETYPE */
  199. /*
  200. * DbgHelp.h
  201. */
  202. /* An MDRVA is an offset into the minidump file. The beginning of the
  203. * MDRawHeader is at offset 0. */
  204. typedef u_int32_t MDRVA; /* RVA */
  205. typedef struct {
  206. u_int32_t data_size;
  207. MDRVA rva;
  208. } MDLocationDescriptor; /* MINIDUMP_LOCATION_DESCRIPTOR */
  209. typedef struct {
  210. /* The base address of the memory range on the host that produced the
  211. * minidump. */
  212. u_int64_t start_of_memory_range;
  213. MDLocationDescriptor memory;
  214. } MDMemoryDescriptor; /* MINIDUMP_MEMORY_DESCRIPTOR */
  215. typedef struct {
  216. u_int32_t signature;
  217. u_int32_t version;
  218. u_int32_t stream_count;
  219. MDRVA stream_directory_rva; /* A |stream_count|-sized array of
  220. * MDRawDirectory structures. */
  221. u_int32_t checksum; /* Can be 0. In fact, that's all that's
  222. * been found in minidump files. */
  223. u_int32_t time_date_stamp; /* time_t */
  224. u_int64_t flags;
  225. } MDRawHeader; /* MINIDUMP_HEADER */
  226. /* For (MDRawHeader).signature and (MDRawHeader).version. Note that only the
  227. * low 16 bits of (MDRawHeader).version are MD_HEADER_VERSION. Per the
  228. * documentation, the high 16 bits are implementation-specific. */
  229. #define MD_HEADER_SIGNATURE 0x504d444d /* 'PMDM' */
  230. /* MINIDUMP_SIGNATURE */
  231. #define MD_HEADER_VERSION 0x0000a793 /* 42899 */
  232. /* MINIDUMP_VERSION */
  233. /* For (MDRawHeader).flags: */
  234. typedef enum {
  235. /* MD_NORMAL is the standard type of minidump. It includes full
  236. * streams for the thread list, module list, exception, system info,
  237. * and miscellaneous info. A memory list stream is also present,
  238. * pointing to the same stack memory contained in the thread list,
  239. * as well as a 256-byte region around the instruction address that
  240. * was executing when the exception occurred. Stack memory is from
  241. * 4 bytes below a thread's stack pointer up to the top of the
  242. * memory region encompassing the stack. */
  243. MD_NORMAL = 0x00000000,
  244. MD_WITH_DATA_SEGS = 0x00000001,
  245. MD_WITH_FULL_MEMORY = 0x00000002,
  246. MD_WITH_HANDLE_DATA = 0x00000004,
  247. MD_FILTER_MEMORY = 0x00000008,
  248. MD_SCAN_MEMORY = 0x00000010,
  249. MD_WITH_UNLOADED_MODULES = 0x00000020,
  250. MD_WITH_INDIRECTLY_REFERENCED_MEMORY = 0x00000040,
  251. MD_FILTER_MODULE_PATHS = 0x00000080,
  252. MD_WITH_PROCESS_THREAD_DATA = 0x00000100,
  253. MD_WITH_PRIVATE_READ_WRITE_MEMORY = 0x00000200,
  254. MD_WITHOUT_OPTIONAL_DATA = 0x00000400,
  255. MD_WITH_FULL_MEMORY_INFO = 0x00000800,
  256. MD_WITH_THREAD_INFO = 0x00001000,
  257. MD_WITH_CODE_SEGS = 0x00002000,
  258. MD_WITHOUT_AUXILLIARY_SEGS = 0x00004000,
  259. MD_WITH_FULL_AUXILLIARY_STATE = 0x00008000,
  260. MD_WITH_PRIVATE_WRITE_COPY_MEMORY = 0x00010000,
  261. MD_IGNORE_INACCESSIBLE_MEMORY = 0x00020000,
  262. MD_WITH_TOKEN_INFORMATION = 0x00040000
  263. } MDType; /* MINIDUMP_TYPE */
  264. typedef struct {
  265. u_int32_t stream_type;
  266. MDLocationDescriptor location;
  267. } MDRawDirectory; /* MINIDUMP_DIRECTORY */
  268. /* For (MDRawDirectory).stream_type */
  269. typedef enum {
  270. MD_UNUSED_STREAM = 0,
  271. MD_RESERVED_STREAM_0 = 1,
  272. MD_RESERVED_STREAM_1 = 2,
  273. MD_THREAD_LIST_STREAM = 3, /* MDRawThreadList */
  274. MD_MODULE_LIST_STREAM = 4, /* MDRawModuleList */
  275. MD_MEMORY_LIST_STREAM = 5, /* MDRawMemoryList */
  276. MD_EXCEPTION_STREAM = 6, /* MDRawExceptionStream */
  277. MD_SYSTEM_INFO_STREAM = 7, /* MDRawSystemInfo */
  278. MD_THREAD_EX_LIST_STREAM = 8,
  279. MD_MEMORY_64_LIST_STREAM = 9,
  280. MD_COMMENT_STREAM_A = 10,
  281. MD_COMMENT_STREAM_W = 11,
  282. MD_HANDLE_DATA_STREAM = 12,
  283. MD_FUNCTION_TABLE_STREAM = 13,
  284. MD_UNLOADED_MODULE_LIST_STREAM = 14,
  285. MD_MISC_INFO_STREAM = 15, /* MDRawMiscInfo */
  286. MD_MEMORY_INFO_LIST_STREAM = 16, /* MDRawMemoryInfoList */
  287. MD_THREAD_INFO_LIST_STREAM = 17,
  288. MD_HANDLE_OPERATION_LIST_STREAM = 18,
  289. MD_LAST_RESERVED_STREAM = 0x0000ffff,
  290. /* Breakpad extension types. 0x4767 = "Gg" */
  291. MD_BREAKPAD_INFO_STREAM = 0x47670001, /* MDRawBreakpadInfo */
  292. MD_ASSERTION_INFO_STREAM = 0x47670002 /* MDRawAssertionInfo */
  293. } MDStreamType; /* MINIDUMP_STREAM_TYPE */
  294. typedef struct {
  295. u_int32_t length; /* Length of buffer in bytes (not characters),
  296. * excluding 0-terminator */
  297. u_int16_t buffer[1]; /* UTF-16-encoded, 0-terminated */
  298. } MDString; /* MINIDUMP_STRING */
  299. static const size_t MDString_minsize = offsetof(MDString, buffer[0]);
  300. typedef struct {
  301. u_int32_t thread_id;
  302. u_int32_t suspend_count;
  303. u_int32_t priority_class;
  304. u_int32_t priority;
  305. u_int64_t teb; /* Thread environment block */
  306. MDMemoryDescriptor stack;
  307. MDLocationDescriptor thread_context; /* MDRawContext[CPU] */
  308. } MDRawThread; /* MINIDUMP_THREAD */
  309. typedef struct {
  310. u_int32_t number_of_threads;
  311. MDRawThread threads[1];
  312. } MDRawThreadList; /* MINIDUMP_THREAD_LIST */
  313. static const size_t MDRawThreadList_minsize = offsetof(MDRawThreadList,
  314. threads[0]);
  315. typedef struct {
  316. u_int64_t base_of_image;
  317. u_int32_t size_of_image;
  318. u_int32_t checksum; /* 0 if unknown */
  319. u_int32_t time_date_stamp; /* time_t */
  320. MDRVA module_name_rva; /* MDString, pathname or filename */
  321. MDVSFixedFileInfo version_info;
  322. /* The next field stores a CodeView record and is populated when a module's
  323. * debug information resides in a PDB file. It identifies the PDB file. */
  324. MDLocationDescriptor cv_record;
  325. /* The next field is populated when a module's debug information resides
  326. * in a DBG file. It identifies the DBG file. This field is effectively
  327. * obsolete with modules built by recent toolchains. */
  328. MDLocationDescriptor misc_record;
  329. /* Alignment problem: reserved0 and reserved1 are defined by the platform
  330. * SDK as 64-bit quantities. However, that results in a structure whose
  331. * alignment is unpredictable on different CPUs and ABIs. If the ABI
  332. * specifies full alignment of 64-bit quantities in structures (as ppc
  333. * does), there will be padding between miscRecord and reserved0. If
  334. * 64-bit quantities can be aligned on 32-bit boundaries (as on x86),
  335. * this padding will not exist. (Note that the structure up to this point
  336. * contains 1 64-bit member followed by 21 32-bit members.)
  337. * As a workaround, reserved0 and reserved1 are instead defined here as
  338. * four 32-bit quantities. This should be harmless, as there are
  339. * currently no known uses for these fields. */
  340. u_int32_t reserved0[2];
  341. u_int32_t reserved1[2];
  342. } MDRawModule; /* MINIDUMP_MODULE */
  343. /* The inclusion of a 64-bit type in MINIDUMP_MODULE forces the struct to
  344. * be tail-padded out to a multiple of 64 bits under some ABIs (such as PPC).
  345. * This doesn't occur on systems that don't tail-pad in this manner. Define
  346. * this macro to be the usable size of the MDRawModule struct, and use it in
  347. * place of sizeof(MDRawModule). */
  348. #define MD_MODULE_SIZE 108
  349. /* (MDRawModule).cv_record can reference MDCVInfoPDB20 or MDCVInfoPDB70.
  350. * Ref.: http://www.debuginfo.com/articles/debuginfomatch.html
  351. * MDCVInfoPDB70 is the expected structure type with recent toolchains. */
  352. typedef struct {
  353. u_int32_t signature;
  354. u_int32_t offset; /* Offset to debug data (expect 0 in minidump) */
  355. } MDCVHeader;
  356. typedef struct {
  357. MDCVHeader cv_header;
  358. u_int32_t signature; /* time_t debug information created */
  359. u_int32_t age; /* revision of PDB file */
  360. u_int8_t pdb_file_name[1]; /* Pathname or filename of PDB file */
  361. } MDCVInfoPDB20;
  362. static const size_t MDCVInfoPDB20_minsize = offsetof(MDCVInfoPDB20,
  363. pdb_file_name[0]);
  364. #define MD_CVINFOPDB20_SIGNATURE 0x3031424e /* cvHeader.signature = '01BN' */
  365. typedef struct {
  366. u_int32_t cv_signature;
  367. MDGUID signature; /* GUID, identifies PDB file */
  368. u_int32_t age; /* Identifies incremental changes to PDB file */
  369. u_int8_t pdb_file_name[1]; /* Pathname or filename of PDB file,
  370. * 0-terminated 8-bit character data (UTF-8?) */
  371. } MDCVInfoPDB70;
  372. static const size_t MDCVInfoPDB70_minsize = offsetof(MDCVInfoPDB70,
  373. pdb_file_name[0]);
  374. #define MD_CVINFOPDB70_SIGNATURE 0x53445352 /* cvSignature = 'SDSR' */
  375. typedef struct {
  376. u_int32_t data1[2];
  377. u_int32_t data2;
  378. u_int32_t data3;
  379. u_int32_t data4;
  380. u_int32_t data5[3];
  381. u_int8_t extra[2];
  382. } MDCVInfoELF;
  383. /* In addition to the two CodeView record formats above, used for linking
  384. * to external pdb files, it is possible for debugging data to be carried
  385. * directly in the CodeView record itself. These signature values will
  386. * be found in the first 4 bytes of the CodeView record. Additional values
  387. * not commonly experienced in the wild are given by "Microsoft Symbol and
  388. * Type Information", http://www.x86.org/ftp/manuals/tools/sym.pdf, section
  389. * 7.2. An in-depth description of the CodeView 4.1 format is given by
  390. * "Undocumented Windows 2000 Secrets", Windows 2000 Debugging Support/
  391. * Microsoft Symbol File Internals/CodeView Subsections,
  392. * http://www.rawol.com/features/undocumented/sbs-w2k-1-windows-2000-debugging-support.pdf
  393. */
  394. #define MD_CVINFOCV41_SIGNATURE 0x3930424e /* '90BN', CodeView 4.10. */
  395. #define MD_CVINFOCV50_SIGNATURE 0x3131424e /* '11BN', CodeView 5.0,
  396. * MS C7-format (/Z7). */
  397. #define MD_CVINFOUNKNOWN_SIGNATURE 0xffffffff /* An unlikely value. */
  398. /* (MDRawModule).miscRecord can reference MDImageDebugMisc. The Windows
  399. * structure is actually defined in WinNT.h. This structure is effectively
  400. * obsolete with modules built by recent toolchains. */
  401. typedef struct {
  402. u_int32_t data_type; /* IMAGE_DEBUG_TYPE_*, not defined here because
  403. * this debug record type is mostly obsolete. */
  404. u_int32_t length; /* Length of entire MDImageDebugMisc structure */
  405. u_int8_t unicode; /* True if data is multibyte */
  406. u_int8_t reserved[3];
  407. u_int8_t data[1];
  408. } MDImageDebugMisc; /* IMAGE_DEBUG_MISC */
  409. static const size_t MDImageDebugMisc_minsize = offsetof(MDImageDebugMisc,
  410. data[0]);
  411. typedef struct {
  412. u_int32_t number_of_modules;
  413. MDRawModule modules[1];
  414. } MDRawModuleList; /* MINIDUMP_MODULE_LIST */
  415. static const size_t MDRawModuleList_minsize = offsetof(MDRawModuleList,
  416. modules[0]);
  417. typedef struct {
  418. u_int32_t number_of_memory_ranges;
  419. MDMemoryDescriptor memory_ranges[1];
  420. } MDRawMemoryList; /* MINIDUMP_MEMORY_LIST */
  421. static const size_t MDRawMemoryList_minsize = offsetof(MDRawMemoryList,
  422. memory_ranges[0]);
  423. #define MD_EXCEPTION_MAXIMUM_PARAMETERS 15
  424. typedef struct {
  425. u_int32_t exception_code; /* Windows: MDExceptionCodeWin,
  426. * Mac OS X: MDExceptionMac,
  427. * Linux: MDExceptionCodeLinux. */
  428. u_int32_t exception_flags; /* Windows: 1 if noncontinuable,
  429. Mac OS X: MDExceptionCodeMac. */
  430. u_int64_t exception_record; /* Address (in the minidump-producing host's
  431. * memory) of another MDException, for
  432. * nested exceptions. */
  433. u_int64_t exception_address; /* The address that caused the exception.
  434. * Mac OS X: exception subcode (which is
  435. * typically the address). */
  436. u_int32_t number_parameters; /* Number of valid elements in
  437. * exception_information. */
  438. u_int32_t __align;
  439. u_int64_t exception_information[MD_EXCEPTION_MAXIMUM_PARAMETERS];
  440. } MDException; /* MINIDUMP_EXCEPTION */
  441. #include "minidump_exception_win32.h"
  442. #include "minidump_exception_mac.h"
  443. #include "minidump_exception_linux.h"
  444. #include "minidump_exception_solaris.h"
  445. typedef struct {
  446. u_int32_t thread_id; /* Thread in which the exception
  447. * occurred. Corresponds to
  448. * (MDRawThread).thread_id. */
  449. u_int32_t __align;
  450. MDException exception_record;
  451. MDLocationDescriptor thread_context; /* MDRawContext[CPU] */
  452. } MDRawExceptionStream; /* MINIDUMP_EXCEPTION_STREAM */
  453. typedef union {
  454. struct {
  455. u_int32_t vendor_id[3]; /* cpuid 0: ebx, edx, ecx */
  456. u_int32_t version_information; /* cpuid 1: eax */
  457. u_int32_t feature_information; /* cpuid 1: edx */
  458. u_int32_t amd_extended_cpu_features; /* cpuid 0x80000001, ebx */
  459. } x86_cpu_info;
  460. struct {
  461. u_int64_t processor_features[2];
  462. } other_cpu_info;
  463. } MDCPUInformation; /* CPU_INFORMATION */
  464. typedef struct {
  465. /* The next 3 fields and numberOfProcessors are from the SYSTEM_INFO
  466. * structure as returned by GetSystemInfo */
  467. u_int16_t processor_architecture;
  468. u_int16_t processor_level; /* x86: 5 = 586, 6 = 686, ... */
  469. u_int16_t processor_revision; /* x86: 0xMMSS, where MM=model,
  470. * SS=stepping */
  471. u_int8_t number_of_processors;
  472. u_int8_t product_type; /* Windows: VER_NT_* from WinNT.h */
  473. /* The next 5 fields are from the OSVERSIONINFO structure as returned
  474. * by GetVersionEx */
  475. u_int32_t major_version;
  476. u_int32_t minor_version;
  477. u_int32_t build_number;
  478. u_int32_t platform_id;
  479. MDRVA csd_version_rva; /* MDString further identifying the
  480. * host OS.
  481. * Windows: name of the installed OS
  482. * service pack.
  483. * Mac OS X: the Apple OS build number
  484. * (sw_vers -buildVersion).
  485. * Linux: uname -srvmo */
  486. u_int16_t suite_mask; /* Windows: VER_SUITE_* from WinNT.h */
  487. u_int16_t reserved2;
  488. MDCPUInformation cpu;
  489. } MDRawSystemInfo; /* MINIDUMP_SYSTEM_INFO */
  490. /* For (MDRawSystemInfo).processor_architecture: */
  491. typedef enum {
  492. MD_CPU_ARCHITECTURE_X86 = 0, /* PROCESSOR_ARCHITECTURE_INTEL */
  493. MD_CPU_ARCHITECTURE_MIPS = 1, /* PROCESSOR_ARCHITECTURE_MIPS */
  494. MD_CPU_ARCHITECTURE_ALPHA = 2, /* PROCESSOR_ARCHITECTURE_ALPHA */
  495. MD_CPU_ARCHITECTURE_PPC = 3, /* PROCESSOR_ARCHITECTURE_PPC */
  496. MD_CPU_ARCHITECTURE_SHX = 4, /* PROCESSOR_ARCHITECTURE_SHX
  497. * (Super-H) */
  498. MD_CPU_ARCHITECTURE_ARM = 5, /* PROCESSOR_ARCHITECTURE_ARM */
  499. MD_CPU_ARCHITECTURE_IA64 = 6, /* PROCESSOR_ARCHITECTURE_IA64 */
  500. MD_CPU_ARCHITECTURE_ALPHA64 = 7, /* PROCESSOR_ARCHITECTURE_ALPHA64 */
  501. MD_CPU_ARCHITECTURE_MSIL = 8, /* PROCESSOR_ARCHITECTURE_MSIL
  502. * (Microsoft Intermediate Language) */
  503. MD_CPU_ARCHITECTURE_AMD64 = 9, /* PROCESSOR_ARCHITECTURE_AMD64 */
  504. MD_CPU_ARCHITECTURE_X86_WIN64 = 10,
  505. /* PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 (WoW64) */
  506. MD_CPU_ARCHITECTURE_SPARC = 0x8001, /* Breakpad-defined value for SPARC */
  507. MD_CPU_ARCHITECTURE_UNKNOWN = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */
  508. } MDCPUArchitecture;
  509. /* For (MDRawSystemInfo).platform_id: */
  510. typedef enum {
  511. MD_OS_WIN32S = 0, /* VER_PLATFORM_WIN32s (Windows 3.1) */
  512. MD_OS_WIN32_WINDOWS = 1, /* VER_PLATFORM_WIN32_WINDOWS (Windows 95-98-Me) */
  513. MD_OS_WIN32_NT = 2, /* VER_PLATFORM_WIN32_NT (Windows NT, 2000+) */
  514. MD_OS_WIN32_CE = 3, /* VER_PLATFORM_WIN32_CE, VER_PLATFORM_WIN32_HH
  515. * (Windows CE, Windows Mobile, "Handheld") */
  516. /* The following values are Breakpad-defined. */
  517. MD_OS_UNIX = 0x8000, /* Generic Unix-ish */
  518. MD_OS_MAC_OS_X = 0x8101, /* Mac OS X/Darwin */
  519. MD_OS_IOS = 0x8102, /* iOS */
  520. MD_OS_LINUX = 0x8201, /* Linux */
  521. MD_OS_SOLARIS = 0x8202 /* Solaris */
  522. } MDOSPlatform;
  523. typedef struct {
  524. u_int32_t size_of_info; /* Length of entire MDRawMiscInfo structure. */
  525. u_int32_t flags1;
  526. /* The next field is only valid if flags1 contains
  527. * MD_MISCINFO_FLAGS1_PROCESS_ID. */
  528. u_int32_t process_id;
  529. /* The next 3 fields are only valid if flags1 contains
  530. * MD_MISCINFO_FLAGS1_PROCESS_TIMES. */
  531. u_int32_t process_create_time; /* time_t process started */
  532. u_int32_t process_user_time; /* seconds of user CPU time */
  533. u_int32_t process_kernel_time; /* seconds of kernel CPU time */
  534. /* The following fields are not present in MINIDUMP_MISC_INFO but are
  535. * in MINIDUMP_MISC_INFO_2. When this struct is populated, these values
  536. * may not be set. Use flags1 or sizeOfInfo to determine whether these
  537. * values are present. These are only valid when flags1 contains
  538. * MD_MISCINFO_FLAGS1_PROCESSOR_POWER_INFO. */
  539. u_int32_t processor_max_mhz;
  540. u_int32_t processor_current_mhz;
  541. u_int32_t processor_mhz_limit;
  542. u_int32_t processor_max_idle_state;
  543. u_int32_t processor_current_idle_state;
  544. } MDRawMiscInfo; /* MINIDUMP_MISC_INFO, MINIDUMP_MISC_INFO2 */
  545. #define MD_MISCINFO_SIZE 24
  546. #define MD_MISCINFO2_SIZE 44
  547. /* For (MDRawMiscInfo).flags1. These values indicate which fields in the
  548. * MDRawMiscInfoStructure are valid. */
  549. typedef enum {
  550. MD_MISCINFO_FLAGS1_PROCESS_ID = 0x00000001,
  551. /* MINIDUMP_MISC1_PROCESS_ID */
  552. MD_MISCINFO_FLAGS1_PROCESS_TIMES = 0x00000002,
  553. /* MINIDUMP_MISC1_PROCESS_TIMES */
  554. MD_MISCINFO_FLAGS1_PROCESSOR_POWER_INFO = 0x00000004
  555. /* MINIDUMP_MISC1_PROCESSOR_POWER_INFO */
  556. } MDMiscInfoFlags1;
  557. /*
  558. * Around DbgHelp version 6.0, the style of new LIST structures changed
  559. * from including an array of length 1 at the end of the struct to
  560. * represent the variable-length data to including explicit
  561. * "size of header", "size of entry" and "number of entries" fields
  562. * in the header, presumably to allow backwards-compatibly-extending
  563. * the structures in the future. The actual list entries follow the
  564. * header data directly in this case.
  565. */
  566. typedef struct {
  567. u_int32_t size_of_header; /* sizeof(MDRawMemoryInfoList) */
  568. u_int32_t size_of_entry; /* sizeof(MDRawMemoryInfo) */
  569. u_int64_t number_of_entries;
  570. } MDRawMemoryInfoList; /* MINIDUMP_MEMORY_INFO_LIST */
  571. typedef struct {
  572. u_int64_t base_address; /* Base address of a region of pages */
  573. u_int64_t allocation_base; /* Base address of a range of pages
  574. * within this region. */
  575. u_int32_t allocation_protection; /* Memory protection when this region
  576. * was originally allocated:
  577. * MDMemoryProtection */
  578. u_int32_t __alignment1;
  579. u_int64_t region_size;
  580. u_int32_t state; /* MDMemoryState */
  581. u_int32_t protection; /* MDMemoryProtection */
  582. u_int32_t type; /* MDMemoryType */
  583. u_int32_t __alignment2;
  584. } MDRawMemoryInfo; /* MINIDUMP_MEMORY_INFO */
  585. /* For (MDRawMemoryInfo).state */
  586. typedef enum {
  587. MD_MEMORY_STATE_COMMIT = 0x1000, /* physical storage has been allocated */
  588. MD_MEMORY_STATE_RESERVE = 0x2000, /* reserved, but no physical storage */
  589. MD_MEMORY_STATE_FREE = 0x10000 /* available to be allocated */
  590. } MDMemoryState;
  591. /* For (MDRawMemoryInfo).allocation_protection and .protection */
  592. typedef enum {
  593. MD_MEMORY_PROTECT_NOACCESS = 0x01, /* PAGE_NOACCESS */
  594. MD_MEMORY_PROTECT_READONLY = 0x02, /* PAGE_READONLY */
  595. MD_MEMORY_PROTECT_READWRITE = 0x04, /* PAGE_READWRITE */
  596. MD_MEMORY_PROTECT_WRITECOPY = 0x08, /* PAGE_WRITECOPY */
  597. MD_MEMORY_PROTECT_EXECUTE = 0x10, /* PAGE_EXECUTE */
  598. MD_MEMORY_PROTECT_EXECUTE_READ = 0x20, /* PAGE_EXECUTE_READ */
  599. MD_MEMORY_PROTECT_EXECUTE_READWRITE = 0x40, /* PAGE_EXECUTE_READWRITE */
  600. MD_MEMORY_PROTECT_EXECUTE_WRITECOPY = 0x80, /* PAGE_EXECUTE_WRITECOPY */
  601. /* These options can be combined with the previous flags. */
  602. MD_MEMORY_PROTECT_GUARD = 0x100, /* PAGE_GUARD */
  603. MD_MEMORY_PROTECT_NOCACHE = 0x200, /* PAGE_NOCACHE */
  604. MD_MEMORY_PROTECT_WRITECOMBINE = 0x400, /* PAGE_WRITECOMBINE */
  605. } MDMemoryProtection;
  606. /* Used to mask the mutually exclusive options from the combinable flags. */
  607. const u_int32_t MD_MEMORY_PROTECTION_ACCESS_MASK = 0xFF;
  608. /* For (MDRawMemoryInfo).type */
  609. typedef enum {
  610. MD_MEMORY_TYPE_PRIVATE = 0x20000, /* not shared by other processes */
  611. MD_MEMORY_TYPE_MAPPED = 0x40000, /* mapped into the view of a section */
  612. MD_MEMORY_TYPE_IMAGE = 0x1000000 /* mapped into the view of an image */
  613. } MDMemoryType;
  614. /*
  615. * Breakpad extension types
  616. */
  617. typedef struct {
  618. /* validity is a bitmask with values from MDBreakpadInfoValidity, indicating
  619. * which of the other fields in the structure are valid. */
  620. u_int32_t validity;
  621. /* Thread ID of the handler thread. dump_thread_id should correspond to
  622. * the thread_id of an MDRawThread in the minidump's MDRawThreadList if
  623. * a dedicated thread in that list was used to produce the minidump. If
  624. * the MDRawThreadList does not contain a dedicated thread used to produce
  625. * the minidump, this field should be set to 0 and the validity field
  626. * must not contain MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID. */
  627. u_int32_t dump_thread_id;
  628. /* Thread ID of the thread that requested the minidump be produced. As
  629. * with dump_thread_id, requesting_thread_id should correspond to the
  630. * thread_id of an MDRawThread in the minidump's MDRawThreadList. For
  631. * minidumps produced as a result of an exception, requesting_thread_id
  632. * will be the same as the MDRawExceptionStream's thread_id field. For
  633. * minidumps produced "manually" at the program's request,
  634. * requesting_thread_id will indicate which thread caused the dump to be
  635. * written. If the minidump was produced at the request of something
  636. * other than a thread in the MDRawThreadList, this field should be set
  637. * to 0 and the validity field must not contain
  638. * MD_BREAKPAD_INFO_VALID_REQUESTING_THREAD_ID. */
  639. u_int32_t requesting_thread_id;
  640. } MDRawBreakpadInfo;
  641. /* For (MDRawBreakpadInfo).validity: */
  642. typedef enum {
  643. /* When set, the dump_thread_id field is valid. */
  644. MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID = 1 << 0,
  645. /* When set, the requesting_thread_id field is valid. */
  646. MD_BREAKPAD_INFO_VALID_REQUESTING_THREAD_ID = 1 << 1
  647. } MDBreakpadInfoValidity;
  648. typedef struct {
  649. /* expression, function, and file are 0-terminated UTF-16 strings. They
  650. * may be truncated if necessary, but should always be 0-terminated when
  651. * written to a file.
  652. * Fixed-length strings are used because MiniDumpWriteDump doesn't offer
  653. * a way for user streams to point to arbitrary RVAs for strings. */
  654. u_int16_t expression[128]; /* Assertion that failed... */
  655. u_int16_t function[128]; /* ...within this function... */
  656. u_int16_t file[128]; /* ...in this file... */
  657. u_int32_t line; /* ...at this line. */
  658. u_int32_t type;
  659. } MDRawAssertionInfo;
  660. /* For (MDRawAssertionInfo).type: */
  661. typedef enum {
  662. MD_ASSERTION_INFO_TYPE_UNKNOWN = 0,
  663. /* Used for assertions that would be raised by the MSVC CRT but are
  664. * directed to an invalid parameter handler instead. */
  665. MD_ASSERTION_INFO_TYPE_INVALID_PARAMETER,
  666. /* Used for assertions that would be raised by the MSVC CRT but are
  667. * directed to a pure virtual call handler instead. */
  668. MD_ASSERTION_INFO_TYPE_PURE_VIRTUAL_CALL
  669. } MDAssertionInfoData;
  670. #if defined(_MSC_VER)
  671. #pragma warning(pop)
  672. #endif /* _MSC_VER */
  673. #endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__ */