chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h

/* Copyright 2006 Google LLC
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google LLC nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

/* minidump_format.h: A cross-platform reimplementation of minidump-related
 * portions of DbgHelp.h from the Windows Platform SDK.
 *
 * (This is C99 source, please don't corrupt it with C++.)
 *
 * Structures that are defined by Microsoft to contain a zero-length array
 * are instead defined here to contain an array with one element, as
 * zero-length arrays are forbidden by standard C and C++.  In these cases,
 * *_minsize constants are provided to be used in place of sizeof.  For a
 * cleaner interface to these sizes when using C++, see minidump_size.h.
 *
 * These structures are also sufficient to populate minidump files.
 *
 * These definitions may be extended to support handling minidump files
 * for other CPUs and other operating systems.
 *
 * Because precise data type sizes are crucial for this implementation to
 * function properly and portably in terms of interoperability with minidumps
 * produced by DbgHelp on Windows, a set of primitive types with known sizes
 * are used as the basis of each structure defined by this file.  DbgHelp
 * on Windows is assumed to be the reference implementation; this file
 * seeks to provide a cross-platform compatible implementation.  To avoid
 * collisions with the types and values defined and used by DbgHelp in the
 * event that this implementation is used on Windows, each type and value
 * defined here is given a new name, beginning with "MD".  Names of the
 * equivalent types and values in the Windows Platform SDK are given in
 * comments.
 *
 * Author: Mark Mentovai */


#ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__
#define GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__

#include <stddef.h>

#include "google_breakpad/common/breakpad_types.h"


#if defined(_MSC_VER)
/* Disable "zero-sized array in struct/union" warnings when compiling in
 * MSVC.  DbgHelp.h does this too. */
#pragma warning(push)
#pragma warning(disable:4200)
#endif  /* _MSC_VER */


/*
 * guiddef.h
 */

MDGUID;  /* GUID */


/*
 * WinNT.h
 */

/* Non-x86 CPU identifiers found in the high 24 bits of
 * (MDRawContext*).context_flags.  These aren't used by Breakpad, but are
 * defined here for reference, to avoid assigning values that conflict
 * (although some values already conflict). */
#define MD_CONTEXT_IA64
/* Additional values from winnt.h in the Windows CE 5.0 SDK: */
#define MD_CONTEXT_SHX
#define MD_CONTEXT_ALPHA

/* As of Windows 7 SP1, the number of flag bits has increased to
 * include 0x40 (CONTEXT_XSTATE):
 * http://msdn.microsoft.com/en-us/library/hh134238%28v=vs.85%29.aspx */
#define MD_CONTEXT_CPU_MASK


/* This is a base type for MDRawContextX86 and MDRawContextPPC.  This
 * structure should never be allocated directly.  The actual structure type
 * can be determined by examining the context_flags field. */
MDRawContextBase;

#include "minidump_cpu_amd64.h"
#include "minidump_cpu_arm.h"
#include "minidump_cpu_arm64.h"
#include "minidump_cpu_mips.h"
#include "minidump_cpu_ppc.h"
#include "minidump_cpu_ppc64.h"
#include "minidump_cpu_riscv.h"
#include "minidump_cpu_sparc.h"
#include "minidump_cpu_x86.h"

/*
 * WinVer.h
 */


MDVSFixedFileInfo;  /* VS_FIXEDFILEINFO */

/* For (MDVSFixedFileInfo).signature */
#define MD_VSFIXEDFILEINFO_SIGNATURE
     /* VS_FFI_SIGNATURE */

/* For (MDVSFixedFileInfo).version */
#define MD_VSFIXEDFILEINFO_VERSION
     /* VS_FFI_STRUCVERSION */

/* For (MDVSFixedFileInfo).file_flags_mask and
 * (MDVSFixedFileInfo).file_flags */
#define MD_VSFIXEDFILEINFO_FILE_FLAGS_DEBUG
     /* VS_FF_DEBUG */
#define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRERELEASE
     /* VS_FF_PRERELEASE */
#define MD_VSFIXEDFILEINFO_FILE_FLAGS_PATCHED
     /* VS_FF_PATCHED */
#define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRIVATEBUILD
     /* VS_FF_PRIVATEBUILD */
#define MD_VSFIXEDFILEINFO_FILE_FLAGS_INFOINFERRED
     /* VS_FF_INFOINFERRED */
