minidump_format.h 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  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. uint32_t data1;
  73. uint16_t data2;
  74. uint16_t data3;
  75. uint8_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_ALPHA 0x00020000 /* CONTEXT_ALPHA */
  88. /* As of Windows 7 SP1, the number of flag bits has increased to
  89. * include 0x40 (CONTEXT_XSTATE):
  90. * http://msdn.microsoft.com/en-us/library/hh134238%28v=vs.85%29.aspx */
  91. #define MD_CONTEXT_CPU_MASK 0xffffff00
  92. /* This is a base type for MDRawContextX86 and MDRawContextPPC. This
  93. * structure should never be allocated directly. The actual structure type
  94. * can be determined by examining the context_flags field. */
  95. typedef struct {
  96. uint32_t context_flags;
  97. } MDRawContextBase;
  98. #include "minidump_cpu_amd64.h"
  99. #include "minidump_cpu_arm.h"
  100. #include "minidump_cpu_arm64.h"
  101. #include "minidump_cpu_mips.h"
  102. #include "minidump_cpu_ppc.h"
  103. #include "minidump_cpu_ppc64.h"
  104. #include "minidump_cpu_sparc.h"
  105. #include "minidump_cpu_x86.h"
  106. /*
  107. * WinVer.h
  108. */
  109. typedef struct {
  110. uint32_t signature;
  111. uint32_t struct_version;
  112. uint32_t file_version_hi;
  113. uint32_t file_version_lo;
  114. uint32_t product_version_hi;
  115. uint32_t product_version_lo;
  116. uint32_t file_flags_mask; /* Identifies valid bits in fileFlags */
  117. uint32_t file_flags;
  118. uint32_t file_os;
  119. uint32_t file_type;
  120. uint32_t file_subtype;
  121. uint32_t file_date_hi;
  122. uint32_t file_date_lo;
  123. } MDVSFixedFileInfo; /* VS_FIXEDFILEINFO */
  124. /* For (MDVSFixedFileInfo).signature */
  125. #define MD_VSFIXEDFILEINFO_SIGNATURE 0xfeef04bd
  126. /* VS_FFI_SIGNATURE */
  127. /* For (MDVSFixedFileInfo).version */
  128. #define MD_VSFIXEDFILEINFO_VERSION 0x00010000
  129. /* VS_FFI_STRUCVERSION */
  130. /* For (MDVSFixedFileInfo).file_flags_mask and
  131. * (MDVSFixedFileInfo).file_flags */
  132. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_DEBUG 0x00000001
  133. /* VS_FF_DEBUG */
  134. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRERELEASE 0x00000002
  135. /* VS_FF_PRERELEASE */
  136. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_PATCHED 0x00000004
  137. /* VS_FF_PATCHED */
  138. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRIVATEBUILD 0x00000008
  139. /* VS_FF_PRIVATEBUILD */
  140. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_INFOINFERRED 0x00000010
  141. /* VS_FF_INFOINFERRED */
  142. #define MD_VSFIXEDFILEINFO_FILE_FLAGS_SPECIALBUILD 0x00000020
  143. /* VS_FF_SPECIALBUILD */
  144. /* For (MDVSFixedFileInfo).file_os: high 16 bits */
  145. #define MD_VSFIXEDFILEINFO_FILE_OS_UNKNOWN 0 /* VOS_UNKNOWN */
  146. #define MD_VSFIXEDFILEINFO_FILE_OS_DOS (1 << 16) /* VOS_DOS */
  147. #define MD_VSFIXEDFILEINFO_FILE_OS_OS216 (2 << 16) /* VOS_OS216 */
  148. #define MD_VSFIXEDFILEINFO_FILE_OS_OS232 (3 << 16) /* VOS_OS232 */
  149. #define MD_VSFIXEDFILEINFO_FILE_OS_NT (4 << 16) /* VOS_NT */
  150. #define MD_VSFIXEDFILEINFO_FILE_OS_WINCE (5 << 16) /* VOS_WINCE */
  151. /* Low 16 bits */
  152. #define MD_VSFIXEDFILEINFO_FILE_OS__BASE 0 /* VOS__BASE */
  153. #define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS16 1 /* VOS__WINDOWS16 */
  154. #define MD_VSFIXEDFILEINFO_FILE_OS__PM16 2 /* VOS__PM16 */
  155. #define MD_VSFIXEDFILEINFO_FILE_OS__PM32 3 /* VOS__PM32 */
  156. #define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS32 4 /* VOS__WINDOWS32 */
  157. /* For (MDVSFixedFileInfo).file_type */
  158. #define MD_VSFIXEDFILEINFO_FILE_TYPE_UNKNOWN 0 /* VFT_UNKNOWN */
  159. #define MD_VSFIXEDFILEINFO_FILE_TYPE_APP 1 /* VFT_APP */
  160. #define MD_VSFIXEDFILEINFO_FILE_TYPE_DLL 2 /* VFT_DLL */
  161. #define MD_VSFIXEDFILEINFO_FILE_TYPE_DRV 3 /* VFT_DLL */
  162. #define MD_VSFIXEDFILEINFO_FILE_TYPE_FONT 4 /* VFT_FONT */
  163. #define MD_VSFIXEDFILEINFO_FILE_TYPE_VXD 5 /* VFT_VXD */
  164. #define MD_VSFIXEDFILEINFO_FILE_TYPE_STATIC_LIB 7 /* VFT_STATIC_LIB */
  165. /* For (MDVSFixedFileInfo).file_subtype */
  166. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_UNKNOWN 0
  167. /* VFT2_UNKNOWN */
  168. /* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_DRV */
  169. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_PRINTER 1
  170. /* VFT2_DRV_PRINTER */
  171. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_KEYBOARD 2
  172. /* VFT2_DRV_KEYBOARD */
  173. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_LANGUAGE 3
  174. /* VFT2_DRV_LANGUAGE */
  175. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_DISPLAY 4
  176. /* VFT2_DRV_DISPLAY */
  177. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_MOUSE 5
  178. /* VFT2_DRV_MOUSE */
  179. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_NETWORK 6
  180. /* VFT2_DRV_NETWORK */
  181. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SYSTEM 7
  182. /* VFT2_DRV_SYSTEM */
  183. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INSTALLABLE 8
  184. /* VFT2_DRV_INSTALLABLE */
  185. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SOUND 9
  186. /* VFT2_DRV_SOUND */
  187. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_COMM 10
  188. /* VFT2_DRV_COMM */
  189. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INPUTMETHOD 11
  190. /* VFT2_DRV_INPUTMETHOD */
  191. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_VERSIONED_PRINTER 12
  192. /* VFT2_DRV_VERSIONED_PRINTER */
  193. /* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_FONT */
  194. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_RASTER 1
  195. /* VFT2_FONT_RASTER */
  196. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_VECTOR 2
  197. /* VFT2_FONT_VECTOR */
  198. #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_TRUETYPE 3
  199. /* VFT2_FONT_TRUETYPE */
  200. /*
  201. * DbgHelp.h
  202. */
  203. /* An MDRVA is an offset into the minidump file. The beginning of the
  204. * MDRawHeader is at offset 0. */
  205. typedef uint32_t MDRVA; /* RVA */
  206. typedef struct {
  207. uint32_t data_size;
  208. MDRVA rva;
  209. } MDLocationDescriptor; /* MINIDUMP_LOCATION_DESCRIPTOR */
  210. typedef struct {
  211. /* The base address of the memory range on the host that produced the
  212. * minidump. */
  213. uint64_t start_of_memory_range;
  214. MDLocationDescriptor memory;
  215. } MDMemoryDescriptor; /* MINIDUMP_MEMORY_DESCRIPTOR */
  216. typedef struct {
  217. uint32_t signature;
  218. uint32_t version;
  219. uint32_t stream_count;
  220. MDRVA stream_directory_rva; /* A |stream_count|-sized array of
  221. * MDRawDirectory structures. */
  222. uint32_t checksum; /* Can be 0. In fact, that's all that's
  223. * been found in minidump files. */
  224. uint32_t time_date_stamp; /* time_t */
  225. uint64_t flags;
  226. } MDRawHeader; /* MINIDUMP_HEADER */
  227. /* For (MDRawHeader).signature and (MDRawHeader).version. Note that only the
  228. * low 16 bits of (MDRawHeader).version are MD_HEADER_VERSION. Per the
  229. * documentation, the high 16 bits are implementation-specific. */
  230. #define MD_HEADER_SIGNATURE 0x504d444d /* 'PMDM' */
  231. /* MINIDUMP_SIGNATURE */
  232. #define MD_HEADER_VERSION 0x0000a793 /* 42899 */
  233. /* MINIDUMP_VERSION */
  234. /* For (MDRawHeader).flags: */
  235. typedef enum {
  236. /* MD_NORMAL is the standard type of minidump. It includes full
  237. * streams for the thread list, module list, exception, system info,
  238. * and miscellaneous info. A memory list stream is also present,
  239. * pointing to the same stack memory contained in the thread list,
  240. * as well as a 256-byte region around the instruction address that
  241. * was executing when the exception occurred. Stack memory is from
  242. * 4 bytes below a thread's stack pointer up to the top of the
  243. * memory region encompassing the stack. */
  244. MD_NORMAL = 0x00000000,
  245. MD_WITH_DATA_SEGS = 0x00000001,
  246. MD_WITH_FULL_MEMORY = 0x00000002,
  247. MD_WITH_HANDLE_DATA = 0x00000004,
  248. MD_FILTER_MEMORY = 0x00000008,
  249. MD_SCAN_MEMORY = 0x00000010,
  250. MD_WITH_UNLOADED_MODULES = 0x00000020,
  251. MD_WITH_INDIRECTLY_REFERENCED_MEMORY = 0x00000040,
  252. MD_FILTER_MODULE_PATHS = 0x00000080,
  253. MD_WITH_PROCESS_THREAD_DATA = 0x00000100,
  254. MD_WITH_PRIVATE_READ_WRITE_MEMORY = 0x00000200,
  255. MD_WITHOUT_OPTIONAL_DATA = 0x00000400,
  256. MD_WITH_FULL_MEMORY_INFO = 0x00000800,
  257. MD_WITH_THREAD_INFO = 0x00001000,
  258. MD_WITH_CODE_SEGS = 0x00002000,
  259. MD_WITHOUT_AUXILLIARY_SEGS = 0x00004000,
  260. MD_WITH_FULL_AUXILLIARY_STATE = 0x00008000,
  261. MD_WITH_PRIVATE_WRITE_COPY_MEMORY = 0x00010000,
  262. MD_IGNORE_INACCESSIBLE_MEMORY = 0x00020000,
  263. MD_WITH_TOKEN_INFORMATION = 0x00040000
  264. } MDType; /* MINIDUMP_TYPE */
  265. typedef struct {
  266. uint32_t stream_type;
  267. MDLocationDescriptor location;
  268. } MDRawDirectory; /* MINIDUMP_DIRECTORY */
  269. /* For (MDRawDirectory).stream_type */
  270. typedef enum {
  271. MD_UNUSED_STREAM = 0,
  272. MD_RESERVED_STREAM_0 = 1,
  273. MD_RESERVED_STREAM_1 = 2,
  274. MD_THREAD_LIST_STREAM = 3, /* MDRawThreadList */
  275. MD_MODULE_LIST_STREAM = 4, /* MDRawModuleList */
  276. MD_MEMORY_LIST_STREAM = 5, /* MDRawMemoryList */
  277. MD_EXCEPTION_STREAM = 6, /* MDRawExceptionStream */
  278. MD_SYSTEM_INFO_STREAM = 7, /* MDRawSystemInfo */
  279. MD_THREAD_EX_LIST_STREAM = 8,
  280. MD_MEMORY_64_LIST_STREAM = 9,
  281. MD_COMMENT_STREAM_A = 10,
  282. MD_COMMENT_STREAM_W = 11,
  283. MD_HANDLE_DATA_STREAM = 12,
  284. MD_FUNCTION_TABLE_STREAM = 13,
  285. MD_UNLOADED_MODULE_LIST_STREAM = 14,
  286. MD_MISC_INFO_STREAM = 15, /* MDRawMiscInfo */
  287. MD_MEMORY_INFO_LIST_STREAM = 16, /* MDRawMemoryInfoList */
  288. MD_THREAD_INFO_LIST_STREAM = 17,
  289. MD_HANDLE_OPERATION_LIST_STREAM = 18,
  290. MD_TOKEN_STREAM = 19,
  291. MD_JAVASCRIPT_DATA_STREAM = 20,
  292. MD_SYSTEM_MEMORY_INFO_STREAM = 21,
  293. MD_PROCESS_VM_COUNTERS_STREAM = 22,
  294. MD_LAST_RESERVED_STREAM = 0x0000ffff,
  295. /* Breakpad extension types. 0x4767 = "Gg" */
  296. MD_BREAKPAD_INFO_STREAM = 0x47670001, /* MDRawBreakpadInfo */
  297. MD_ASSERTION_INFO_STREAM = 0x47670002, /* MDRawAssertionInfo */
  298. /* These are additional minidump stream values which are specific to
  299. * the linux breakpad implementation. */
  300. MD_LINUX_CPU_INFO = 0x47670003, /* /proc/cpuinfo */
  301. MD_LINUX_PROC_STATUS = 0x47670004, /* /proc/$x/status */
  302. MD_LINUX_LSB_RELEASE = 0x47670005, /* /etc/lsb-release */
  303. MD_LINUX_CMD_LINE = 0x47670006, /* /proc/$x/cmdline */
  304. MD_LINUX_ENVIRON = 0x47670007, /* /proc/$x/environ */
  305. MD_LINUX_AUXV = 0x47670008, /* /proc/$x/auxv */
  306. MD_LINUX_MAPS = 0x47670009, /* /proc/$x/maps */
  307. MD_LINUX_DSO_DEBUG = 0x4767000A, /* MDRawDebug{32,64} */
  308. /* Crashpad extension types. 0x4350 = "CP"
  309. * See Crashpad's minidump/minidump_extensions.h. */
  310. MD_CRASHPAD_INFO_STREAM = 0x43500001, /* MDRawCrashpadInfo */
  311. } MDStreamType; /* MINIDUMP_STREAM_TYPE */
  312. typedef struct {
  313. uint32_t length; /* Length of buffer in bytes (not characters),
  314. * excluding 0-terminator */
  315. uint16_t buffer[1]; /* UTF-16-encoded, 0-terminated */
  316. } MDString; /* MINIDUMP_STRING */
  317. static const size_t MDString_minsize = offsetof(MDString, buffer[0]);
  318. typedef struct {
  319. uint32_t thread_id;
  320. uint32_t suspend_count;
  321. uint32_t priority_class;
  322. uint32_t priority;
  323. uint64_t teb; /* Thread environment block */
  324. MDMemoryDescriptor stack;
  325. MDLocationDescriptor thread_context; /* MDRawContext[CPU] */
  326. } MDRawThread; /* MINIDUMP_THREAD */
  327. typedef struct {
  328. uint32_t number_of_threads;
  329. MDRawThread threads[1];
  330. } MDRawThreadList; /* MINIDUMP_THREAD_LIST */
  331. static const size_t MDRawThreadList_minsize = offsetof(MDRawThreadList,
  332. threads[0]);
  333. typedef struct {
  334. uint64_t base_of_image;
  335. uint32_t size_of_image;
  336. uint32_t checksum; /* 0 if unknown */
  337. uint32_t time_date_stamp; /* time_t */
  338. MDRVA module_name_rva; /* MDString, pathname or filename */
  339. MDVSFixedFileInfo version_info;
  340. /* The next field stores a CodeView record and is populated when a module's
  341. * debug information resides in a PDB file. It identifies the PDB file. */
  342. MDLocationDescriptor cv_record;
  343. /* The next field is populated when a module's debug information resides
  344. * in a DBG file. It identifies the DBG file. This field is effectively
  345. * obsolete with modules built by recent toolchains. */
  346. MDLocationDescriptor misc_record;
  347. /* Alignment problem: reserved0 and reserved1 are defined by the platform
  348. * SDK as 64-bit quantities. However, that results in a structure whose
  349. * alignment is unpredictable on different CPUs and ABIs. If the ABI
  350. * specifies full alignment of 64-bit quantities in structures (as ppc
  351. * does), there will be padding between miscRecord and reserved0. If
  352. * 64-bit quantities can be aligned on 32-bit boundaries (as on x86),
  353. * this padding will not exist. (Note that the structure up to this point
  354. * contains 1 64-bit member followed by 21 32-bit members.)
  355. * As a workaround, reserved0 and reserved1 are instead defined here as
  356. * four 32-bit quantities. This should be harmless, as there are
  357. * currently no known uses for these fields. */
  358. uint32_t reserved0[2];
  359. uint32_t reserved1[2];
  360. } MDRawModule; /* MINIDUMP_MODULE */
  361. /* The inclusion of a 64-bit type in MINIDUMP_MODULE forces the struct to
  362. * be tail-padded out to a multiple of 64 bits under some ABIs (such as PPC).
  363. * This doesn't occur on systems that don't tail-pad in this manner. Define
  364. * this macro to be the usable size of the MDRawModule struct, and use it in
  365. * place of sizeof(MDRawModule). */
  366. #define MD_MODULE_SIZE 108
  367. /* (MDRawModule).cv_record can reference MDCVInfoPDB20 or MDCVInfoPDB70.
  368. * Ref.: http://www.debuginfo.com/articles/debuginfomatch.html
  369. * MDCVInfoPDB70 is the expected structure type with recent toolchains. */
  370. typedef struct {
  371. uint32_t signature;
  372. uint32_t offset; /* Offset to debug data (expect 0 in minidump) */
  373. } MDCVHeader;
  374. typedef struct {
  375. MDCVHeader cv_header;
  376. uint32_t signature; /* time_t debug information created */
  377. uint32_t age; /* revision of PDB file */
  378. uint8_t pdb_file_name[1]; /* Pathname or filename of PDB file */
  379. } MDCVInfoPDB20;
  380. static const size_t MDCVInfoPDB20_minsize = offsetof(MDCVInfoPDB20,
  381. pdb_file_name[0]);
  382. #define MD_CVINFOPDB20_SIGNATURE 0x3031424e /* cvHeader.signature = '01BN' */
  383. typedef struct {
  384. uint32_t cv_signature;
  385. MDGUID signature; /* GUID, identifies PDB file */
  386. uint32_t age; /* Identifies incremental changes to PDB file */
  387. uint8_t pdb_file_name[1]; /* Pathname or filename of PDB file,
  388. * 0-terminated 8-bit character data (UTF-8?) */
  389. } MDCVInfoPDB70;
  390. static const size_t MDCVInfoPDB70_minsize = offsetof(MDCVInfoPDB70,
  391. pdb_file_name[0]);
  392. #define MD_CVINFOPDB70_SIGNATURE 0x53445352 /* cvSignature = 'SDSR' */
  393. /*
  394. * Modern ELF toolchains insert a "build id" into the ELF headers that
  395. * usually contains a hash of some ELF headers + sections to uniquely
  396. * identify a binary.
  397. *
  398. * https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Developer_Guide/compiling-build-id.html
  399. * https://sourceware.org/binutils/docs-2.26/ld/Options.html#index-g_t_002d_002dbuild_002did-292
  400. */
  401. typedef struct {
  402. uint32_t cv_signature;
  403. uint8_t build_id[1]; /* Bytes of build id from GNU_BUILD_ID ELF note.
  404. * This is variable-length, but usually 20 bytes
  405. * as the binutils ld default is a SHA-1 hash. */
  406. } MDCVInfoELF;
  407. static const size_t MDCVInfoELF_minsize = offsetof(MDCVInfoELF,
  408. build_id[0]);
  409. #define MD_CVINFOELF_SIGNATURE 0x4270454c /* cvSignature = 'BpEL' */
  410. /* In addition to the two CodeView record formats above, used for linking
  411. * to external pdb files, it is possible for debugging data to be carried
  412. * directly in the CodeView record itself. These signature values will
  413. * be found in the first 4 bytes of the CodeView record. Additional values
  414. * not commonly experienced in the wild are given by "Microsoft Symbol and
  415. * Type Information", http://www.x86.org/ftp/manuals/tools/sym.pdf, section
  416. * 7.2. An in-depth description of the CodeView 4.1 format is given by
  417. * "Undocumented Windows 2000 Secrets", Windows 2000 Debugging Support/
  418. * Microsoft Symbol File Internals/CodeView Subsections,
  419. * http://www.rawol.com/features/undocumented/sbs-w2k-1-windows-2000-debugging-support.pdf
  420. */
  421. #define MD_CVINFOCV41_SIGNATURE 0x3930424e /* '90BN', CodeView 4.10. */
  422. #define MD_CVINFOCV50_SIGNATURE 0x3131424e /* '11BN', CodeView 5.0,
  423. * MS C7-format (/Z7). */
  424. #define MD_CVINFOUNKNOWN_SIGNATURE 0xffffffff /* An unlikely value. */
  425. /* (MDRawModule).miscRecord can reference MDImageDebugMisc. The Windows
  426. * structure is actually defined in WinNT.h. This structure is effectively
  427. * obsolete with modules built by recent toolchains. */
  428. typedef struct {
  429. uint32_t data_type; /* IMAGE_DEBUG_TYPE_*, not defined here because
  430. * this debug record type is mostly obsolete. */
  431. uint32_t length; /* Length of entire MDImageDebugMisc structure */
  432. uint8_t unicode; /* True if data is multibyte */
  433. uint8_t reserved[3];
  434. uint8_t data[1];
  435. } MDImageDebugMisc; /* IMAGE_DEBUG_MISC */
  436. static const size_t MDImageDebugMisc_minsize = offsetof(MDImageDebugMisc,
  437. data[0]);
  438. typedef struct {
  439. uint32_t number_of_modules;
  440. MDRawModule modules[1];
  441. } MDRawModuleList; /* MINIDUMP_MODULE_LIST */
  442. static const size_t MDRawModuleList_minsize = offsetof(MDRawModuleList,
  443. modules[0]);
  444. typedef struct {
  445. uint32_t number_of_memory_ranges;
  446. MDMemoryDescriptor memory_ranges[1];
  447. } MDRawMemoryList; /* MINIDUMP_MEMORY_LIST */
  448. static const size_t MDRawMemoryList_minsize = offsetof(MDRawMemoryList,
  449. memory_ranges[0]);
  450. #define MD_EXCEPTION_MAXIMUM_PARAMETERS 15u
  451. typedef struct {
  452. uint32_t exception_code; /* Windows: MDExceptionCodeWin,
  453. * Mac OS X: MDExceptionMac,
  454. * Linux: MDExceptionCodeLinux. */
  455. uint32_t exception_flags; /* Windows: 1 if noncontinuable,
  456. Mac OS X: MDExceptionCodeMac. */
  457. uint64_t exception_record; /* Address (in the minidump-producing host's
  458. * memory) of another MDException, for
  459. * nested exceptions. */
  460. uint64_t exception_address; /* The address that caused the exception.
  461. * Mac OS X: exception subcode (which is
  462. * typically the address). */
  463. uint32_t number_parameters; /* Number of valid elements in
  464. * exception_information. */
  465. uint32_t __align;
  466. uint64_t exception_information[MD_EXCEPTION_MAXIMUM_PARAMETERS];
  467. } MDException; /* MINIDUMP_EXCEPTION */
  468. #include "minidump_exception_fuchsia.h"
  469. #include "minidump_exception_linux.h"
  470. #include "minidump_exception_mac.h"
  471. #include "minidump_exception_ps3.h"
  472. #include "minidump_exception_solaris.h"
  473. #include "minidump_exception_win32.h"
  474. typedef struct {
  475. uint32_t thread_id; /* Thread in which the exception
  476. * occurred. Corresponds to
  477. * (MDRawThread).thread_id. */
  478. uint32_t __align;
  479. MDException exception_record;
  480. MDLocationDescriptor thread_context; /* MDRawContext[CPU] */
  481. } MDRawExceptionStream; /* MINIDUMP_EXCEPTION_STREAM */
  482. typedef union {
  483. struct {
  484. uint32_t vendor_id[3]; /* cpuid 0: ebx, edx, ecx */
  485. uint32_t version_information; /* cpuid 1: eax */
  486. uint32_t feature_information; /* cpuid 1: edx */
  487. uint32_t amd_extended_cpu_features; /* cpuid 0x80000001, ebx */
  488. } x86_cpu_info;
  489. struct {
  490. uint32_t cpuid;
  491. uint32_t elf_hwcaps; /* linux specific, 0 otherwise */
  492. } arm_cpu_info;
  493. struct {
  494. uint64_t processor_features[2];
  495. } other_cpu_info;
  496. } MDCPUInformation; /* CPU_INFORMATION */
  497. /* For (MDCPUInformation).arm_cpu_info.elf_hwcaps.
  498. * This matches the Linux kernel definitions from <asm/hwcaps.h> */
  499. typedef enum {
  500. MD_CPU_ARM_ELF_HWCAP_SWP = (1 << 0),
  501. MD_CPU_ARM_ELF_HWCAP_HALF = (1 << 1),
  502. MD_CPU_ARM_ELF_HWCAP_THUMB = (1 << 2),
  503. MD_CPU_ARM_ELF_HWCAP_26BIT = (1 << 3),
  504. MD_CPU_ARM_ELF_HWCAP_FAST_MULT = (1 << 4),
  505. MD_CPU_ARM_ELF_HWCAP_FPA = (1 << 5),
  506. MD_CPU_ARM_ELF_HWCAP_VFP = (1 << 6),
  507. MD_CPU_ARM_ELF_HWCAP_EDSP = (1 << 7),
  508. MD_CPU_ARM_ELF_HWCAP_JAVA = (1 << 8),
  509. MD_CPU_ARM_ELF_HWCAP_IWMMXT = (1 << 9),
  510. MD_CPU_ARM_ELF_HWCAP_CRUNCH = (1 << 10),
  511. MD_CPU_ARM_ELF_HWCAP_THUMBEE = (1 << 11),
  512. MD_CPU_ARM_ELF_HWCAP_NEON = (1 << 12),
  513. MD_CPU_ARM_ELF_HWCAP_VFPv3 = (1 << 13),
  514. MD_CPU_ARM_ELF_HWCAP_VFPv3D16 = (1 << 14),
  515. MD_CPU_ARM_ELF_HWCAP_TLS = (1 << 15),
  516. MD_CPU_ARM_ELF_HWCAP_VFPv4 = (1 << 16),
  517. MD_CPU_ARM_ELF_HWCAP_IDIVA = (1 << 17),
  518. MD_CPU_ARM_ELF_HWCAP_IDIVT = (1 << 18),
  519. } MDCPUInformationARMElfHwCaps;
  520. typedef struct {
  521. /* The next 3 fields and numberOfProcessors are from the SYSTEM_INFO
  522. * structure as returned by GetSystemInfo */
  523. uint16_t processor_architecture;
  524. uint16_t processor_level; /* x86: 5 = 586, 6 = 686, ... */
  525. /* ARM: 6 = ARMv6, 7 = ARMv7 ... */
  526. uint16_t processor_revision; /* x86: 0xMMSS, where MM=model,
  527. * SS=stepping */
  528. /* ARM: 0 */
  529. uint8_t number_of_processors;
  530. uint8_t product_type; /* Windows: VER_NT_* from WinNT.h */
  531. /* The next 5 fields are from the OSVERSIONINFO structure as returned
  532. * by GetVersionEx */
  533. uint32_t major_version;
  534. uint32_t minor_version;
  535. uint32_t build_number;
  536. uint32_t platform_id;
  537. MDRVA csd_version_rva; /* MDString further identifying the
  538. * host OS.
  539. * Windows: name of the installed OS
  540. * service pack.
  541. * Mac OS X: the Apple OS build number
  542. * (sw_vers -buildVersion).
  543. * Linux: uname -srvmo */
  544. uint16_t suite_mask; /* Windows: VER_SUITE_* from WinNT.h */
  545. uint16_t reserved2;
  546. MDCPUInformation cpu;
  547. } MDRawSystemInfo; /* MINIDUMP_SYSTEM_INFO */
  548. /* For (MDRawSystemInfo).processor_architecture: */
  549. typedef enum {
  550. MD_CPU_ARCHITECTURE_X86 = 0, /* PROCESSOR_ARCHITECTURE_INTEL */
  551. MD_CPU_ARCHITECTURE_MIPS = 1, /* PROCESSOR_ARCHITECTURE_MIPS */
  552. MD_CPU_ARCHITECTURE_ALPHA = 2, /* PROCESSOR_ARCHITECTURE_ALPHA */
  553. MD_CPU_ARCHITECTURE_PPC = 3, /* PROCESSOR_ARCHITECTURE_PPC */
  554. MD_CPU_ARCHITECTURE_SHX = 4, /* PROCESSOR_ARCHITECTURE_SHX
  555. * (Super-H) */
  556. MD_CPU_ARCHITECTURE_ARM = 5, /* PROCESSOR_ARCHITECTURE_ARM */
  557. MD_CPU_ARCHITECTURE_IA64 = 6, /* PROCESSOR_ARCHITECTURE_IA64 */
  558. MD_CPU_ARCHITECTURE_ALPHA64 = 7, /* PROCESSOR_ARCHITECTURE_ALPHA64 */
  559. MD_CPU_ARCHITECTURE_MSIL = 8, /* PROCESSOR_ARCHITECTURE_MSIL
  560. * (Microsoft Intermediate Language) */
  561. MD_CPU_ARCHITECTURE_AMD64 = 9, /* PROCESSOR_ARCHITECTURE_AMD64 */
  562. MD_CPU_ARCHITECTURE_X86_WIN64 = 10,
  563. /* PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 (WoW64) */
  564. MD_CPU_ARCHITECTURE_ARM64 = 12, /* PROCESSOR_ARCHITECTURE_ARM64 */
  565. MD_CPU_ARCHITECTURE_SPARC = 0x8001, /* Breakpad-defined value for SPARC */
  566. MD_CPU_ARCHITECTURE_PPC64 = 0x8002, /* Breakpad-defined value for PPC64 */
  567. MD_CPU_ARCHITECTURE_ARM64_OLD = 0x8003, /* Breakpad-defined value for ARM64 */
  568. MD_CPU_ARCHITECTURE_MIPS64 = 0x8004, /* Breakpad-defined value for MIPS64 */
  569. MD_CPU_ARCHITECTURE_UNKNOWN = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */
  570. } MDCPUArchitecture;
  571. /* For (MDRawSystemInfo).platform_id: */
  572. typedef enum {
  573. MD_OS_WIN32S = 0, /* VER_PLATFORM_WIN32s (Windows 3.1) */
  574. MD_OS_WIN32_WINDOWS = 1, /* VER_PLATFORM_WIN32_WINDOWS (Windows 95-98-Me) */
  575. MD_OS_WIN32_NT = 2, /* VER_PLATFORM_WIN32_NT (Windows NT, 2000+) */
  576. MD_OS_WIN32_CE = 3, /* VER_PLATFORM_WIN32_CE, VER_PLATFORM_WIN32_HH
  577. * (Windows CE, Windows Mobile, "Handheld") */
  578. /* The following values are Breakpad-defined. */
  579. MD_OS_UNIX = 0x8000, /* Generic Unix-ish */
  580. MD_OS_MAC_OS_X = 0x8101, /* Mac OS X/Darwin */
  581. MD_OS_IOS = 0x8102, /* iOS */
  582. MD_OS_LINUX = 0x8201, /* Linux */
  583. MD_OS_SOLARIS = 0x8202, /* Solaris */
  584. MD_OS_ANDROID = 0x8203, /* Android */
  585. MD_OS_PS3 = 0x8204, /* PS3 */
  586. MD_OS_NACL = 0x8205, /* Native Client (NaCl) */
  587. MD_OS_FUCHSIA = 0x8206 /* Fuchsia */
  588. } MDOSPlatform;
  589. typedef struct {
  590. uint64_t base_of_image;
  591. uint32_t size_of_image;
  592. uint32_t checksum;
  593. uint32_t time_date_stamp;
  594. MDRVA module_name_rva;
  595. } MDRawUnloadedModule;
  596. typedef struct {
  597. uint32_t size_of_header;
  598. uint32_t size_of_entry;
  599. uint32_t number_of_entries;
  600. } MDRawUnloadedModuleList; /* MINIDUMP_UNLOADED_MODULE_LIST */
  601. typedef struct {
  602. uint16_t year;
  603. uint16_t month;
  604. uint16_t day_of_week;
  605. uint16_t day;
  606. uint16_t hour;
  607. uint16_t minute;
  608. uint16_t second;
  609. uint16_t milliseconds;
  610. } MDSystemTime; /* SYSTEMTIME */
  611. typedef struct {
  612. /* Required field. The bias is the difference, in minutes, between
  613. * Coordinated Universal Time (UTC) and local time.
  614. * Formula: UTC = local time + bias */
  615. int32_t bias;
  616. /* A description for standard time. For example, "EST" could indicate Eastern
  617. * Standard Time. In practice this contains the full time zone names. This
  618. * string can be empty. */
  619. uint16_t standard_name[32]; /* UTF-16-encoded, 0-terminated */
  620. /* A MDSystemTime structure that contains a date and local time when the
  621. * transition from daylight saving time to standard time occurs on this
  622. * operating system. If the time zone does not support daylight saving time,
  623. * the month member in the MDSystemTime structure is zero. */
  624. MDSystemTime standard_date;
  625. /* The bias value to be used during local time translations that occur during
  626. * standard time. */
  627. int32_t standard_bias;
  628. /* A description for daylight saving time. For example, "PDT" could indicate
  629. * Pacific Daylight Time. In practice this contains the full time zone names.
  630. * This string can be empty. */
  631. uint16_t daylight_name[32]; /* UTF-16-encoded, 0-terminated */
  632. /* A MDSystemTime structure that contains a date and local time when the
  633. * transition from standard time to daylight saving time occurs on this
  634. * operating system. If the time zone does not support daylight saving time,
  635. * the month member in the MDSystemTime structure is zero.*/
  636. MDSystemTime daylight_date;
  637. /* The bias value to be used during local time translations that occur during
  638. * daylight saving time. */
  639. int32_t daylight_bias;
  640. } MDTimeZoneInformation; /* TIME_ZONE_INFORMATION */
  641. /* MAX_PATH from windef.h */
  642. #define MD_MAX_PATH 260
  643. /* For MDXStateConfigFeatureMscInfo.features */
  644. typedef struct {
  645. uint32_t offset;
  646. uint32_t size;
  647. } MDXStateFeature;
  648. /* For MDXStateConfigFeatureMscInfo.enabled_features from winnt.h */
  649. typedef enum {
  650. MD_XSTATE_LEGACY_FLOATING_POINT = 0, /* XSTATE_LEGACY_FLOATING_POINT */
  651. MD_XSTATE_LEGACY_SSE = 1, /* XSTATE_LEGACY_SSE */
  652. MD_XSTATE_GSSE = 2, /* XSTATE_GSSE */
  653. MD_XSTATE_AVX = MD_XSTATE_GSSE, /* XSTATE_AVX */
  654. MD_XSTATE_MPX_BNDREGS = 3, /* XSTATE_MPX_BNDREGS */
  655. MD_XSTATE_MPX_BNDCSR = 4, /* XSTATE_MPX_BNDCSR */
  656. MD_XSTATE_AVX512_KMASK = 5, /* XSTATE_AVX512_KMASK */
  657. MD_XSTATE_AVX512_ZMM_H = 6, /* XSTATE_AVX512_ZMM_H */
  658. MD_XSTATE_AVX512_ZMM = 7, /* XSTATE_AVX512_ZMM */
  659. MD_XSTATE_IPT = 8, /* XSTATE_IPT */
  660. MD_XSTATE_LWP = 62 /* XSTATE_LWP */
  661. } MDXStateFeatureFlag;
  662. /* MAXIMUM_XSTATE_FEATURES from winnt.h */
  663. #define MD_MAXIMUM_XSTATE_FEATURES 64
  664. /* For MDRawMiscInfo.xstate_data */
  665. typedef struct {
  666. uint32_t size_of_info;
  667. uint32_t context_size;
  668. /* An entry in the features array is valid only if the corresponding bit in
  669. * the enabled_features flag is set. */
  670. uint64_t enabled_features;
  671. MDXStateFeature features[MD_MAXIMUM_XSTATE_FEATURES];
  672. } MDXStateConfigFeatureMscInfo;
  673. /* The miscellaneous information stream contains a variety
  674. * of small pieces of information. A member is valid if
  675. * it's within the available size and its corresponding
  676. * bit is set. */
  677. typedef struct {
  678. uint32_t size_of_info; /* Length of entire MDRawMiscInfo structure. */
  679. uint32_t flags1;
  680. /* The next field is only valid if flags1 contains
  681. * MD_MISCINFO_FLAGS1_PROCESS_ID. */
  682. uint32_t process_id;
  683. /* The next 3 fields are only valid if flags1 contains
  684. * MD_MISCINFO_FLAGS1_PROCESS_TIMES. */
  685. uint32_t process_create_time; /* time_t process started */
  686. uint32_t process_user_time; /* seconds of user CPU time */
  687. uint32_t process_kernel_time; /* seconds of kernel CPU time */
  688. /* The following fields are not present in MINIDUMP_MISC_INFO but are
  689. * in MINIDUMP_MISC_INFO_2. When this struct is populated, these values
  690. * may not be set. Use flags1 and size_of_info to determine whether these
  691. * values are present. These are only valid when flags1 contains
  692. * MD_MISCINFO_FLAGS1_PROCESSOR_POWER_INFO. */
  693. uint32_t processor_max_mhz;
  694. uint32_t processor_current_mhz;
  695. uint32_t processor_mhz_limit;
  696. uint32_t processor_max_idle_state;
  697. uint32_t processor_current_idle_state;
  698. /* The following fields are not present in MINIDUMP_MISC_INFO_2 but are
  699. * in MINIDUMP_MISC_INFO_3. When this struct is populated, these values
  700. * may not be set. Use flags1 and size_of_info to determine whether these
  701. * values are present. */
  702. /* The following field is only valid if flags1 contains
  703. * MD_MISCINFO_FLAGS1_PROCESS_INTEGRITY. */
  704. uint32_t process_integrity_level;
  705. /* The following field is only valid if flags1 contains
  706. * MD_MISCINFO_FLAGS1_PROCESS_EXECUTE_FLAGS. */
  707. uint32_t process_execute_flags;
  708. /* The following field is only valid if flags1 contains
  709. * MD_MISCINFO_FLAGS1_PROTECTED_PROCESS. */
  710. uint32_t protected_process;
  711. /* The following 2 fields are only valid if flags1 contains
  712. * MD_MISCINFO_FLAGS1_TIMEZONE. */
  713. uint32_t time_zone_id;
  714. MDTimeZoneInformation time_zone;
  715. /* The following fields are not present in MINIDUMP_MISC_INFO_3 but are
  716. * in MINIDUMP_MISC_INFO_4. When this struct is populated, these values
  717. * may not be set. Use flags1 and size_of_info to determine whether these
  718. * values are present. */
  719. /* The following 2 fields are only valid if flags1 contains
  720. * MD_MISCINFO_FLAGS1_BUILDSTRING. */
  721. uint16_t build_string[MD_MAX_PATH]; /* UTF-16-encoded, 0-terminated */
  722. uint16_t dbg_bld_str[40]; /* UTF-16-encoded, 0-terminated */
  723. /* The following fields are not present in MINIDUMP_MISC_INFO_4 but are
  724. * in MINIDUMP_MISC_INFO_5. When this struct is populated, these values
  725. * may not be set. Use flags1 and size_of_info to determine whether these
  726. * values are present. */
  727. /* The following field has its own flags for establishing the validity of
  728. * the structure's contents.*/
  729. MDXStateConfigFeatureMscInfo xstate_data;
  730. /* The following field is only valid if flags1 contains
  731. * MD_MISCINFO_FLAGS1_PROCESS_COOKIE. */
  732. uint32_t process_cookie;
  733. } MDRawMiscInfo; /* MINIDUMP_MISC_INFO, MINIDUMP_MISC_INFO_2,
  734. * MINIDUMP_MISC_INFO_3, MINIDUMP_MISC_INFO_4,
  735. * MINIDUMP_MISC_INFO_5, MINIDUMP_MISC_INFO_N */
  736. static const size_t MD_MISCINFO_SIZE =
  737. offsetof(MDRawMiscInfo, processor_max_mhz);
  738. static const size_t MD_MISCINFO2_SIZE =
  739. offsetof(MDRawMiscInfo, process_integrity_level);
  740. static const size_t MD_MISCINFO3_SIZE =
  741. offsetof(MDRawMiscInfo, build_string[0]);
  742. static const size_t MD_MISCINFO4_SIZE =
  743. offsetof(MDRawMiscInfo, xstate_data);
  744. /* Version 5 of the MDRawMiscInfo structure is not a multiple of 8 in size and
  745. * yet it contains some 8-bytes sized fields. This causes many compilers to
  746. * round the structure size up to a multiple of 8 by adding padding at the end.
  747. * The following hack is thus required for matching the proper on-disk size. */
  748. static const size_t MD_MISCINFO5_SIZE =
  749. offsetof(MDRawMiscInfo, process_cookie) + sizeof(uint32_t);
  750. /* For (MDRawMiscInfo).flags1. These values indicate which fields in the
  751. * MDRawMiscInfoStructure are valid. */
  752. typedef enum {
  753. MD_MISCINFO_FLAGS1_PROCESS_ID = 0x00000001,
  754. /* MINIDUMP_MISC1_PROCESS_ID */
  755. MD_MISCINFO_FLAGS1_PROCESS_TIMES = 0x00000002,
  756. /* MINIDUMP_MISC1_PROCESS_TIMES */
  757. MD_MISCINFO_FLAGS1_PROCESSOR_POWER_INFO = 0x00000004,
  758. /* MINIDUMP_MISC1_PROCESSOR_POWER_INFO */
  759. MD_MISCINFO_FLAGS1_PROCESS_INTEGRITY = 0x00000010,
  760. /* MINIDUMP_MISC3_PROCESS_INTEGRITY */
  761. MD_MISCINFO_FLAGS1_PROCESS_EXECUTE_FLAGS = 0x00000020,
  762. /* MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS */
  763. MD_MISCINFO_FLAGS1_TIMEZONE = 0x00000040,
  764. /* MINIDUMP_MISC3_TIMEZONE */
  765. MD_MISCINFO_FLAGS1_PROTECTED_PROCESS = 0x00000080,
  766. /* MINIDUMP_MISC3_PROTECTED_PROCESS */
  767. MD_MISCINFO_FLAGS1_BUILDSTRING = 0x00000100,
  768. /* MINIDUMP_MISC4_BUILDSTRING */
  769. MD_MISCINFO_FLAGS1_PROCESS_COOKIE = 0x00000200,
  770. /* MINIDUMP_MISC5_PROCESS_COOKIE */
  771. } MDMiscInfoFlags1;
  772. /*
  773. * Around DbgHelp version 6.0, the style of new LIST structures changed
  774. * from including an array of length 1 at the end of the struct to
  775. * represent the variable-length data to including explicit
  776. * "size of header", "size of entry" and "number of entries" fields
  777. * in the header, presumably to allow backwards-compatibly-extending
  778. * the structures in the future. The actual list entries follow the
  779. * header data directly in this case.
  780. */
  781. typedef struct {
  782. uint32_t size_of_header; /* sizeof(MDRawMemoryInfoList) */
  783. uint32_t size_of_entry; /* sizeof(MDRawMemoryInfo) */
  784. uint64_t number_of_entries;
  785. } MDRawMemoryInfoList; /* MINIDUMP_MEMORY_INFO_LIST */
  786. typedef struct {
  787. uint64_t base_address; /* Base address of a region of pages */
  788. uint64_t allocation_base; /* Base address of a range of pages
  789. * within this region. */
  790. uint32_t allocation_protection; /* Memory protection when this region
  791. * was originally allocated:
  792. * MDMemoryProtection */
  793. uint32_t __alignment1;
  794. uint64_t region_size;
  795. uint32_t state; /* MDMemoryState */
  796. uint32_t protection; /* MDMemoryProtection */
  797. uint32_t type; /* MDMemoryType */
  798. uint32_t __alignment2;
  799. } MDRawMemoryInfo; /* MINIDUMP_MEMORY_INFO */
  800. /* For (MDRawMemoryInfo).state */
  801. typedef enum {
  802. MD_MEMORY_STATE_COMMIT = 0x1000, /* physical storage has been allocated */
  803. MD_MEMORY_STATE_RESERVE = 0x2000, /* reserved, but no physical storage */
  804. MD_MEMORY_STATE_FREE = 0x10000 /* available to be allocated */
  805. } MDMemoryState;
  806. /* For (MDRawMemoryInfo).allocation_protection and .protection */
  807. typedef enum {
  808. MD_MEMORY_PROTECT_NOACCESS = 0x01, /* PAGE_NOACCESS */
  809. MD_MEMORY_PROTECT_READONLY = 0x02, /* PAGE_READONLY */
  810. MD_MEMORY_PROTECT_READWRITE = 0x04, /* PAGE_READWRITE */
  811. MD_MEMORY_PROTECT_WRITECOPY = 0x08, /* PAGE_WRITECOPY */
  812. MD_MEMORY_PROTECT_EXECUTE = 0x10, /* PAGE_EXECUTE */
  813. MD_MEMORY_PROTECT_EXECUTE_READ = 0x20, /* PAGE_EXECUTE_READ */
  814. MD_MEMORY_PROTECT_EXECUTE_READWRITE = 0x40, /* PAGE_EXECUTE_READWRITE */
  815. MD_MEMORY_PROTECT_EXECUTE_WRITECOPY = 0x80, /* PAGE_EXECUTE_WRITECOPY */
  816. /* These options can be combined with the previous flags. */
  817. MD_MEMORY_PROTECT_GUARD = 0x100, /* PAGE_GUARD */
  818. MD_MEMORY_PROTECT_NOCACHE = 0x200, /* PAGE_NOCACHE */
  819. MD_MEMORY_PROTECT_WRITECOMBINE = 0x400, /* PAGE_WRITECOMBINE */
  820. } MDMemoryProtection;
  821. /* Used to mask the mutually exclusive options from the combinable flags. */
  822. const uint32_t MD_MEMORY_PROTECTION_ACCESS_MASK = 0xFF;
  823. /* For (MDRawMemoryInfo).type */
  824. typedef enum {
  825. MD_MEMORY_TYPE_PRIVATE = 0x20000, /* not shared by other processes */
  826. MD_MEMORY_TYPE_MAPPED = 0x40000, /* mapped into the view of a section */
  827. MD_MEMORY_TYPE_IMAGE = 0x1000000 /* mapped into the view of an image */
  828. } MDMemoryType;
  829. /*
  830. * Breakpad extension types
  831. */
  832. typedef struct {
  833. /* validity is a bitmask with values from MDBreakpadInfoValidity, indicating
  834. * which of the other fields in the structure are valid. */
  835. uint32_t validity;
  836. /* Thread ID of the handler thread. dump_thread_id should correspond to
  837. * the thread_id of an MDRawThread in the minidump's MDRawThreadList if
  838. * a dedicated thread in that list was used to produce the minidump. If
  839. * the MDRawThreadList does not contain a dedicated thread used to produce
  840. * the minidump, this field should be set to 0 and the validity field
  841. * must not contain MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID. */
  842. uint32_t dump_thread_id;
  843. /* Thread ID of the thread that requested the minidump be produced. As
  844. * with dump_thread_id, requesting_thread_id should correspond to the
  845. * thread_id of an MDRawThread in the minidump's MDRawThreadList. For
  846. * minidumps produced as a result of an exception, requesting_thread_id
  847. * will be the same as the MDRawExceptionStream's thread_id field. For
  848. * minidumps produced "manually" at the program's request,
  849. * requesting_thread_id will indicate which thread caused the dump to be
  850. * written. If the minidump was produced at the request of something
  851. * other than a thread in the MDRawThreadList, this field should be set
  852. * to 0 and the validity field must not contain
  853. * MD_BREAKPAD_INFO_VALID_REQUESTING_THREAD_ID. */
  854. uint32_t requesting_thread_id;
  855. } MDRawBreakpadInfo;
  856. /* For (MDRawBreakpadInfo).validity: */
  857. typedef enum {
  858. /* When set, the dump_thread_id field is valid. */
  859. MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID = 1 << 0,
  860. /* When set, the requesting_thread_id field is valid. */
  861. MD_BREAKPAD_INFO_VALID_REQUESTING_THREAD_ID = 1 << 1
  862. } MDBreakpadInfoValidity;
  863. typedef struct {
  864. /* expression, function, and file are 0-terminated UTF-16 strings. They
  865. * may be truncated if necessary, but should always be 0-terminated when
  866. * written to a file.
  867. * Fixed-length strings are used because MiniDumpWriteDump doesn't offer
  868. * a way for user streams to point to arbitrary RVAs for strings. */
  869. uint16_t expression[128]; /* Assertion that failed... */
  870. uint16_t function[128]; /* ...within this function... */
  871. uint16_t file[128]; /* ...in this file... */
  872. uint32_t line; /* ...at this line. */
  873. uint32_t type;
  874. } MDRawAssertionInfo;
  875. /* For (MDRawAssertionInfo).type: */
  876. typedef enum {
  877. MD_ASSERTION_INFO_TYPE_UNKNOWN = 0,
  878. /* Used for assertions that would be raised by the MSVC CRT but are
  879. * directed to an invalid parameter handler instead. */
  880. MD_ASSERTION_INFO_TYPE_INVALID_PARAMETER,
  881. /* Used for assertions that would be raised by the MSVC CRT but are
  882. * directed to a pure virtual call handler instead. */
  883. MD_ASSERTION_INFO_TYPE_PURE_VIRTUAL_CALL
  884. } MDAssertionInfoData;
  885. /* These structs are used to store the DSO debug data in Linux minidumps,
  886. * which is necessary for converting minidumps to usable coredumps.
  887. * Because of a historical accident, several fields are variably encoded
  888. * according to client word size, so tools potentially need to support both. */
  889. typedef struct {
  890. uint32_t addr;
  891. MDRVA name;
  892. uint32_t ld;
  893. } MDRawLinkMap32;
  894. typedef struct {
  895. uint32_t version;
  896. MDRVA map; /* array of MDRawLinkMap32 */
  897. uint32_t dso_count;
  898. uint32_t brk;
  899. uint32_t ldbase;
  900. uint32_t dynamic;
  901. } MDRawDebug32;
  902. typedef struct {
  903. uint64_t addr;
  904. MDRVA name;
  905. uint64_t ld;
  906. } MDRawLinkMap64;
  907. typedef struct {
  908. uint32_t version;
  909. MDRVA map; /* array of MDRawLinkMap64 */
  910. uint32_t dso_count;
  911. uint64_t brk;
  912. uint64_t ldbase;
  913. uint64_t dynamic;
  914. } MDRawDebug64;
  915. /* Crashpad extension types. See Crashpad's minidump/minidump_extensions.h. */
  916. typedef struct {
  917. MDRVA key;
  918. MDRVA value;
  919. } MDRawSimpleStringDictionaryEntry;
  920. typedef struct {
  921. uint32_t count;
  922. MDRawSimpleStringDictionaryEntry entries[0];
  923. } MDRawSimpleStringDictionary;
  924. typedef struct {
  925. uint32_t version;
  926. MDLocationDescriptor list_annotations;
  927. MDLocationDescriptor simple_annotations; /* MDRawSimpleStringDictionary */
  928. } MDRawModuleCrashpadInfo;
  929. typedef struct {
  930. uint32_t minidump_module_list_index;
  931. MDLocationDescriptor location; /* MDRawModuleCrashpadInfo */
  932. } MDRawModuleCrashpadInfoLink;
  933. typedef struct {
  934. uint32_t count;
  935. MDLocationDescriptor modules[0]; /* MDRawModuleCrashpadInfoLink */
  936. } MDRawModuleCrashpadInfoList;
  937. typedef struct {
  938. uint32_t version;
  939. MDGUID report_id;
  940. MDGUID client_id;
  941. MDLocationDescriptor simple_annotations; /* MDRawSimpleStringDictionary */
  942. MDLocationDescriptor module_list; /* MDRawModuleCrashpadInfoList */
  943. } MDRawCrashpadInfo;
  944. #if defined(_MSC_VER)
  945. #pragma warning(pop)
  946. #endif /* _MSC_VER */
  947. #endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__ */