Planeshift

minidump_format.h

Go to the documentation of this file.
00001 /* Copyright (c) 2006, Google Inc.
00002  * All rights reserved.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are
00006  * met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  * notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above
00011  * copyright notice, this list of conditions and the following disclaimer
00012  * in the documentation and/or other materials provided with the
00013  * distribution.
00014  *     * Neither the name of Google Inc. nor the names of its
00015  * contributors may be used to endorse or promote products derived from
00016  * this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00024  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
00029 
00030 /* minidump_format.h: A cross-platform reimplementation of minidump-related
00031  * portions of DbgHelp.h from the Windows Platform SDK.
00032  *
00033  * (This is C99 source, please don't corrupt it with C++.)
00034  *
00035  * Structures that are defined by Microsoft to contain a zero-length array
00036  * are instead defined here to contain an array with one element, as
00037  * zero-length arrays are forbidden by standard C and C++.  In these cases,
00038  * *_minsize constants are provided to be used in place of sizeof.  For a
00039  * cleaner interface to these sizes when using C++, see minidump_size.h.
00040  *
00041  * These structures are also sufficient to populate minidump files.
00042  *
00043  * These definitions may be extended to support handling minidump files
00044  * for other CPUs and other operating systems.
00045  *
00046  * Because precise data type sizes are crucial for this implementation to
00047  * function properly and portably in terms of interoperability with minidumps
00048  * produced by DbgHelp on Windows, a set of primitive types with known sizes
00049  * are used as the basis of each structure defined by this file.  DbgHelp
00050  * on Windows is assumed to be the reference implementation; this file
00051  * seeks to provide a cross-platform compatible implementation.  To avoid
00052  * collisions with the types and values defined and used by DbgHelp in the
00053  * event that this implementation is used on Windows, each type and value
00054  * defined here is given a new name, beginning with "MD".  Names of the
00055  * equivalent types and values in the Windows Platform SDK are given in
00056  * comments.
00057  *
00058  * Author: Mark Mentovai */
00059 
00060 
00061 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__
00062 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__
00063 
00064 #include <stddef.h>
00065 
00066 #include "google_breakpad/common/breakpad_types.h"
00067 
00068 
00069 #if defined(_MSC_VER)
00070 /* Disable "zero-sized array in struct/union" warnings when compiling in
00071  * MSVC.  DbgHelp.h does this too. */
00072 #pragma warning(push)
00073 #pragma warning(disable:4200)
00074 #endif  /* _MSC_VER */
00075 
00076 
00077 /*
00078  * guiddef.h
00079  */
00080 
00081 typedef struct {
00082   uint32_t data1;
00083   uint16_t data2;
00084   uint16_t data3;
00085   uint8_t  data4[8];
00086 } MDGUID;  /* GUID */
00087 
00088 
00089 /*
00090  * WinNT.h
00091  */
00092 
00093 /* Non-x86 CPU identifiers found in the high 24 bits of
00094  * (MDRawContext*).context_flags.  These aren't used by Breakpad, but are
00095  * defined here for reference, to avoid assigning values that conflict
00096  * (although some values already conflict). */
00097 #define MD_CONTEXT_IA64  0x00080000  /* CONTEXT_IA64 */
00098 /* Additional values from winnt.h in the Windows CE 5.0 SDK: */
00099 #define MD_CONTEXT_SHX   0x000000c0  /* CONTEXT_SH4 (Super-H, includes SH3) */
00100 #define MD_CONTEXT_MIPS  0x00010000  /* CONTEXT_R4000 (same value as x86?) */
00101 #define MD_CONTEXT_ALPHA 0x00020000  /* CONTEXT_ALPHA */
00102 
00103 /* As of Windows 7 SP1, the number of flag bits has increased to
00104  * include 0x40 (CONTEXT_XSTATE):
00105  * http://msdn.microsoft.com/en-us/library/hh134238%28v=vs.85%29.aspx */
00106 #define MD_CONTEXT_CPU_MASK 0xffffff00
00107 
00108 
00109 /* This is a base type for MDRawContextX86 and MDRawContextPPC.  This
00110  * structure should never be allocated directly.  The actual structure type
00111  * can be determined by examining the context_flags field. */
00112 typedef struct {
00113   uint32_t context_flags;
00114 } MDRawContextBase;
00115 
00116 #include "minidump_cpu_amd64.h"
00117 #include "minidump_cpu_arm.h"
00118 #include "minidump_cpu_ppc.h"
00119 #include "minidump_cpu_ppc64.h"
00120 #include "minidump_cpu_sparc.h"
00121 #include "minidump_cpu_x86.h"
00122 
00123 /*
00124  * WinVer.h
00125  */
00126 
00127 
00128 typedef struct {
00129   uint32_t signature;
00130   uint32_t struct_version;
00131   uint32_t file_version_hi;
00132   uint32_t file_version_lo;
00133   uint32_t product_version_hi;
00134   uint32_t product_version_lo;
00135   uint32_t file_flags_mask;    /* Identifies valid bits in fileFlags */
00136   uint32_t file_flags;
00137   uint32_t file_os;
00138   uint32_t file_type;
00139   uint32_t file_subtype;
00140   uint32_t file_date_hi;
00141   uint32_t file_date_lo;
00142 } MDVSFixedFileInfo;  /* VS_FIXEDFILEINFO */
00143 
00144 /* For (MDVSFixedFileInfo).signature */
00145 #define MD_VSFIXEDFILEINFO_SIGNATURE 0xfeef04bd
00146      /* VS_FFI_SIGNATURE */
00147 
00148 /* For (MDVSFixedFileInfo).version */
00149 #define MD_VSFIXEDFILEINFO_VERSION 0x00010000
00150      /* VS_FFI_STRUCVERSION */
00151 
00152 /* For (MDVSFixedFileInfo).file_flags_mask and
00153  * (MDVSFixedFileInfo).file_flags */
00154 #define MD_VSFIXEDFILEINFO_FILE_FLAGS_DEBUG        0x00000001
00155      /* VS_FF_DEBUG */
00156 #define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRERELEASE   0x00000002
00157      /* VS_FF_PRERELEASE */
00158 #define MD_VSFIXEDFILEINFO_FILE_FLAGS_PATCHED      0x00000004
00159      /* VS_FF_PATCHED */
00160 #define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRIVATEBUILD 0x00000008
00161      /* VS_FF_PRIVATEBUILD */
00162 #define MD_VSFIXEDFILEINFO_FILE_FLAGS_INFOINFERRED 0x00000010
00163      /* VS_FF_INFOINFERRED */
00164 #define MD_VSFIXEDFILEINFO_FILE_FLAGS_SPECIALBUILD 0x00000020
00165      /* VS_FF_SPECIALBUILD */
00166 
00167 /* For (MDVSFixedFileInfo).file_os: high 16 bits */
00168 #define MD_VSFIXEDFILEINFO_FILE_OS_UNKNOWN    0          /* VOS_UNKNOWN */
00169 #define MD_VSFIXEDFILEINFO_FILE_OS_DOS        (1 << 16)  /* VOS_DOS */
00170 #define MD_VSFIXEDFILEINFO_FILE_OS_OS216      (2 << 16)  /* VOS_OS216 */
00171 #define MD_VSFIXEDFILEINFO_FILE_OS_OS232      (3 << 16)  /* VOS_OS232 */
00172 #define MD_VSFIXEDFILEINFO_FILE_OS_NT         (4 << 16)  /* VOS_NT */
00173 #define MD_VSFIXEDFILEINFO_FILE_OS_WINCE      (5 << 16)  /* VOS_WINCE */
00174 /* Low 16 bits */
00175 #define MD_VSFIXEDFILEINFO_FILE_OS__BASE      0          /* VOS__BASE */
00176 #define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS16 1          /* VOS__WINDOWS16 */
00177 #define MD_VSFIXEDFILEINFO_FILE_OS__PM16      2          /* VOS__PM16 */
00178 #define MD_VSFIXEDFILEINFO_FILE_OS__PM32      3          /* VOS__PM32 */
00179 #define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS32 4          /* VOS__WINDOWS32 */
00180 
00181 /* For (MDVSFixedFileInfo).file_type */
00182 #define MD_VSFIXEDFILEINFO_FILE_TYPE_UNKNOWN    0  /* VFT_UNKNOWN */
00183 #define MD_VSFIXEDFILEINFO_FILE_TYPE_APP        1  /* VFT_APP */
00184 #define MD_VSFIXEDFILEINFO_FILE_TYPE_DLL        2  /* VFT_DLL */
00185 #define MD_VSFIXEDFILEINFO_FILE_TYPE_DRV        3  /* VFT_DLL */
00186 #define MD_VSFIXEDFILEINFO_FILE_TYPE_FONT       4  /* VFT_FONT */
00187 #define MD_VSFIXEDFILEINFO_FILE_TYPE_VXD        5  /* VFT_VXD */
00188 #define MD_VSFIXEDFILEINFO_FILE_TYPE_STATIC_LIB 7  /* VFT_STATIC_LIB */
00189 
00190 /* For (MDVSFixedFileInfo).file_subtype */
00191 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_UNKNOWN                0
00192      /* VFT2_UNKNOWN */
00193 /* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_DRV */
00194 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_PRINTER            1
00195      /* VFT2_DRV_PRINTER */
00196 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_KEYBOARD           2
00197      /* VFT2_DRV_KEYBOARD */
00198 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_LANGUAGE           3
00199      /* VFT2_DRV_LANGUAGE */
00200 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_DISPLAY            4
00201      /* VFT2_DRV_DISPLAY */
00202 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_MOUSE              5
00203      /* VFT2_DRV_MOUSE */
00204 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_NETWORK            6
00205      /* VFT2_DRV_NETWORK */
00206 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SYSTEM             7
00207      /* VFT2_DRV_SYSTEM */
00208 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INSTALLABLE        8
00209      /* VFT2_DRV_INSTALLABLE */
00210 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SOUND              9
00211      /* VFT2_DRV_SOUND */
00212 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_COMM              10
00213      /* VFT2_DRV_COMM */
00214 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INPUTMETHOD       11
00215      /* VFT2_DRV_INPUTMETHOD */
00216 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_VERSIONED_PRINTER 12
00217      /* VFT2_DRV_VERSIONED_PRINTER */
00218 /* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_FONT */
00219 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_RASTER            1
00220      /* VFT2_FONT_RASTER */
00221 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_VECTOR            2
00222      /* VFT2_FONT_VECTOR */
00223 #define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_TRUETYPE          3
00224      /* VFT2_FONT_TRUETYPE */
00225 
00226 
00227 /*
00228  * DbgHelp.h
00229  */
00230 
00231 
00232 /* An MDRVA is an offset into the minidump file.  The beginning of the
00233  * MDRawHeader is at offset 0. */
00234 typedef uint32_t MDRVA;  /* RVA */
00235 
00236 typedef struct {
00237   uint32_t  data_size;
00238   MDRVA     rva;
00239 } MDLocationDescriptor;  /* MINIDUMP_LOCATION_DESCRIPTOR */
00240 
00241 
00242 typedef struct {
00243   /* The base address of the memory range on the host that produced the
00244    * minidump. */
00245   uint64_t             start_of_memory_range;
00246 
00247   MDLocationDescriptor memory;
00248 } MDMemoryDescriptor;  /* MINIDUMP_MEMORY_DESCRIPTOR */
00249 
00250 
00251 typedef struct {
00252   uint32_t  signature;
00253   uint32_t  version;
00254   uint32_t  stream_count;
00255   MDRVA     stream_directory_rva;  /* A |stream_count|-sized array of
00256                                     * MDRawDirectory structures. */
00257   uint32_t  checksum;              /* Can be 0.  In fact, that's all that's
00258                                     * been found in minidump files. */
00259   uint32_t  time_date_stamp;       /* time_t */
00260   uint64_t  flags;
00261 } MDRawHeader;  /* MINIDUMP_HEADER */
00262 
00263 /* For (MDRawHeader).signature and (MDRawHeader).version.  Note that only the
00264  * low 16 bits of (MDRawHeader).version are MD_HEADER_VERSION.  Per the
00265  * documentation, the high 16 bits are implementation-specific. */
00266 #define MD_HEADER_SIGNATURE 0x504d444d /* 'PMDM' */
00267      /* MINIDUMP_SIGNATURE */
00268 #define MD_HEADER_VERSION   0x0000a793 /* 42899 */
00269      /* MINIDUMP_VERSION */
00270 
00271 /* For (MDRawHeader).flags: */
00272 typedef enum {
00273   /* MD_NORMAL is the standard type of minidump.  It includes full
00274    * streams for the thread list, module list, exception, system info,
00275    * and miscellaneous info.  A memory list stream is also present,
00276    * pointing to the same stack memory contained in the thread list,
00277    * as well as a 256-byte region around the instruction address that
00278    * was executing when the exception occurred.  Stack memory is from
00279    * 4 bytes below a thread's stack pointer up to the top of the
00280    * memory region encompassing the stack. */
00281   MD_NORMAL                            = 0x00000000,
00282   MD_WITH_DATA_SEGS                    = 0x00000001,
00283   MD_WITH_FULL_MEMORY                  = 0x00000002,
00284   MD_WITH_HANDLE_DATA                  = 0x00000004,
00285   MD_FILTER_MEMORY                     = 0x00000008,
00286   MD_SCAN_MEMORY                       = 0x00000010,
00287   MD_WITH_UNLOADED_MODULES             = 0x00000020,
00288   MD_WITH_INDIRECTLY_REFERENCED_MEMORY = 0x00000040,
00289   MD_FILTER_MODULE_PATHS               = 0x00000080,
00290   MD_WITH_PROCESS_THREAD_DATA          = 0x00000100,
00291   MD_WITH_PRIVATE_READ_WRITE_MEMORY    = 0x00000200,
00292   MD_WITHOUT_OPTIONAL_DATA             = 0x00000400,
00293   MD_WITH_FULL_MEMORY_INFO             = 0x00000800,
00294   MD_WITH_THREAD_INFO                  = 0x00001000,
00295   MD_WITH_CODE_SEGS                    = 0x00002000,
00296   MD_WITHOUT_AUXILLIARY_SEGS           = 0x00004000,
00297   MD_WITH_FULL_AUXILLIARY_STATE        = 0x00008000,
00298   MD_WITH_PRIVATE_WRITE_COPY_MEMORY    = 0x00010000,
00299   MD_IGNORE_INACCESSIBLE_MEMORY        = 0x00020000,
00300   MD_WITH_TOKEN_INFORMATION            = 0x00040000
00301 } MDType;  /* MINIDUMP_TYPE */
00302 
00303 
00304 typedef struct {
00305   uint32_t             stream_type;
00306   MDLocationDescriptor location;
00307 } MDRawDirectory;  /* MINIDUMP_DIRECTORY */
00308 
00309 /* For (MDRawDirectory).stream_type */
00310 typedef enum {
00311   MD_UNUSED_STREAM               =  0,
00312   MD_RESERVED_STREAM_0           =  1,
00313   MD_RESERVED_STREAM_1           =  2,
00314   MD_THREAD_LIST_STREAM          =  3,  /* MDRawThreadList */
00315   MD_MODULE_LIST_STREAM          =  4,  /* MDRawModuleList */
00316   MD_MEMORY_LIST_STREAM          =  5,  /* MDRawMemoryList */
00317   MD_EXCEPTION_STREAM            =  6,  /* MDRawExceptionStream */
00318   MD_SYSTEM_INFO_STREAM          =  7,  /* MDRawSystemInfo */
00319   MD_THREAD_EX_LIST_STREAM       =  8,
00320   MD_MEMORY_64_LIST_STREAM       =  9,
00321   MD_COMMENT_STREAM_A            = 10,
00322   MD_COMMENT_STREAM_W            = 11,
00323   MD_HANDLE_DATA_STREAM          = 12,
00324   MD_FUNCTION_TABLE_STREAM       = 13,
00325   MD_UNLOADED_MODULE_LIST_STREAM = 14,
00326   MD_MISC_INFO_STREAM            = 15,  /* MDRawMiscInfo */
00327   MD_MEMORY_INFO_LIST_STREAM     = 16,  /* MDRawMemoryInfoList */
00328   MD_THREAD_INFO_LIST_STREAM     = 17,
00329   MD_HANDLE_OPERATION_LIST_STREAM = 18,
00330   MD_LAST_RESERVED_STREAM        = 0x0000ffff,
00331 
00332   /* Breakpad extension types.  0x4767 = "Gg" */
00333   MD_BREAKPAD_INFO_STREAM        = 0x47670001,  /* MDRawBreakpadInfo  */
00334   MD_ASSERTION_INFO_STREAM       = 0x47670002,  /* MDRawAssertionInfo */
00335   /* These are additional minidump stream values which are specific to
00336    * the linux breakpad implementation. */
00337   MD_LINUX_CPU_INFO              = 0x47670003,  /* /proc/cpuinfo      */
00338   MD_LINUX_PROC_STATUS           = 0x47670004,  /* /proc/$x/status    */
00339   MD_LINUX_LSB_RELEASE           = 0x47670005,  /* /etc/lsb-release   */
00340   MD_LINUX_CMD_LINE              = 0x47670006,  /* /proc/$x/cmdline   */
00341   MD_LINUX_ENVIRON               = 0x47670007,  /* /proc/$x/environ   */
00342   MD_LINUX_AUXV                  = 0x47670008,  /* /proc/$x/auxv      */
00343   MD_LINUX_MAPS                  = 0x47670009,  /* /proc/$x/maps      */
00344   MD_LINUX_DSO_DEBUG             = 0x4767000A   /* MDRawDebug         */
00345 } MDStreamType;  /* MINIDUMP_STREAM_TYPE */
00346 
00347 
00348 typedef struct {
00349   uint32_t length;     /* Length of buffer in bytes (not characters),
00350                         * excluding 0-terminator */
00351   uint16_t buffer[1];  /* UTF-16-encoded, 0-terminated */
00352 } MDString;  /* MINIDUMP_STRING */
00353 
00354 static const size_t MDString_minsize = offsetof(MDString, buffer[0]);
00355 
00356 
00357 typedef struct {
00358   uint32_t             thread_id;
00359   uint32_t             suspend_count;
00360   uint32_t             priority_class;
00361   uint32_t             priority;
00362   uint64_t             teb;             /* Thread environment block */
00363   MDMemoryDescriptor   stack;
00364   MDLocationDescriptor thread_context;  /* MDRawContext[CPU] */
00365 } MDRawThread;  /* MINIDUMP_THREAD */
00366 
00367 
00368 typedef struct {
00369   uint32_t    number_of_threads;
00370   MDRawThread threads[1];
00371 } MDRawThreadList;  /* MINIDUMP_THREAD_LIST */
00372 
00373 static const size_t MDRawThreadList_minsize = offsetof(MDRawThreadList,
00374                                                        threads[0]);
00375 
00376 
00377 typedef struct {
00378   uint64_t             base_of_image;
00379   uint32_t             size_of_image;
00380   uint32_t             checksum;         /* 0 if unknown */
00381   uint32_t             time_date_stamp;  /* time_t */
00382   MDRVA                module_name_rva;  /* MDString, pathname or filename */
00383   MDVSFixedFileInfo    version_info;
00384 
00385   /* The next field stores a CodeView record and is populated when a module's
00386    * debug information resides in a PDB file.  It identifies the PDB file. */
00387   MDLocationDescriptor cv_record;
00388 
00389   /* The next field is populated when a module's debug information resides
00390    * in a DBG file.  It identifies the DBG file.  This field is effectively
00391    * obsolete with modules built by recent toolchains. */
00392   MDLocationDescriptor misc_record;
00393 
00394   /* Alignment problem: reserved0 and reserved1 are defined by the platform
00395    * SDK as 64-bit quantities.  However, that results in a structure whose
00396    * alignment is unpredictable on different CPUs and ABIs.  If the ABI
00397    * specifies full alignment of 64-bit quantities in structures (as ppc
00398    * does), there will be padding between miscRecord and reserved0.  If
00399    * 64-bit quantities can be aligned on 32-bit boundaries (as on x86),
00400    * this padding will not exist.  (Note that the structure up to this point
00401    * contains 1 64-bit member followed by 21 32-bit members.)
00402    * As a workaround, reserved0 and reserved1 are instead defined here as
00403    * four 32-bit quantities.  This should be harmless, as there are
00404    * currently no known uses for these fields. */
00405   uint32_t             reserved0[2];
00406   uint32_t             reserved1[2];
00407 } MDRawModule;  /* MINIDUMP_MODULE */
00408 
00409 /* The inclusion of a 64-bit type in MINIDUMP_MODULE forces the struct to
00410  * be tail-padded out to a multiple of 64 bits under some ABIs (such as PPC).
00411  * This doesn't occur on systems that don't tail-pad in this manner.  Define
00412  * this macro to be the usable size of the MDRawModule struct, and use it in
00413  * place of sizeof(MDRawModule). */
00414 #define MD_MODULE_SIZE 108
00415 
00416 
00417 /* (MDRawModule).cv_record can reference MDCVInfoPDB20 or MDCVInfoPDB70.
00418  * Ref.: http://www.debuginfo.com/articles/debuginfomatch.html
00419  * MDCVInfoPDB70 is the expected structure type with recent toolchains. */
00420 
00421 typedef struct {
00422   uint32_t signature;
00423   uint32_t offset;     /* Offset to debug data (expect 0 in minidump) */
00424 } MDCVHeader;
00425 
00426 typedef struct {
00427   MDCVHeader cv_header;
00428   uint32_t   signature;         /* time_t debug information created */
00429   uint32_t   age;               /* revision of PDB file */
00430   uint8_t    pdb_file_name[1];  /* Pathname or filename of PDB file */
00431 } MDCVInfoPDB20;
00432 
00433 static const size_t MDCVInfoPDB20_minsize = offsetof(MDCVInfoPDB20,
00434                                                      pdb_file_name[0]);
00435 
00436 #define MD_CVINFOPDB20_SIGNATURE 0x3031424e  /* cvHeader.signature = '01BN' */
00437 
00438 typedef struct {
00439   uint32_t  cv_signature;
00440   MDGUID    signature;         /* GUID, identifies PDB file */
00441   uint32_t  age;               /* Identifies incremental changes to PDB file */
00442   uint8_t   pdb_file_name[1];  /* Pathname or filename of PDB file,
00443                                 * 0-terminated 8-bit character data (UTF-8?) */
00444 } MDCVInfoPDB70;
00445 
00446 static const size_t MDCVInfoPDB70_minsize = offsetof(MDCVInfoPDB70,
00447                                                      pdb_file_name[0]);
00448 
00449 #define MD_CVINFOPDB70_SIGNATURE 0x53445352  /* cvSignature = 'SDSR' */
00450 
00451 typedef struct {
00452   uint32_t data1[2];
00453   uint32_t data2;
00454   uint32_t data3;
00455   uint32_t data4;
00456   uint32_t data5[3];
00457   uint8_t  extra[2];
00458 } MDCVInfoELF;
00459 
00460 /* In addition to the two CodeView record formats above, used for linking
00461  * to external pdb files, it is possible for debugging data to be carried
00462  * directly in the CodeView record itself.  These signature values will
00463  * be found in the first 4 bytes of the CodeView record.  Additional values
00464  * not commonly experienced in the wild are given by "Microsoft Symbol and
00465  * Type Information", http://www.x86.org/ftp/manuals/tools/sym.pdf, section
00466  * 7.2.  An in-depth description of the CodeView 4.1 format is given by
00467  * "Undocumented Windows 2000 Secrets", Windows 2000 Debugging Support/
00468  * Microsoft Symbol File Internals/CodeView Subsections,
00469  * http://www.rawol.com/features/undocumented/sbs-w2k-1-windows-2000-debugging-support.pdf
00470  */
00471 #define MD_CVINFOCV41_SIGNATURE 0x3930424e  /* '90BN', CodeView 4.10. */
00472 #define MD_CVINFOCV50_SIGNATURE 0x3131424e  /* '11BN', CodeView 5.0,
00473                                              * MS C7-format (/Z7). */
00474 
00475 #define MD_CVINFOUNKNOWN_SIGNATURE 0xffffffff  /* An unlikely value. */
00476 
00477 /* (MDRawModule).miscRecord can reference MDImageDebugMisc.  The Windows
00478  * structure is actually defined in WinNT.h.  This structure is effectively
00479  * obsolete with modules built by recent toolchains. */
00480 
00481 typedef struct {
00482   uint32_t  data_type;    /* IMAGE_DEBUG_TYPE_*, not defined here because
00483                            * this debug record type is mostly obsolete. */
00484   uint32_t  length;       /* Length of entire MDImageDebugMisc structure */
00485   uint8_t   unicode;      /* True if data is multibyte */
00486   uint8_t   reserved[3];
00487   uint8_t   data[1];
00488 } MDImageDebugMisc;  /* IMAGE_DEBUG_MISC */
00489 
00490 static const size_t MDImageDebugMisc_minsize = offsetof(MDImageDebugMisc,
00491                                                         data[0]);
00492 
00493 
00494 typedef struct {
00495   uint32_t    number_of_modules;
00496   MDRawModule modules[1];
00497 } MDRawModuleList;  /* MINIDUMP_MODULE_LIST */
00498 
00499 static const size_t MDRawModuleList_minsize = offsetof(MDRawModuleList,
00500                                                        modules[0]);
00501 
00502 
00503 typedef struct {
00504   uint32_t           number_of_memory_ranges;
00505   MDMemoryDescriptor memory_ranges[1];
00506 } MDRawMemoryList;  /* MINIDUMP_MEMORY_LIST */
00507 
00508 static const size_t MDRawMemoryList_minsize = offsetof(MDRawMemoryList,
00509                                                        memory_ranges[0]);
00510 
00511 
00512 #define MD_EXCEPTION_MAXIMUM_PARAMETERS 15
00513 
00514 typedef struct {
00515   uint32_t  exception_code;     /* Windows: MDExceptionCodeWin,
00516                                  * Mac OS X: MDExceptionMac,
00517                                  * Linux: MDExceptionCodeLinux. */
00518   uint32_t  exception_flags;    /* Windows: 1 if noncontinuable,
00519                                    Mac OS X: MDExceptionCodeMac. */
00520   uint64_t  exception_record;   /* Address (in the minidump-producing host's
00521                                  * memory) of another MDException, for
00522                                  * nested exceptions. */
00523   uint64_t  exception_address;  /* The address that caused the exception.
00524                                  * Mac OS X: exception subcode (which is
00525                                  *           typically the address). */
00526   uint32_t  number_parameters;  /* Number of valid elements in
00527                                  * exception_information. */
00528   uint32_t  __align;
00529   uint64_t  exception_information[MD_EXCEPTION_MAXIMUM_PARAMETERS];
00530 } MDException;  /* MINIDUMP_EXCEPTION */
00531 
00532 #include "minidump_exception_linux.h"
00533 #include "minidump_exception_mac.h"
00534 #include "minidump_exception_ps3.h"
00535 #include "minidump_exception_solaris.h"
00536 #include "minidump_exception_win32.h"
00537 
00538 typedef struct {
00539   uint32_t             thread_id;         /* Thread in which the exception
00540                                            * occurred.  Corresponds to
00541                                            * (MDRawThread).thread_id. */
00542   uint32_t             __align;
00543   MDException          exception_record;
00544   MDLocationDescriptor thread_context;    /* MDRawContext[CPU] */
00545 } MDRawExceptionStream;  /* MINIDUMP_EXCEPTION_STREAM */
00546 
00547 
00548 typedef union {
00549   struct {
00550     uint32_t vendor_id[3];               /* cpuid 0: ebx, edx, ecx */
00551     uint32_t version_information;        /* cpuid 1: eax */
00552     uint32_t feature_information;        /* cpuid 1: edx */
00553     uint32_t amd_extended_cpu_features;  /* cpuid 0x80000001, ebx */
00554   } x86_cpu_info;
00555   struct {
00556     uint32_t cpuid;
00557     uint32_t elf_hwcaps;    /* linux specific, 0 otherwise */
00558   } arm_cpu_info;
00559   struct {
00560     uint64_t processor_features[2];
00561   } other_cpu_info;
00562 } MDCPUInformation;  /* CPU_INFORMATION */
00563 
00564 /* For (MDCPUInformation).arm_cpu_info.elf_hwcaps.
00565  * This matches the Linux kernel definitions from <asm/hwcaps.h> */
00566 typedef enum {
00567   MD_CPU_ARM_ELF_HWCAP_SWP       = (1 << 0),
00568   MD_CPU_ARM_ELF_HWCAP_HALF      = (1 << 1),
00569   MD_CPU_ARM_ELF_HWCAP_THUMB     = (1 << 2),
00570   MD_CPU_ARM_ELF_HWCAP_26BIT     = (1 << 3),
00571   MD_CPU_ARM_ELF_HWCAP_FAST_MULT = (1 << 4),
00572   MD_CPU_ARM_ELF_HWCAP_FPA       = (1 << 5),
00573   MD_CPU_ARM_ELF_HWCAP_VFP       = (1 << 6),
00574   MD_CPU_ARM_ELF_HWCAP_EDSP      = (1 << 7),
00575   MD_CPU_ARM_ELF_HWCAP_JAVA      = (1 << 8),
00576   MD_CPU_ARM_ELF_HWCAP_IWMMXT    = (1 << 9),
00577   MD_CPU_ARM_ELF_HWCAP_CRUNCH    = (1 << 10),
00578   MD_CPU_ARM_ELF_HWCAP_THUMBEE   = (1 << 11),
00579   MD_CPU_ARM_ELF_HWCAP_NEON      = (1 << 12),
00580   MD_CPU_ARM_ELF_HWCAP_VFPv3     = (1 << 13),
00581   MD_CPU_ARM_ELF_HWCAP_VFPv3D16  = (1 << 14),
00582   MD_CPU_ARM_ELF_HWCAP_TLS       = (1 << 15),
00583   MD_CPU_ARM_ELF_HWCAP_VFPv4     = (1 << 16),
00584   MD_CPU_ARM_ELF_HWCAP_IDIVA     = (1 << 17),
00585   MD_CPU_ARM_ELF_HWCAP_IDIVT     = (1 << 18),
00586 } MDCPUInformationARMElfHwCaps;
00587 
00588 typedef struct {
00589   /* The next 3 fields and numberOfProcessors are from the SYSTEM_INFO
00590    * structure as returned by GetSystemInfo */
00591   uint16_t         processor_architecture;
00592   uint16_t         processor_level;         /* x86: 5 = 586, 6 = 686, ... */
00593                                             /* ARM: 6 = ARMv6, 7 = ARMv7 ... */
00594   uint16_t         processor_revision;      /* x86: 0xMMSS, where MM=model,
00595                                              *      SS=stepping */
00596                                             /* ARM: 0 */
00597 
00598   uint8_t          number_of_processors;
00599   uint8_t          product_type;            /* Windows: VER_NT_* from WinNT.h */
00600 
00601   /* The next 5 fields are from the OSVERSIONINFO structure as returned
00602    * by GetVersionEx */
00603   uint32_t         major_version;
00604   uint32_t         minor_version;
00605   uint32_t         build_number;
00606   uint32_t         platform_id;
00607   MDRVA            csd_version_rva;  /* MDString further identifying the
00608                                       * host OS.
00609                                       * Windows: name of the installed OS
00610                                       *          service pack.
00611                                       * Mac OS X: the Apple OS build number
00612                                       *           (sw_vers -buildVersion).
00613                                       * Linux: uname -srvmo */
00614 
00615   uint16_t         suite_mask;       /* Windows: VER_SUITE_* from WinNT.h */
00616   uint16_t         reserved2;
00617 
00618   MDCPUInformation cpu;
00619 } MDRawSystemInfo;  /* MINIDUMP_SYSTEM_INFO */
00620 
00621 /* For (MDRawSystemInfo).processor_architecture: */
00622 typedef enum {
00623   MD_CPU_ARCHITECTURE_X86       =  0,  /* PROCESSOR_ARCHITECTURE_INTEL */
00624   MD_CPU_ARCHITECTURE_MIPS      =  1,  /* PROCESSOR_ARCHITECTURE_MIPS */
00625   MD_CPU_ARCHITECTURE_ALPHA     =  2,  /* PROCESSOR_ARCHITECTURE_ALPHA */
00626   MD_CPU_ARCHITECTURE_PPC       =  3,  /* PROCESSOR_ARCHITECTURE_PPC */
00627   MD_CPU_ARCHITECTURE_SHX       =  4,  /* PROCESSOR_ARCHITECTURE_SHX
00628                                         * (Super-H) */
00629   MD_CPU_ARCHITECTURE_ARM       =  5,  /* PROCESSOR_ARCHITECTURE_ARM */
00630   MD_CPU_ARCHITECTURE_IA64      =  6,  /* PROCESSOR_ARCHITECTURE_IA64 */
00631   MD_CPU_ARCHITECTURE_ALPHA64   =  7,  /* PROCESSOR_ARCHITECTURE_ALPHA64 */
00632   MD_CPU_ARCHITECTURE_MSIL      =  8,  /* PROCESSOR_ARCHITECTURE_MSIL
00633                                         * (Microsoft Intermediate Language) */
00634   MD_CPU_ARCHITECTURE_AMD64     =  9,  /* PROCESSOR_ARCHITECTURE_AMD64 */
00635   MD_CPU_ARCHITECTURE_X86_WIN64 = 10,
00636       /* PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 (WoW64) */
00637   MD_CPU_ARCHITECTURE_SPARC     = 0x8001, /* Breakpad-defined value for SPARC */
00638   MD_CPU_ARCHITECTURE_PPC64     = 0x8002, /* Breakpad-defined value for PPC64 */
00639   MD_CPU_ARCHITECTURE_UNKNOWN   = 0xffff  /* PROCESSOR_ARCHITECTURE_UNKNOWN */
00640 } MDCPUArchitecture;
00641 
00642 /* For (MDRawSystemInfo).platform_id: */
00643 typedef enum {
00644   MD_OS_WIN32S        = 0,  /* VER_PLATFORM_WIN32s (Windows 3.1) */
00645   MD_OS_WIN32_WINDOWS = 1,  /* VER_PLATFORM_WIN32_WINDOWS (Windows 95-98-Me) */
00646   MD_OS_WIN32_NT      = 2,  /* VER_PLATFORM_WIN32_NT (Windows NT, 2000+) */
00647   MD_OS_WIN32_CE      = 3,  /* VER_PLATFORM_WIN32_CE, VER_PLATFORM_WIN32_HH
00648                              * (Windows CE, Windows Mobile, "Handheld") */
00649 
00650   /* The following values are Breakpad-defined. */
00651   MD_OS_UNIX          = 0x8000,  /* Generic Unix-ish */
00652   MD_OS_MAC_OS_X      = 0x8101,  /* Mac OS X/Darwin */
00653   MD_OS_IOS           = 0x8102,  /* iOS */
00654   MD_OS_LINUX         = 0x8201,  /* Linux */
00655   MD_OS_SOLARIS       = 0x8202,  /* Solaris */
00656   MD_OS_ANDROID       = 0x8203,  /* Android */
00657   MD_OS_PS3           = 0x8204,  /* PS3 */
00658   MD_OS_NACL          = 0x8205   /* Native Client (NaCl) */
00659 } MDOSPlatform;
00660 
00661 typedef struct {
00662   uint16_t year;
00663   uint16_t month;
00664   uint16_t day_of_week;
00665   uint16_t day;
00666   uint16_t hour;
00667   uint16_t minute;
00668   uint16_t second;
00669   uint16_t milliseconds;
00670 } MDSystemTime;  /* SYSTEMTIME */
00671 
00672 typedef struct {
00673   /* Required field.  The bias is the difference, in minutes, between
00674    * Coordinated Universal Time (UTC) and local time.
00675    *   Formula: UTC = local time + bias */
00676   int32_t bias;
00677   /* A description for standard time.  For example, "EST" could indicate Eastern
00678    * Standard Time.  In practice this contains the full time zone names.  This
00679    * string can be empty. */
00680   uint16_t standard_name[32];  /* UTF-16-encoded, 0-terminated */
00681   /* A MDSystemTime structure that contains a date and local time when the
00682    * transition from daylight saving time to standard time occurs on this
00683    * operating system.  If the time zone does not support daylight saving time, 
00684    * the month member in the MDSystemTime structure is zero. */
00685   MDSystemTime standard_date;
00686   /* The bias value to be used during local time translations that occur during
00687    * standard time. */
00688   int32_t standard_bias;
00689   /* A description for daylight saving time.  For example, "PDT" could indicate
00690    * Pacific Daylight Time.  In practice this contains the full time zone names.
00691    * This string can be empty. */
00692   uint16_t daylight_name[32];  /* UTF-16-encoded, 0-terminated */
00693   /* A MDSystemTime structure that contains a date and local time when the
00694    * transition from standard time to daylight saving time occurs on this
00695    * operating system.  If the time zone does not support daylight saving time, 
00696    * the month member in the MDSystemTime structure is zero.*/
00697   MDSystemTime daylight_date;
00698   /* The bias value to be used during local time translations that occur during
00699    * daylight saving time. */
00700   int32_t daylight_bias;
00701 } MDTimeZoneInformation;  /* TIME_ZONE_INFORMATION */
00702 
00703 /* MAX_PATH from windef.h */
00704 #define MD_MAX_PATH 260
00705 
00706 /* The miscellaneous information stream contains a variety
00707  * of small pieces of information.  A member is valid if
00708  * it's within the available size and its corresponding
00709  * bit is set. */
00710 typedef struct {
00711   uint32_t size_of_info;  /* Length of entire MDRawMiscInfo structure. */
00712   uint32_t flags1;
00713 
00714   /* The next field is only valid if flags1 contains
00715    * MD_MISCINFO_FLAGS1_PROCESS_ID. */
00716   uint32_t process_id;
00717 
00718   /* The next 3 fields are only valid if flags1 contains
00719    * MD_MISCINFO_FLAGS1_PROCESS_TIMES. */
00720   uint32_t process_create_time;  /* time_t process started */
00721   uint32_t process_user_time;    /* seconds of user CPU time */
00722   uint32_t process_kernel_time;  /* seconds of kernel CPU time */
00723 
00724   /* The following fields are not present in MINIDUMP_MISC_INFO but are
00725    * in MINIDUMP_MISC_INFO_2.  When this struct is populated, these value
00726    * may not be set.  Use flags1 or size_of_info to determine whether these
00727    * values are present.  These are only valid when flags1 contains
00728    * MD_MISCINFO_FLAGS1_PROCESSOR_POWER_INFO. */
00729   uint32_t processor_max_mhz;
00730   uint32_t processor_current_mhz;
00731   uint32_t processor_mhz_limit;
00732   uint32_t processor_max_idle_state;
00733   uint32_t processor_current_idle_state;
00734 
00735   /* The following fields are not present in MINIDUMP_MISC_INFO_2 but are
00736    * in MINIDUMP_MISC_INFO_3.  When this struct is populated, these value
00737    * may not be set.  Use flags1 or size_of_info to determine whether these
00738    * values are present. */
00739    
00740   /* The following field is only valid if flags1 contains
00741    * MD_MISCINFO_FLAGS1_PROCESS_INTEGRITY. */
00742   uint32_t process_integrity_level;
00743 
00744   /* The following field is only valid if flags1 contains
00745    * MD_MISCINFO_FLAGS1_PROCESS_EXECUTE_FLAGS. */
00746   uint32_t process_execute_flags;
00747 
00748   /* The following field is only valid if flags1 contains
00749    * MD_MISCINFO_FLAGS1_PROTECTED_PROCESS. */
00750   uint32_t protected_process;
00751 
00752   /* The following 2 fields are only valid if flags1 contains
00753    * MD_MISCINFO_FLAGS1_TIMEZONE. */
00754   uint32_t time_zone_id;
00755   MDTimeZoneInformation time_zone;
00756 
00757   /* The following fields are not present in MINIDUMP_MISC_INFO_3 but are
00758    * in MINIDUMP_MISC_INFO_4.  When this struct is populated, these value
00759    * may not be set.  Use size_of_info to determine whether these values are 
00760    * present. */
00761 
00762   /* The following 2 fields are only valid if
00763    * size_of_info is >= MD_MISCINFO4_SIZE */
00764   uint16_t build_string[MD_MAX_PATH];  /* UTF-16-encoded, 0-terminated */
00765   uint16_t dbg_bld_str[40];            /* UTF-16-encoded, 0-terminated */
00766 } MDRawMiscInfo;  /* MINIDUMP_MISC_INFO, MINIDUMP_MISC_INFO2,
00767                    * MINIDUMP_MISC_INFO3, MINIDUMP_MISC_INFO4 */
00768 
00769 static const size_t MD_MISCINFO_SIZE =
00770     offsetof(MDRawMiscInfo, processor_max_mhz);
00771 static const size_t MD_MISCINFO2_SIZE =
00772     offsetof(MDRawMiscInfo, process_integrity_level);
00773 static const size_t MD_MISCINFO3_SIZE =
00774     offsetof(MDRawMiscInfo, build_string[0]);
00775 static const size_t MD_MISCINFO4_SIZE = sizeof(MDRawMiscInfo);
00776 
00777 /* For (MDRawMiscInfo).flags1.  These values indicate which fields in the
00778  * MDRawMiscInfoStructure are valid. */
00779 typedef enum {
00780   MD_MISCINFO_FLAGS1_PROCESS_ID            = 0x00000001,
00781       /* MINIDUMP_MISC1_PROCESS_ID */
00782   MD_MISCINFO_FLAGS1_PROCESS_TIMES         = 0x00000002,
00783       /* MINIDUMP_MISC1_PROCESS_TIMES */
00784   MD_MISCINFO_FLAGS1_PROCESSOR_POWER_INFO  = 0x00000004,
00785       /* MINIDUMP_MISC1_PROCESSOR_POWER_INFO */
00786   MD_MISCINFO_FLAGS1_PROCESS_INTEGRITY     = 0x00000010,
00787       /* MINIDUMP_MISC3_PROCESS_INTEGRITY */
00788   MD_MISCINFO_FLAGS1_PROCESS_EXECUTE_FLAGS = 0x00000020,
00789       /* MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS */
00790   MD_MISCINFO_FLAGS1_TIMEZONE              = 0x00000040,
00791       /* MINIDUMP_MISC3_TIMEZONE */
00792   MD_MISCINFO_FLAGS1_PROTECTED_PROCESS     = 0x00000080,
00793       /* MINIDUMP_MISC3_PROTECTED_PROCESS */
00794 } MDMiscInfoFlags1;
00795 
00796 /*
00797  * Around DbgHelp version 6.0, the style of new LIST structures changed
00798  * from including an array of length 1 at the end of the struct to
00799  * represent the variable-length data to including explicit
00800  * "size of header", "size of entry" and "number of entries" fields
00801  * in the header, presumably to allow backwards-compatibly-extending
00802  * the structures in the future. The actual list entries follow the
00803  * header data directly in this case.
00804  */
00805 
00806 typedef struct {
00807   uint32_t size_of_header;    /* sizeof(MDRawMemoryInfoList) */
00808   uint32_t size_of_entry;     /* sizeof(MDRawMemoryInfo) */
00809   uint64_t number_of_entries;
00810 } MDRawMemoryInfoList;  /* MINIDUMP_MEMORY_INFO_LIST */
00811 
00812 typedef struct {
00813   uint64_t  base_address;           /* Base address of a region of pages */
00814   uint64_t  allocation_base;        /* Base address of a range of pages
00815                                      * within this region. */
00816   uint32_t  allocation_protection;  /* Memory protection when this region
00817                                      * was originally allocated:
00818                                      * MDMemoryProtection */
00819   uint32_t  __alignment1;
00820   uint64_t  region_size;
00821   uint32_t  state;                  /* MDMemoryState */
00822   uint32_t  protection;             /* MDMemoryProtection */
00823   uint32_t  type;                   /* MDMemoryType */
00824   uint32_t  __alignment2;
00825 } MDRawMemoryInfo;  /* MINIDUMP_MEMORY_INFO */
00826 
00827 /* For (MDRawMemoryInfo).state */
00828 typedef enum {
00829   MD_MEMORY_STATE_COMMIT   = 0x1000,  /* physical storage has been allocated */
00830   MD_MEMORY_STATE_RESERVE  = 0x2000,  /* reserved, but no physical storage */
00831   MD_MEMORY_STATE_FREE     = 0x10000  /* available to be allocated */
00832 } MDMemoryState;
00833 
00834 /* For (MDRawMemoryInfo).allocation_protection and .protection */
00835 typedef enum {
00836   MD_MEMORY_PROTECT_NOACCESS          = 0x01,  /* PAGE_NOACCESS */
00837   MD_MEMORY_PROTECT_READONLY          = 0x02,  /* PAGE_READONLY */
00838   MD_MEMORY_PROTECT_READWRITE         = 0x04,  /* PAGE_READWRITE */
00839   MD_MEMORY_PROTECT_WRITECOPY         = 0x08,  /* PAGE_WRITECOPY */
00840   MD_MEMORY_PROTECT_EXECUTE           = 0x10,  /* PAGE_EXECUTE */
00841   MD_MEMORY_PROTECT_EXECUTE_READ      = 0x20,  /* PAGE_EXECUTE_READ */
00842   MD_MEMORY_PROTECT_EXECUTE_READWRITE = 0x40,  /* PAGE_EXECUTE_READWRITE */
00843   MD_MEMORY_PROTECT_EXECUTE_WRITECOPY = 0x80,  /* PAGE_EXECUTE_WRITECOPY */
00844   /* These options can be combined with the previous flags. */
00845   MD_MEMORY_PROTECT_GUARD             = 0x100,  /* PAGE_GUARD */
00846   MD_MEMORY_PROTECT_NOCACHE           = 0x200,  /* PAGE_NOCACHE */
00847   MD_MEMORY_PROTECT_WRITECOMBINE      = 0x400,  /* PAGE_WRITECOMBINE */
00848 } MDMemoryProtection;
00849 
00850 /* Used to mask the mutually exclusive options from the combinable flags. */
00851 const uint32_t MD_MEMORY_PROTECTION_ACCESS_MASK = 0xFF;
00852 
00853 /* For (MDRawMemoryInfo).type */
00854 typedef enum {
00855   MD_MEMORY_TYPE_PRIVATE = 0x20000,   /* not shared by other processes */
00856   MD_MEMORY_TYPE_MAPPED  = 0x40000,   /* mapped into the view of a section */
00857   MD_MEMORY_TYPE_IMAGE   = 0x1000000  /* mapped into the view of an image */
00858 } MDMemoryType;
00859 
00860 /*
00861  * Breakpad extension types
00862  */
00863 
00864 
00865 typedef struct {
00866   /* validity is a bitmask with values from MDBreakpadInfoValidity, indicating
00867    * which of the other fields in the structure are valid. */
00868   uint32_t validity;
00869 
00870   /* Thread ID of the handler thread.  dump_thread_id should correspond to
00871    * the thread_id of an MDRawThread in the minidump's MDRawThreadList if
00872    * a dedicated thread in that list was used to produce the minidump.  If
00873    * the MDRawThreadList does not contain a dedicated thread used to produce
00874    * the minidump, this field should be set to 0 and the validity field
00875    * must not contain MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID. */
00876   uint32_t dump_thread_id;
00877 
00878   /* Thread ID of the thread that requested the minidump be produced.  As
00879    * with dump_thread_id, requesting_thread_id should correspond to the
00880    * thread_id of an MDRawThread in the minidump's MDRawThreadList.  For
00881    * minidumps produced as a result of an exception, requesting_thread_id
00882    * will be the same as the MDRawExceptionStream's thread_id field.  For
00883    * minidumps produced "manually" at the program's request,
00884    * requesting_thread_id will indicate which thread caused the dump to be
00885    * written.  If the minidump was produced at the request of something
00886    * other than a thread in the MDRawThreadList, this field should be set
00887    * to 0 and the validity field must not contain
00888    * MD_BREAKPAD_INFO_VALID_REQUESTING_THREAD_ID. */
00889   uint32_t requesting_thread_id;
00890 } MDRawBreakpadInfo;
00891 
00892 /* For (MDRawBreakpadInfo).validity: */
00893 typedef enum {
00894   /* When set, the dump_thread_id field is valid. */
00895   MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID       = 1 << 0,
00896 
00897   /* When set, the requesting_thread_id field is valid. */
00898   MD_BREAKPAD_INFO_VALID_REQUESTING_THREAD_ID = 1 << 1
00899 } MDBreakpadInfoValidity;
00900 
00901 typedef struct {
00902   /* expression, function, and file are 0-terminated UTF-16 strings.  They
00903    * may be truncated if necessary, but should always be 0-terminated when
00904    * written to a file.
00905    * Fixed-length strings are used because MiniDumpWriteDump doesn't offer
00906    * a way for user streams to point to arbitrary RVAs for strings. */
00907   uint16_t expression[128];  /* Assertion that failed... */
00908   uint16_t function[128];    /* ...within this function... */
00909   uint16_t file[128];        /* ...in this file... */
00910   uint32_t line;             /* ...at this line. */
00911   uint32_t type;
00912 } MDRawAssertionInfo;
00913 
00914 /* For (MDRawAssertionInfo).type: */
00915 typedef enum {
00916   MD_ASSERTION_INFO_TYPE_UNKNOWN = 0,
00917 
00918   /* Used for assertions that would be raised by the MSVC CRT but are
00919    * directed to an invalid parameter handler instead. */
00920   MD_ASSERTION_INFO_TYPE_INVALID_PARAMETER,
00921 
00922   /* Used for assertions that would be raised by the MSVC CRT but are
00923    * directed to a pure virtual call handler instead. */
00924   MD_ASSERTION_INFO_TYPE_PURE_VIRTUAL_CALL
00925 } MDAssertionInfoData;
00926 
00927 /* These structs are used to store the DSO debug data in Linux minidumps,
00928  * which is necessary for converting minidumps to usable coredumps. */
00929 typedef struct {
00930   void*     addr;
00931   MDRVA     name;
00932   void*     ld;
00933 } MDRawLinkMap;
00934 
00935 typedef struct {
00936   uint32_t  version;
00937   MDRVA     map;
00938   uint32_t  dso_count;
00939   void*     brk;
00940   void*     ldbase;
00941   void*     dynamic;
00942 } MDRawDebug;
00943 
00944 #if defined(_MSC_VER)
00945 #pragma warning(pop)
00946 #endif  /* _MSC_VER */
00947 
00948 
00949 #endif  /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__ */