#define MD_VSFIXEDFILEINFO_FILE_FLAGS_SPECIALBUILD
     /* VS_FF_SPECIALBUILD */

/* For (MDVSFixedFileInfo).file_os: high 16 bits */
#define MD_VSFIXEDFILEINFO_FILE_OS_UNKNOWN
#define MD_VSFIXEDFILEINFO_FILE_OS_DOS
#define MD_VSFIXEDFILEINFO_FILE_OS_OS216
#define MD_VSFIXEDFILEINFO_FILE_OS_OS232
#define MD_VSFIXEDFILEINFO_FILE_OS_NT
#define MD_VSFIXEDFILEINFO_FILE_OS_WINCE
/* Low 16 bits */
#define MD_VSFIXEDFILEINFO_FILE_OS__BASE
#define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS16
#define MD_VSFIXEDFILEINFO_FILE_OS__PM16
#define MD_VSFIXEDFILEINFO_FILE_OS__PM32
#define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS32

/* For (MDVSFixedFileInfo).file_type */
#define MD_VSFIXEDFILEINFO_FILE_TYPE_UNKNOWN
#define MD_VSFIXEDFILEINFO_FILE_TYPE_APP
#define MD_VSFIXEDFILEINFO_FILE_TYPE_DLL
#define MD_VSFIXEDFILEINFO_FILE_TYPE_DRV
#define MD_VSFIXEDFILEINFO_FILE_TYPE_FONT
#define MD_VSFIXEDFILEINFO_FILE_TYPE_VXD
#define MD_VSFIXEDFILEINFO_FILE_TYPE_STATIC_LIB

/* For (MDVSFixedFileInfo).file_subtype */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_UNKNOWN
     /* VFT2_UNKNOWN */
/* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_DRV */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_PRINTER
     /* VFT2_DRV_PRINTER */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_KEYBOARD
     /* VFT2_DRV_KEYBOARD */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_LANGUAGE
     /* VFT2_DRV_LANGUAGE */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_DISPLAY
     /* VFT2_DRV_DISPLAY */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_MOUSE
     /* VFT2_DRV_MOUSE */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_NETWORK
     /* VFT2_DRV_NETWORK */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SYSTEM
     /* VFT2_DRV_SYSTEM */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INSTALLABLE
     /* VFT2_DRV_INSTALLABLE */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SOUND
     /* VFT2_DRV_SOUND */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_COMM
     /* VFT2_DRV_COMM */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INPUTMETHOD
     /* VFT2_DRV_INPUTMETHOD */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_VERSIONED_PRINTER
     /* VFT2_DRV_VERSIONED_PRINTER */
/* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_FONT */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_RASTER
     /* VFT2_FONT_RASTER */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_VECTOR
     /* VFT2_FONT_VECTOR */
#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_TRUETYPE
     /* VFT2_FONT_TRUETYPE */


/*
 * DbgHelp.h
 */


/* An MDRVA is an offset into the minidump file.  The beginning of the
 * MDRawHeader is at offset 0. */
MDRVA;  /* RVA */

MDLocationDescriptor;  /* MINIDUMP_LOCATION_DESCRIPTOR */

/* An MDRVA64 is an 64-bit offset into the minidump file.  The beginning of the
 * MDRawHeader is at offset 0. */
MDRVA64; /* RVA64 */

MDLocationDescriptor64; /* MINIDUMP_LOCATION_DESCRIPTOR64 */


MDMemoryDescriptor;  /* MINIDUMP_MEMORY_DESCRIPTOR */


MDRawHeader;  /* MINIDUMP_HEADER */

/* For (MDRawHeader).signature and (MDRawHeader).version.  Note that only the
 * low 16 bits of (MDRawHeader).version are MD_HEADER_VERSION.  Per the
 * documentation, the high 16 bits are implementation-specific. */
#define MD_HEADER_SIGNATURE
     /* MINIDUMP_SIGNATURE */
#define MD_HEADER_VERSION
     /* MINIDUMP_VERSION */

/* For (MDRawHeader).flags: */
MDType;  /* MINIDUMP_TYPE */


MDRawDirectory;  /* MINIDUMP_DIRECTORY */

/* For (MDRawDirectory).stream_type */
MDStreamType;  /* MINIDUMP_STREAM_TYPE */


MDString;  /* MINIDUMP_STRING */

static const size_t MDString_minsize =;


MDRawThread;  /* MINIDUMP_THREAD */


MDRawThreadList;  /* MINIDUMP_THREAD_LIST */

static const size_t MDRawThreadList_minsize =;

#pragma pack(push, 4)
MDRawThreadName;         /* MINIDUMP_THREAD_NAME */

MDRawThreadNameList; /* MINIDUMP_THREAD_NAME_LIST */
#pragma pack(pop)

static const size_t MDRawThreadNameList_minsize =;

MDRawModule;  /* MINIDUMP_MODULE */

/* The inclusion of a 64-bit type in MINIDUMP_MODULE forces the struct to
 * be tail-padded out to a multiple of 64 bits under some ABIs (such as PPC).
 * This doesn't occur on systems that don't tail-pad in this manner.  Define
 * this macro to be the usable size of the MDRawModule struct, and use it in
 * place of sizeof(MDRawModule). */
#define MD_MODULE_SIZE


/* (MDRawModule).cv_record can reference MDCVInfoPDB20 or MDCVInfoPDB70.
 * Ref.: http://www.debuginfo.com/articles/debuginfomatch.html
 * MDCVInfoPDB70 is the expected structure type with recent toolchains. */

MDCVHeader;

MDCVInfoPDB20;

static const size_t MDCVInfoPDB20_minsize =;

#define MD_CVINFOPDB20_SIGNATURE

MDCVInfoPDB70;

static const size_t MDCVInfoPDB70_minsize =;

#define MD_CVINFOPDB70_SIGNATURE

/*
 * Modern ELF toolchains insert a "build id" into the ELF headers that
 * usually contains a hash of some ELF headers + sections to uniquely
 * identify a binary.
 *
 * https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Developer_Guide/compiling-build-id.html
 * https://sourceware.org/binutils/docs-2.26/ld/Options.html#index-g_t_002d_002dbuild_002did-292
 */
MDCVInfoELF;

static const size_t MDCVInfoELF_minsize =;

#define MD_CVINFOELF_SIGNATURE

/* In addition to the two CodeView record formats above, used for linking
 * to external pdb files, it is possible for debugging data to be carried
 * directly in the CodeView record itself.  These signature values will
 * be found in the first 4 bytes of the CodeView record.  Additional values
 * not commonly experienced in the wild are given by "Microsoft Symbol and
 * Type Information", http://www.x86.org/ftp/manuals/tools/sym.pdf, section
 * 7.2.  An in-depth description of the CodeView 4.1 format is given by
 * "Undocumented Windows 2000 Secrets", Windows 2000 Debugging Support/
 * Microsoft Symbol File Internals/CodeView Subsections,
 * http://www.rawol.com/features/undocumented/sbs-w2k-1-windows-2000-debugging-support.pdf
 */
#define MD_CVINFOCV41_SIGNATURE
#define MD_CVINFOCV50_SIGNATURE

#define MD_CVINFOUNKNOWN_SIGNATURE

/* (MDRawModule).miscRecord can reference MDImageDebugMisc.  The Windows
 * structure is actually defined in WinNT.h.  This structure is effectively
 * obsolete with modules built by recent toolchains. */

MDImageDebugMisc;  /* IMAGE_DEBUG_MISC */

static const size_t MDImageDebugMisc_minsize =;


MDRawModuleList;  /* MINIDUMP_MODULE_LIST */

static const size_t MDRawModuleList_minsize =;


MDRawMemoryList;  /* MINIDUMP_MEMORY_LIST */

static const size_t MDRawMemoryList_minsize =;


#define MD_EXCEPTION_MAXIMUM_PARAMETERS

MDException;  /* MINIDUMP_EXCEPTION */

#include "minidump_exception_fuchsia.h"
#include "minidump_exception_linux.h"
#include "minidump_exception_mac.h"
#include "minidump_exception_ps3.h"
#include "minidump_exception_solaris.h"
#include "minidump_exception_win32.h"

MDRawExceptionStream;  /* MINIDUMP_EXCEPTION_STREAM */


MDCPUInformation;  /* CPU_INFORMATION */

/* For (MDCPUInformation).arm_cpu_info.elf_hwcaps.
 * This matches the Linux kernel definitions from <asm/hwcaps.h> */
MDCPUInformationARMElfHwCaps;

MDRawSystemInfo;  /* MINIDUMP_SYSTEM_INFO */

/* For (MDRawSystemInfo).processor_architecture: */
MDCPUArchitecture;

/* For (MDRawSystemInfo).platform_id: */
MDOSPlatform;

MDRawUnloadedModule;

MDRawUnloadedModuleList;  /* MINIDUMP_UNLOADED_MODULE_LIST */

MDSystemTime;  /* SYSTEMTIME */

MDTimeZoneInformation;  /* TIME_ZONE_INFORMATION */

/* MAX_PATH from windef.h */
#define MD_MAX_PATH

/* For MDXStateConfigFeatureMscInfo.features */
MDXStateFeature;

/* For MDXStateConfigFeatureMscInfo.enabled_features from winnt.h */
MDXStateFeatureFlag;

/* MAXIMUM_XSTATE_FEATURES from winnt.h */
#define MD_MAXIMUM_XSTATE_FEATURES

/* For MDRawMiscInfo.xstate_data */
MDXStateConfigFeatureMscInfo;


/* The miscellaneous information stream contains a variety
 * of small pieces of information.  A member is valid if
 * it's within the available size and its corresponding
 * bit is set. */
MDRawMiscInfo;  /* MINIDUMP_MISC_INFO, MINIDUMP_MISC_INFO_2,
                   * MINIDUMP_MISC_INFO_3, MINIDUMP_MISC_INFO_4,
                   * MINIDUMP_MISC_INFO_5, MINIDUMP_MISC_INFO_N */

static const size_t MD_MISCINFO_SIZE =;
static const size_t MD_MISCINFO2_SIZE =;
static const size_t MD_MISCINFO3_SIZE =;
static const size_t MD_MISCINFO4_SIZE =;
/* Version 5 of the MDRawMiscInfo structure is not a multiple of 8 in size and
 * yet it contains some 8-bytes sized fields. This causes many compilers to
 * round the structure size up to a multiple of 8 by adding padding at the end.
 * The following hack is thus required for matching the proper on-disk size. */
static const size_t MD_MISCINFO5_SIZE =;

/* For (MDRawMiscInfo).flags1.  These values indicate which fields in the
 * MDRawMiscInfoStructure are valid. */
MDMiscInfoFlags1;

/*
 * Around DbgHelp version 6.0, the style of new LIST structures changed
 * from including an array of length 1 at the end of the struct to
 * represent the variable-length data to including explicit
 * "size of header", "size of entry" and "number of entries" fields
 * in the header, presumably to allow backwards-compatibly-extending
 * the structures in the future. The actual list entries follow the
 * header data directly in this case.
 */

MDRawMemoryInfoList;  /* MINIDUMP_MEMORY_INFO_LIST */

MDRawMemoryInfo;  /* MINIDUMP_MEMORY_INFO */

/* For (MDRawMemoryInfo).state */
MDMemoryState;

/* For (MDRawMemoryInfo).allocation_protection and .protection */
MDMemoryProtection;

/* Used to mask the mutually exclusive options from the combinable flags. */
const uint32_t MD_MEMORY_PROTECTION_ACCESS_MASK =;

/* For (MDRawMemoryInfo).type */
MDMemoryType;

/*
 * Breakpad extension types
 */


MDRawBreakpadInfo;

/* For (MDRawBreakpadInfo).validity: */
MDBreakpadInfoValidity;

MDRawAssertionInfo;

/* For (MDRawAssertionInfo).type: */
MDAssertionInfoData;

/* These structs are used to store the DSO debug data in Linux minidumps,
 * which is necessary for converting minidumps to usable coredumps.
 * Because of a historical accident, several fields are variably encoded
 * according to client word size, so tools potentially need to support both. */

MDRawLinkMap32;

MDRawDebug32;

MDRawLinkMap64;

MDRawDebug64;

/* Crashpad extension types. See Crashpad's minidump/minidump_extensions.h. */

MDRawSimpleStringDictionaryEntry;

MDRawSimpleStringDictionary;

MDRawCrashpadAnnotation;

MDRawCrashpadAnnotationList;

MDRawModuleCrashpadInfo;

MDRawModuleCrashpadInfoLink;

MDRawModuleCrashpadInfoList;

MDRawCrashpadInfo;

#if defined(_MSC_VER)
#pragma warning(pop)
#endif  /* _MSC_VER */


#endif  /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__ */