aboutsummaryrefslogtreecommitdiff
path: root/src/google_breakpad
diff options
context:
space:
mode:
Diffstat (limited to 'src/google_breakpad')
-rw-r--r--src/google_breakpad/common/breakpad_types.h65
-rw-r--r--src/google_breakpad/common/minidump_format.h1063
-rw-r--r--src/google_breakpad/processor/basic_source_line_resolver.h84
-rw-r--r--src/google_breakpad/processor/call_stack.h77
-rw-r--r--src/google_breakpad/processor/code_module.h93
-rw-r--r--src/google_breakpad/processor/code_modules.h98
-rw-r--r--src/google_breakpad/processor/memory_region.h76
-rw-r--r--src/google_breakpad/processor/minidump.h813
-rw-r--r--src/google_breakpad/processor/minidump_processor.h91
-rw-r--r--src/google_breakpad/processor/process_state.h114
-rw-r--r--src/google_breakpad/processor/source_line_resolver_interface.h79
-rw-r--r--src/google_breakpad/processor/stack_frame.h84
-rw-r--r--src/google_breakpad/processor/stack_frame_cpu.h103
-rw-r--r--src/google_breakpad/processor/stackwalker.h140
-rw-r--r--src/google_breakpad/processor/symbol_supplier.h72
-rw-r--r--src/google_breakpad/processor/system_info.h89
16 files changed, 3141 insertions, 0 deletions
diff --git a/src/google_breakpad/common/breakpad_types.h b/src/google_breakpad/common/breakpad_types.h
new file mode 100644
index 00000000..07b11347
--- /dev/null
+++ b/src/google_breakpad/common/breakpad_types.h
@@ -0,0 +1,65 @@
+/* Copyright (c) 2006, Google Inc.
+ * All rights reserved.
+ *
+ * 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 Inc. 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. */
+
+/* breakpad_types.h: Precise-width types
+ *
+ * (This is C99 source, please don't corrupt it with C++.)
+ *
+ * This file ensures that types u_intN_t are defined for N = 8, 16, 32, and
+ * 64. Types of precise widths are crucial to the task of writing data
+ * structures on one platform and reading them on another.
+ *
+ * Author: Mark Mentovai */
+
+#ifndef GOOGLE_BREAKPAD_COMMON_BREAKPAD_TYPES_H__
+#define GOOGLE_BREAKPAD_COMMON_BREAKPAD_TYPES_H__
+
+#ifndef _WIN32
+
+#include <sys/types.h>
+
+#else /* !_WIN32 */
+
+#include <WTypes.h>
+
+typedef unsigned __int8 u_int8_t;
+typedef unsigned __int16 u_int16_t;
+typedef unsigned __int32 u_int32_t;
+typedef unsigned __int64 u_int64_t;
+
+#endif /* !_WIN32 */
+
+typedef struct {
+ u_int64_t high;
+ u_int64_t low;
+} u_int128_t;
+
+typedef u_int64_t breakpad_time_t;
+
+#endif /* GOOGLE_BREAKPAD_COMMON_BREAKPAD_TYPES_H__ */
diff --git a/src/google_breakpad/common/minidump_format.h b/src/google_breakpad/common/minidump_format.h
new file mode 100644
index 00000000..c83274fc
--- /dev/null
+++ b/src/google_breakpad/common/minidump_format.h
@@ -0,0 +1,1063 @@
+/* Copyright (c) 2006, Google Inc.
+ * All rights reserved.
+ *
+ * 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 Inc. 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++.)
+ *
+ * This file contains the necessary definitions to read minidump files
+ * produced on win32/x86. These files may be read on any platform provided
+ * that the alignments of these structures on the processing system are
+ * identical to the alignments of these structures on the producing system.
+ * For this reason, precise-sized types are used. The structures defined
+ * by this file have been laid out to minimize alignment problems by ensuring
+ * ensuring that all members are aligned on their natural boundaries. In
+ * In some cases, tail-padding may be significant when different ABIs specify
+ * different tail-padding behaviors. To avoid problems when reading or
+ * writing affected structures, MD_*_SIZE macros are provided where needed,
+ * containing the useful size of the structures without padding.
+ *
+ * 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 "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
+ */
+
+
+typedef struct {
+ u_int32_t data1;
+ u_int16_t data2;
+ u_int16_t data3;
+ u_int8_t data4[8];
+} MDGUID; /* GUID */
+
+
+/*
+ * WinNT.h
+ */
+
+
+#define MD_FLOATINGSAVEAREA_X86_REGISTERAREA_SIZE 80
+ /* SIZE_OF_80387_REGISTERS */
+
+typedef struct {
+ u_int32_t control_word;
+ u_int32_t status_word;
+ u_int32_t tag_word;
+ u_int32_t error_offset;
+ u_int32_t error_selector;
+ u_int32_t data_offset;
+ u_int32_t data_selector;
+
+ /* register_area contains eight 80-bit (x87 "long double") quantities for
+ * floating-point registers %st0 (%mm0) through %st7 (%mm7). */
+ u_int8_t register_area[MD_FLOATINGSAVEAREA_X86_REGISTERAREA_SIZE];
+ u_int32_t cr0_npx_state;
+} MDFloatingSaveAreaX86; /* FLOATING_SAVE_AREA */
+
+
+#define MD_CONTEXT_X86_EXTENDED_REGISTERS_SIZE 512
+ /* MAXIMUM_SUPPORTED_EXTENSION */
+
+typedef struct {
+ /* The next field determines the layout of the structure, and which parts
+ * of it are populated */
+ u_int32_t context_flags;
+
+ /* The next 6 registers are included with MD_CONTEXT_X86_DEBUG_REGISTERS */
+ u_int32_t dr0;
+ u_int32_t dr1;
+ u_int32_t dr2;
+ u_int32_t dr3;
+ u_int32_t dr6;
+ u_int32_t dr7;
+
+ /* The next field is included with MD_CONTEXT_X86_FLOATING_POINT */
+ MDFloatingSaveAreaX86 float_save;
+
+ /* The next 4 registers are included with MD_CONTEXT_X86_SEGMENTS */
+ u_int32_t gs;
+ u_int32_t fs;
+ u_int32_t es;
+ u_int32_t ds;
+ /* The next 6 registers are included with MD_CONTEXT_X86_INTEGER */
+ u_int32_t edi;
+ u_int32_t esi;
+ u_int32_t ebx;
+ u_int32_t edx;
+ u_int32_t ecx;
+ u_int32_t eax;
+
+ /* The next 6 registers are included with MD_CONTEXT_X86_CONTROL */
+ u_int32_t ebp;
+ u_int32_t eip;
+ u_int32_t cs; /* WinNT.h says "must be sanitized" */
+ u_int32_t eflags; /* WinNT.h says "must be sanitized" */
+ u_int32_t esp;
+ u_int32_t ss;
+
+ /* The next field is included with MD_CONTEXT_X86_EXTENDED_REGISTERS.
+ * It contains vector (MMX/SSE) registers. It it laid out in the
+ * format used by the fxsave and fsrstor instructions, so it includes
+ * a copy of the x87 floating-point registers as well. See FXSAVE in
+ * "Intel Architecture Software Developer's Manual, Volume 2." */
+ u_int8_t extended_registers[
+ MD_CONTEXT_X86_EXTENDED_REGISTERS_SIZE];
+} MDRawContextX86; /* CONTEXT */
+
+/* For (MDRawContextX86).context_flags. These values indicate the type of
+ * context stored in the structure. The high 26 bits identify the CPU, the
+ * low 6 bits identify the type of context saved. */
+#define MD_CONTEXT_X86 0x00010000
+ /* CONTEXT_i386, CONTEXT_i486: identifies CPU */
+#define MD_CONTEXT_X86_CONTROL (MD_CONTEXT_X86 | 0x00000001)
+ /* CONTEXT_CONTROL */
+#define MD_CONTEXT_X86_INTEGER (MD_CONTEXT_X86 | 0x00000002)
+ /* CONTEXT_INTEGER */
+#define MD_CONTEXT_X86_SEGMENTS (MD_CONTEXT_X86 | 0x00000004)
+ /* CONTEXT_SEGMENTS */
+#define MD_CONTEXT_X86_FLOATING_POINT (MD_CONTEXT_X86 | 0x00000008)
+ /* CONTEXT_FLOATING_POINT */
+#define MD_CONTEXT_X86_DEBUG_REGISTERS (MD_CONTEXT_X86 | 0x00000010)
+ /* CONTEXT_DEBUG_REGISTERS */
+#define MD_CONTEXT_X86_EXTENDED_REGISTERS (MD_CONTEXT_X86 | 0x00000020)
+ /* CONTEXT_EXTENDED_REGISTERS */
+
+#define MD_CONTEXT_X86_FULL (MD_CONTEXT_X86_CONTROL | \
+ MD_CONTEXT_X86_INTEGER | \
+ MD_CONTEXT_X86_SEGMENTS)
+ /* CONTEXT_FULL */
+
+#define MD_CONTEXT_X86_ALL (MD_CONTEXT_X86_FULL | \
+ MD_CONTEXT_X86_FLOATING_POINT | \
+ MD_CONTEXT_X86_DEBUG_REGISTERS | \
+ MD_CONTEXT_X86_EXTENDED_REGISTERS)
+ /* CONTEXT_ALL */
+
+/* Non-x86 CPU identifiers found in the high 26 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 0x00080000 /* CONTEXT_IA64 */
+#define MD_CONTEXT_AMD64 0x00100000 /* CONTEXT_AMD64 */
+/* Additional values from winnt.h in the Windows CE 5.0 SDK: */
+#define MD_CONTEXT_SHX 0x000000c0 /* CONTEXT_SH4 (Super-H, includes SH3) */
+#define MD_CONTEXT_ARM 0x00000040 /* CONTEXT_ARM (0x40 bit set in SHx?) */
+#define MD_CONTEXT_MIPS 0x00010000 /* CONTEXT_R4000 (same value as x86?) */
+#define MD_CONTEXT_ALPHA 0x00020000 /* CONTEXT_ALPHA */
+
+#define MD_CONTEXT_CPU_MASK 0xffffffc0
+
+
+/*
+ * Breakpad minidump extension for PowerPC support. Based on Darwin/Mac OS X'
+ * mach/ppc/_types.h
+ */
+
+
+/* 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. */
+typedef struct {
+ u_int32_t context_flags;
+} MDRawContextBase;
+
+
+#define MD_FLOATINGSAVEAREA_PPC_FPR_COUNT 32
+
+typedef struct {
+ /* fpregs is a double[32] in mach/ppc/_types.h, but a u_int64_t is used
+ * here for precise sizing. */
+ u_int64_t fpregs[MD_FLOATINGSAVEAREA_PPC_FPR_COUNT];
+ u_int32_t fpscr_pad;
+ u_int32_t fpscr; /* Status/control */
+} MDFloatingSaveAreaPPC; /* Based on ppc_float_state */
+
+
+#define MD_VECTORSAVEAREA_PPC_VR_COUNT 32
+
+typedef struct {
+ /* Vector registers (including vscr) are 128 bits, but mach/ppc/_types.h
+ * exposes them as four 32-bit quantities. */
+ u_int128_t save_vr[MD_VECTORSAVEAREA_PPC_VR_COUNT];
+ u_int128_t save_vscr; /* Status/control */
+ u_int32_t save_pad5[4];
+ u_int32_t save_vrvalid; /* Identifies which vector registers are saved */
+ u_int32_t save_pad6[7];
+} MDVectorSaveAreaPPC; /* ppc_vector_state */
+
+
+#define MD_CONTEXT_PPC_GPR_COUNT 32
+
+typedef struct {
+ /* context_flags is not present in ppc_thread_state, but it aids
+ * identification of MDRawContextPPC among other raw context types,
+ * and it guarantees alignment when we get to float_save. */
+ u_int32_t context_flags;
+
+ u_int32_t srr0; /* Machine status save/restore: stores pc
+ * (instruction) */
+ u_int32_t srr1; /* Machine status save/restore: stores msr
+ * (ps, program/machine state) */
+ /* ppc_thread_state contains 32 fields, r0 .. r31. Here, an array is
+ * used for brevity. */
+ u_int32_t gpr[MD_CONTEXT_PPC_GPR_COUNT];
+ u_int32_t cr; /* Condition */
+ u_int32_t xer; /* Integer (fiXed-point) exception */
+ u_int32_t lr; /* Link */
+ u_int32_t ctr; /* Count */
+ u_int32_t mq; /* Multiply/Quotient (PPC 601, POWER only) */
+ u_int32_t vrsave; /* Vector save */
+
+ /* float_save and vector_save aren't present in ppc_thread_state, but
+ * are represented in separate structures that still define a thread's
+ * context. */
+ MDFloatingSaveAreaPPC float_save;
+ MDVectorSaveAreaPPC vector_save;
+} MDRawContextPPC; /* Based on ppc_thread_state */
+
+/* For (MDRawContextPPC).context_flags. These values indicate the type of
+ * context stored in the structure. MD_CONTEXT_PPC is Breakpad-defined. Its
+ * value was chosen to avoid likely conflicts with MD_CONTEXT_* for other
+ * CPUs. */
+#define MD_CONTEXT_PPC 0x20000000
+#define MD_CONTEXT_PPC_BASE (MD_CONTEXT_PPC | 0x00000001)
+#define MD_CONTEXT_PPC_FLOATING_POINT (MD_CONTEXT_PPC | 0x00000008)
+#define MD_CONTEXT_PPC_VECTOR (MD_CONTEXT_PPC | 0x00000020)
+
+#define MD_CONTEXT_PPC_FULL MD_CONTEXT_PPC_BASE
+#define MD_CONTEXT_PPC_ALL (MD_CONTEXT_PPC_FULL | \
+ MD_CONTEXT_PPC_FLOATING_POINT | \
+ MD_CONTEXT_PPC_VECTOR)
+
+
+/*
+ * WinVer.h
+ */
+
+
+typedef struct {
+ u_int32_t signature;
+ u_int32_t struct_version;
+ u_int32_t file_version_hi;
+ u_int32_t file_version_lo;
+ u_int32_t product_version_hi;
+ u_int32_t product_version_lo;
+ u_int32_t file_flags_mask; /* Identifies valid bits in fileFlags */
+ u_int32_t file_flags;
+ u_int32_t file_os;
+ u_int32_t file_type;
+ u_int32_t file_subtype;
+ u_int32_t file_date_hi;
+ u_int32_t file_date_lo;
+} MDVSFixedFileInfo; /* VS_FIXEDFILEINFO */
+
+/* For (MDVSFixedFileInfo).signature */
+#define MD_VSFIXEDFILEINFO_SIGNATURE 0xfeef04bd
+ /* VS_FFI_SIGNATURE */
+
+/* For (MDVSFixedFileInfo).version */
+#define MD_VSFIXEDFILEINFO_VERSION 0x00010000
+ /* VS_FFI_STRUCVERSION */
+
+/* For (MDVSFixedFileInfo).file_flags_mask and
+ * (MDVSFixedFileInfo).file_flags */
+#define MD_VSFIXEDFILEINFO_FILE_FLAGS_DEBUG 0x00000001
+ /* VS_FF_DEBUG */
+#define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRERELEASE 0x00000002
+ /* VS_FF_PRERELEASE */
+#define MD_VSFIXEDFILEINFO_FILE_FLAGS_PATCHED 0x00000004
+ /* VS_FF_PATCHED */
+#define MD_VSFIXEDFILEINFO_FILE_FLAGS_PRIVATEBUILD 0x00000008
+ /* VS_FF_PRIVATEBUILD */
+#define MD_VSFIXEDFILEINFO_FILE_FLAGS_INFOINFERRED 0x00000010
+ /* VS_FF_INFOINFERRED */
+#define MD_VSFIXEDFILEINFO_FILE_FLAGS_SPECIALBUILD 0x00000020
+ /* VS_FF_SPECIALBUILD */
+
+/* For (MDVSFixedFileInfo).file_os: high 16 bits */
+#define MD_VSFIXEDFILEINFO_FILE_OS_UNKNOWN 0 /* VOS_UNKNOWN */
+#define MD_VSFIXEDFILEINFO_FILE_OS_DOS (1 << 16) /* VOS_DOS */
+#define MD_VSFIXEDFILEINFO_FILE_OS_OS216 (2 << 16) /* VOS_OS216 */
+#define MD_VSFIXEDFILEINFO_FILE_OS_OS232 (3 << 16) /* VOS_OS232 */
+#define MD_VSFIXEDFILEINFO_FILE_OS_NT (4 << 16) /* VOS_NT */
+#define MD_VSFIXEDFILEINFO_FILE_OS_WINCE (5 << 16) /* VOS_WINCE */
+/* Low 16 bits */
+#define MD_VSFIXEDFILEINFO_FILE_OS__BASE 0 /* VOS__BASE */
+#define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS16 1 /* VOS__WINDOWS16 */
+#define MD_VSFIXEDFILEINFO_FILE_OS__PM16 2 /* VOS__PM16 */
+#define MD_VSFIXEDFILEINFO_FILE_OS__PM32 3 /* VOS__PM32 */
+#define MD_VSFIXEDFILEINFO_FILE_OS__WINDOWS32 4 /* VOS__WINDOWS32 */
+
+/* For (MDVSFixedFileInfo).file_type */
+#define MD_VSFIXEDFILEINFO_FILE_TYPE_UNKNOWN 0 /* VFT_UNKNOWN */
+#define MD_VSFIXEDFILEINFO_FILE_TYPE_APP 1 /* VFT_APP */
+#define MD_VSFIXEDFILEINFO_FILE_TYPE_DLL 2 /* VFT_DLL */
+#define MD_VSFIXEDFILEINFO_FILE_TYPE_DRV 3 /* VFT_DLL */
+#define MD_VSFIXEDFILEINFO_FILE_TYPE_FONT 4 /* VFT_FONT */
+#define MD_VSFIXEDFILEINFO_FILE_TYPE_VXD 5 /* VFT_VXD */
+#define MD_VSFIXEDFILEINFO_FILE_TYPE_STATIC_LIB 7 /* VFT_STATIC_LIB */
+
+/* For (MDVSFixedFileInfo).file_subtype */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_UNKNOWN 0
+ /* VFT2_UNKNOWN */
+/* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_DRV */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_PRINTER 1
+ /* VFT2_DRV_PRINTER */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_KEYBOARD 2
+ /* VFT2_DRV_KEYBOARD */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_LANGUAGE 3
+ /* VFT2_DRV_LANGUAGE */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_DISPLAY 4
+ /* VFT2_DRV_DISPLAY */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_MOUSE 5
+ /* VFT2_DRV_MOUSE */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_NETWORK 6
+ /* VFT2_DRV_NETWORK */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SYSTEM 7
+ /* VFT2_DRV_SYSTEM */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INSTALLABLE 8
+ /* VFT2_DRV_INSTALLABLE */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_SOUND 9
+ /* VFT2_DRV_SOUND */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_COMM 10
+ /* VFT2_DRV_COMM */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_INPUTMETHOD 11
+ /* VFT2_DRV_INPUTMETHOD */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_DRV_VERSIONED_PRINTER 12
+ /* VFT2_DRV_VERSIONED_PRINTER */
+/* with file_type = MD_VSFIXEDFILEINFO_FILETYPE_FONT */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_RASTER 1
+ /* VFT2_FONT_RASTER */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_VECTOR 2
+ /* VFT2_FONT_VECTOR */
+#define MD_VSFIXEDFILEINFO_FILE_SUBTYPE_FONT_TRUETYPE 3
+ /* VFT2_FONT_TRUETYPE */
+
+
+/*
+ * DbgHelp.h
+ */
+
+
+/* An MDRVA is an offset into the minidump file. The beginning of the
+ * MDRawHeader is at offset 0. */
+typedef u_int32_t MDRVA; /* RVA */
+
+
+typedef struct {
+ u_int32_t data_size;
+ MDRVA rva;
+} MDLocationDescriptor; /* MINIDUMP_LOCATION_DESCRIPTOR */
+
+
+typedef struct {
+ /* The base address of the memory range on the host that produced the
+ * minidump. */
+ u_int64_t start_of_memory_range;
+
+ MDLocationDescriptor memory;
+} MDMemoryDescriptor; /* MINIDUMP_MEMORY_DESCRIPTOR */
+
+
+typedef struct {
+ u_int32_t signature;
+ u_int32_t version;
+ u_int32_t stream_count;
+ MDRVA stream_directory_rva; /* A |stream_count|-sized array of
+ * MDRawDirectory structures. */
+ u_int32_t checksum; /* Can be 0. In fact, that's all that's
+ * been found in minidump files. */
+ u_int32_t time_date_stamp; /* time_t */
+ u_int64_t flags;
+} 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 0x504d444d /* 'PMDM' */
+ /* MINIDUMP_SIGNATURE */
+#define MD_HEADER_VERSION 0x0000a793 /* 42899 */
+ /* MINIDUMP_VERSION */
+
+/* For (MDRawHeader).flags: */
+typedef enum {
+ /* MD_NORMAL is the standard type of minidump. It includes full
+ * streams for the thread list, module list, exception, system info,
+ * and miscellaneous info. A memory list stream is also present,
+ * pointing to the same stack memory contained in the thread list,
+ * as well as a 256-byte region around the instruction address that
+ * was executing when the exception occurred. Stack memory is from
+ * 4 bytes below a thread's stack pointer up to the top of the
+ * memory region encompassing the stack. */
+ MD_NORMAL = 0x00000000,
+ MD_WITH_DATA_SEGS = 0x00000001,
+ MD_WITH_FULL_MEMORY = 0x00000002,
+ MD_WITH_HANDLE_DATA = 0x00000004,
+ MD_FILTER_MEMORY = 0x00000008,
+ MD_SCAN_MEMORY = 0x00000010,
+ MD_WITH_UNLOADED_MODULES = 0x00000020,
+ MD_WITH_INDIRECTLY_REFERENCED_MEMORY = 0x00000040,
+ MD_FILTER_MODULE_PATHS = 0x00000080,
+ MD_WITH_PROCESS_THREAD_DATA = 0x00000100,
+ MD_WITH_PRIVATE_READ_WRITE_MEMORY = 0x00000200,
+ MD_WITHOUT_OPTIONAL_DATA = 0x00000400,
+ MD_WITH_FULL_MEMORY_INFO = 0x00000800,
+ MD_WITH_THREAD_INFO = 0x00001000,
+ MD_WITH_CODE_SEGS = 0x00002000
+} MDType; /* MINIDUMP_TYPE */
+
+
+typedef struct {
+ u_int32_t stream_type;
+ MDLocationDescriptor location;
+} MDRawDirectory; /* MINIDUMP_DIRECTORY */
+
+/* For (MDRawDirectory).stream_type */
+typedef enum {
+ MD_UNUSED_STREAM = 0,
+ MD_RESERVED_STREAM_0 = 1,
+ MD_RESERVED_STREAM_1 = 2,
+ MD_THREAD_LIST_STREAM = 3, /* MDRawThreadList */
+ MD_MODULE_LIST_STREAM = 4, /* MDRawModuleList */
+ MD_MEMORY_LIST_STREAM = 5, /* MDRawMemoryList */
+ MD_EXCEPTION_STREAM = 6, /* MDRawExceptionStream */
+ MD_SYSTEM_INFO_STREAM = 7, /* MDRawSystemInfo */
+ MD_THREAD_EX_LIST_STREAM = 8,
+ MD_MEMORY_64_LIST_STREAM = 9,
+ MD_COMMENT_STREAM_A = 10,
+ MD_COMMENT_STREAM_W = 11,
+ MD_HANDLE_DATA_STREAM = 12,
+ MD_FUNCTION_TABLE_STREAM = 13,
+ MD_UNLOADED_MODULE_LIST_STREAM = 14,
+ MD_MISC_INFO_STREAM = 15, /* MDRawMiscInfo */
+ MD_LAST_RESERVED_STREAM = 0x0000ffff,
+
+ /* Breakpad extension types. 0x4767 = "Gg" */
+ MD_BREAKPAD_INFO_STREAM = 0x47670001, /* MDRawBreakpadInfo */
+ MD_ASSERTION_INFO_STREAM = 0x47670002 /* MDRawAssertionInfo */
+} MDStreamType; /* MINIDUMP_STREAM_TYPE */
+
+
+typedef struct {
+ u_int32_t length; /* Length of buffer in bytes (not characters),
+ * excluding 0-terminator */
+ u_int16_t buffer[0]; /* UTF-16-encoded, 0-terminated */
+} MDString; /* MINIDUMP_STRING */
+
+
+typedef struct {
+ u_int32_t thread_id;
+ u_int32_t suspend_count;
+ u_int32_t priority_class;
+ u_int32_t priority;
+ u_int64_t teb; /* Thread environment block */
+ MDMemoryDescriptor stack;
+ MDLocationDescriptor thread_context; /* MDRawContext[CPU] */
+} MDRawThread; /* MINIDUMP_THREAD */
+
+
+typedef struct {
+ u_int32_t number_of_threads;
+ MDRawThread threads[0];
+} MDRawThreadList; /* MINIDUMP_THREAD_LIST */
+
+
+typedef struct {
+ u_int64_t base_of_image;
+ u_int32_t size_of_image;
+ u_int32_t checksum; /* 0 if unknown */
+ u_int32_t time_date_stamp; /* time_t */
+ MDRVA module_name_rva; /* MDString, pathname or filename */
+ MDVSFixedFileInfo version_info;
+
+ /* The next field stores a CodeView record and is populated when a module's
+ * debug information resides in a PDB file. It identifies the PDB file. */
+ MDLocationDescriptor cv_record;
+
+ /* The next field is populated when a module's debug information resides
+ * in a DBG file. It identifies the DBG file. This field is effectively
+ * obsolete with modules built by recent toolchains. */
+ MDLocationDescriptor misc_record;
+
+ /* Alignment problem: reserved0 and reserved1 are defined by the platform
+ * SDK as 64-bit quantities. However, that results in a structure whose
+ * alignment is unpredictable on different CPUs and ABIs. If the ABI
+ * specifies full alignment of 64-bit quantities in structures (as ppc
+ * does), there will be padding between miscRecord and reserved0. If
+ * 64-bit quantities can be aligned on 32-bit boundaries (as on x86),
+ * this padding will not exist. (Note that the structure up to this point
+ * contains 1 64-bit member followed by 21 32-bit members.)
+ * As a workaround, reserved0 and reserved1 are instead defined here as
+ * four 32-bit quantities. This should be harmless, as there are
+ * currently no known uses for these fields. */
+ u_int32_t reserved0[2];
+ u_int32_t reserved1[2];
+} 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 108
+
+
+/* (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. */
+
+typedef struct {
+ u_int32_t signature;
+ u_int32_t offset; /* Offset to debug data (expect 0 in minidump) */
+} MDCVHeader;
+
+typedef struct {
+ MDCVHeader cv_header;
+ u_int32_t signature; /* time_t debug information created */
+ u_int32_t age; /* revision of PDB file */
+ u_int8_t pdb_file_name[0]; /* Pathname or filename of PDB file */
+} MDCVInfoPDB20;
+
+#define MD_CVINFOPDB20_SIGNATURE 0x3031424e /* cvHeader.signature = '01BN' */
+
+typedef struct {
+ u_int32_t cv_signature;
+ MDGUID signature; /* GUID, identifies PDB file */
+ u_int32_t age; /* Identifies incremental changes to PDB file */
+ u_int8_t pdb_file_name[0]; /* Pathname or filename of PDB file,
+ * 0-terminated 8-bit character data (UTF-8?) */
+} MDCVInfoPDB70;
+
+#define MD_CVINFOPDB70_SIGNATURE 0x53445352 /* cvSignature = 'SDSR' */
+
+/* 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 0x3930424e /* '90BN', CodeView 4.10. */
+#define MD_CVINFOCV50_SIGNATURE 0x3131424e /* '11BN', CodeView 5.0,
+ * MS C7-format (/Z7). */
+
+#define MD_CVINFOUNKNOWN_SIGNATURE 0xffffffff /* An unlikely value. */
+
+/* (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. */
+
+typedef struct {
+ u_int32_t data_type; /* IMAGE_DEBUG_TYPE_*, not defined here because
+ * this debug record type is mostly obsolete. */
+ u_int32_t length; /* Length of entire MDImageDebugMisc structure */
+ u_int8_t unicode; /* True if data is multibyte */
+ u_int8_t reserved[3];
+ u_int8_t data[0];
+} MDImageDebugMisc; /* IMAGE_DEBUG_MISC */
+
+
+typedef struct {
+ u_int32_t number_of_modules;
+ MDRawModule modules[0];
+} MDRawModuleList; /* MINIDUMP_MODULE_LIST */
+
+
+typedef struct {
+ u_int32_t number_of_memory_ranges;
+ MDMemoryDescriptor memory_ranges[0];
+} MDRawMemoryList; /* MINIDUMP_MEMORY_LIST */
+
+
+#define MD_EXCEPTION_MAXIMUM_PARAMETERS 15
+
+typedef struct {
+ u_int32_t exception_code; /* Windows: MDExceptionCodeWin,
+ * Mac OS X: MDExceptionMac. */
+ u_int32_t exception_flags; /* Windows: 1 if noncontinuable,
+ Mac OS X: MDExceptionCodeMac. */
+ u_int64_t exception_record; /* Address (in the minidump-producing host's
+ * memory) of another MDException, for
+ * nested exceptions. */
+ u_int64_t exception_address; /* The address that caused the exception.
+ * Mac OS X: exception subcode (which is
+ * typically the address). */
+ u_int32_t number_parameters; /* Number of valid elements in
+ * exception_information. */
+ u_int32_t __align;
+ u_int64_t exception_information[MD_EXCEPTION_MAXIMUM_PARAMETERS];
+} MDException; /* MINIDUMP_EXCEPTION */
+
+/* For (MDException).exception_code. These values come from WinBase.h
+ * and WinNT.h (names beginning with EXCEPTION_ are in WinBase.h,
+ * they are STATUS_ in WinNT.h). */
+typedef enum {
+ MD_EXCEPTION_CODE_WIN_CONTROL_C = 0x40010005,
+ /* DBG_CONTROL_C */
+ MD_EXCEPTION_CODE_WIN_GUARD_PAGE_VIOLATION = 0x80000001,
+ /* EXCEPTION_GUARD_PAGE */
+ MD_EXCEPTION_CODE_WIN_DATATYPE_MISALIGNMENT = 0x80000002,
+ /* EXCEPTION_DATATYPE_MISALIGNMENT */
+ MD_EXCEPTION_CODE_WIN_BREAKPOINT = 0x80000003,
+ /* EXCEPTION_BREAKPOINT */
+ MD_EXCEPTION_CODE_WIN_SINGLE_STEP = 0x80000004,
+ /* EXCEPTION_SINGLE_STEP */
+ MD_EXCEPTION_CODE_WIN_ACCESS_VIOLATION = 0xc0000005,
+ /* EXCEPTION_ACCESS_VIOLATION */
+ MD_EXCEPTION_CODE_WIN_IN_PAGE_ERROR = 0xc0000006,
+ /* EXCEPTION_IN_PAGE_ERROR */
+ MD_EXCEPTION_CODE_WIN_INVALID_HANDLE = 0xc0000008,
+ /* EXCEPTION_INVALID_HANDLE */
+ MD_EXCEPTION_CODE_WIN_ILLEGAL_INSTRUCTION = 0xc000001d,
+ /* EXCEPTION_ILLEGAL_INSTRUCTION */
+ MD_EXCEPTION_CODE_WIN_NONCONTINUABLE_EXCEPTION = 0xc0000025,
+ /* EXCEPTION_NONCONTINUABLE_EXCEPTION */
+ MD_EXCEPTION_CODE_WIN_INVALID_DISPOSITION = 0xc0000026,
+ /* EXCEPTION_INVALID_DISPOSITION */
+ MD_EXCEPTION_CODE_WIN_ARRAY_BOUNDS_EXCEEDED = 0xc000008c,
+ /* EXCEPTION_BOUNDS_EXCEEDED */
+ MD_EXCEPTION_CODE_WIN_FLOAT_DENORMAL_OPERAND = 0xc000008d,
+ /* EXCEPTION_FLT_DENORMAL_OPERAND */
+ MD_EXCEPTION_CODE_WIN_FLOAT_DIVIDE_BY_ZERO = 0xc000008e,
+ /* EXCEPTION_FLT_DIVIDE_BY_ZERO */
+ MD_EXCEPTION_CODE_WIN_FLOAT_INEXACT_RESULT = 0xc000008f,
+ /* EXCEPTION_FLT_INEXACT_RESULT */
+ MD_EXCEPTION_CODE_WIN_FLOAT_INVALID_OPERATION = 0xc0000090,
+ /* EXCEPTION_FLT_INVALID_OPERATION */
+ MD_EXCEPTION_CODE_WIN_FLOAT_OVERFLOW = 0xc0000091,
+ /* EXCEPTION_FLT_OVERFLOW */
+ MD_EXCEPTION_CODE_WIN_FLOAT_STACK_CHECK = 0xc0000092,
+ /* EXCEPTION_FLT_STACK_CHECK */
+ MD_EXCEPTION_CODE_WIN_FLOAT_UNDERFLOW = 0xc0000093,
+ /* EXCEPTION_FLT_UNDERFLOW */
+ MD_EXCEPTION_CODE_WIN_INTEGER_DIVIDE_BY_ZERO = 0xc0000094,
+ /* EXCEPTION_INT_DIVIDE_BY_ZERO */
+ MD_EXCEPTION_CODE_WIN_INTEGER_OVERFLOW = 0xc0000095,
+ /* EXCEPTION_INT_OVERFLOW */
+ MD_EXCEPTION_CODE_WIN_PRIVILEGED_INSTRUCTION = 0xc0000096,
+ /* EXCEPTION_PRIV_INSTRUCTION */
+ MD_EXCEPTION_CODE_WIN_STACK_OVERFLOW = 0xc00000fd,
+ /* EXCEPTION_STACK_OVERFLOW */
+ MD_EXCEPTION_CODE_WIN_POSSIBLE_DEADLOCK = 0xc0000194
+ /* EXCEPTION_POSSIBLE_DEADLOCK */
+} MDExceptionCodeWin;
+
+/* For (MDException).exception_code. Breakpad minidump extension for Mac OS X
+ * support. Based on Darwin/Mac OS X' mach/exception_types.h. This is
+ * what Mac OS X calls an "exception", not a "code". */
+typedef enum {
+ /* Exception code. The high 16 bits of exception_code contains one of
+ * these values. */
+ MD_EXCEPTION_MAC_BAD_ACCESS = 1, /* code can be a kern_return_t */
+ /* EXC_BAD_ACCESS */
+ MD_EXCEPTION_MAC_BAD_INSTRUCTION = 2, /* code is CPU-specific */
+ /* EXC_BAD_INSTRUCTION */
+ MD_EXCEPTION_MAC_ARITHMETIC = 3, /* code is CPU-specific */
+ /* EXC_ARITHMETIC */
+ MD_EXCEPTION_MAC_EMULATION = 4, /* code is CPU-specific */
+ /* EXC_EMULATION */
+ MD_EXCEPTION_MAC_SOFTWARE = 5,
+ /* EXC_SOFTWARE */
+ MD_EXCEPTION_MAC_BREAKPOINT = 6, /* code is CPU-specific */
+ /* EXC_BREAKPOINT */
+ MD_EXCEPTION_MAC_SYSCALL = 7,
+ /* EXC_SYSCALL */
+ MD_EXCEPTION_MAC_MACH_SYSCALL = 8,
+ /* EXC_MACH_SYSCALL */
+ MD_EXCEPTION_MAC_RPC_ALERT = 9
+ /* EXC_RPC_ALERT */
+} MDExceptionMac;
+
+/* For (MDException).exception_flags. Breakpad minidump extension for Mac OS X
+ * support. Based on Darwin/Mac OS X' mach/ppc/exception.h and
+ * mach/i386/exception.h. This is what Mac OS X calls a "code". */
+typedef enum {
+ /* With MD_EXCEPTION_BAD_ACCESS. These are relevant kern_return_t values
+ * from mach/kern_return.h. */
+ MD_EXCEPTION_CODE_MAC_INVALID_ADDRESS = 1,
+ /* KERN_INVALID_ADDRESS */
+ MD_EXCEPTION_CODE_MAC_PROTECTION_FAILURE = 2,
+ /* KERN_PROTECTION_FAILURE */
+ MD_EXCEPTION_CODE_MAC_NO_ACCESS = 8,
+ /* KERN_NO_ACCESS */
+ MD_EXCEPTION_CODE_MAC_MEMORY_FAILURE = 9,
+ /* KERN_MEMORY_FAILURE */
+ MD_EXCEPTION_CODE_MAC_MEMORY_ERROR = 10,
+ /* KERN_MEMORY_ERROR */
+
+ /* With MD_EXCEPTION_SOFTWARE */
+ MD_EXCEPTION_CODE_MAC_BAD_SYSCALL = 0x00010000, /* Mach SIGSYS */
+ MD_EXCEPTION_CODE_MAC_BAD_PIPE = 0x00010001, /* Mach SIGPIPE */
+ MD_EXCEPTION_CODE_MAC_ABORT = 0x00010002, /* Mach SIGABRT */
+
+ /* With MD_EXCEPTION_MAC_BAD_ACCESS on ppc */
+ MD_EXCEPTION_CODE_MAC_PPC_VM_PROT_READ = 0x0101,
+ /* EXC_PPC_VM_PROT_READ */
+ MD_EXCEPTION_CODE_MAC_PPC_BADSPACE = 0x0102,
+ /* EXC_PPC_BADSPACE */
+ MD_EXCEPTION_CODE_MAC_PPC_UNALIGNED = 0x0103,
+ /* EXC_PPC_UNALIGNED */
+
+ /* With MD_EXCEPTION_MAC_BAD_INSTRUCTION on ppc */
+ MD_EXCEPTION_CODE_MAC_PPC_INVALID_SYSCALL = 1,
+ /* EXC_PPC_INVALID_SYSCALL */
+ MD_EXCEPTION_CODE_MAC_PPC_UNIMPLEMENTED_INSTRUCTION = 2,
+ /* EXC_PPC_UNIPL_INST */
+ MD_EXCEPTION_CODE_MAC_PPC_PRIVILEGED_INSTRUCTION = 3,
+ /* EXC_PPC_PRIVINST */
+ MD_EXCEPTION_CODE_MAC_PPC_PRIVILEGED_REGISTER = 4,
+ /* EXC_PPC_PRIVREG */
+ MD_EXCEPTION_CODE_MAC_PPC_TRACE = 5,
+ /* EXC_PPC_TRACE */
+ MD_EXCEPTION_CODE_MAC_PPC_PERFORMANCE_MONITOR = 6,
+ /* EXC_PPC_PERFMON */
+
+ /* With MD_EXCEPTION_MAC_ARITHMETIC on ppc */
+ MD_EXCEPTION_CODE_MAC_PPC_OVERFLOW = 1,
+ /* EXC_PPC_OVERFLOW */
+ MD_EXCEPTION_CODE_MAC_PPC_ZERO_DIVIDE = 2,
+ /* EXC_PPC_ZERO_DIVIDE */
+ MD_EXCEPTION_CODE_MAC_PPC_FLOAT_INEXACT = 3,
+ /* EXC_FLT_INEXACT */
+ MD_EXCEPTION_CODE_MAC_PPC_FLOAT_ZERO_DIVIDE = 4,
+ /* EXC_PPC_FLT_ZERO_DIVIDE */
+ MD_EXCEPTION_CODE_MAC_PPC_FLOAT_UNDERFLOW = 5,
+ /* EXC_PPC_FLT_UNDERFLOW */
+ MD_EXCEPTION_CODE_MAC_PPC_FLOAT_OVERFLOW = 6,
+ /* EXC_PPC_FLT_OVERFLOW */
+ MD_EXCEPTION_CODE_MAC_PPC_FLOAT_NOT_A_NUMBER = 7,
+ /* EXC_PPC_FLT_NOT_A_NUMBER */
+
+ /* With MD_EXCEPTION_MAC_EMULATION on ppc */
+ MD_EXCEPTION_CODE_MAC_PPC_NO_EMULATION = 8,
+ /* EXC_PPC_NOEMULATION */
+ MD_EXCEPTION_CODE_MAC_PPC_ALTIVEC_ASSIST = 9,
+ /* EXC_PPC_ALTIVECASSIST */
+
+ /* With MD_EXCEPTION_MAC_SOFTWARE on ppc */
+ MD_EXCEPTION_CODE_MAC_PPC_TRAP = 0x00000001, /* EXC_PPC_TRAP */
+ MD_EXCEPTION_CODE_MAC_PPC_MIGRATE = 0x00010100, /* EXC_PPC_MIGRATE */
+
+ /* With MD_EXCEPTION_MAC_BREAKPOINT on ppc */
+ MD_EXCEPTION_CODE_MAC_PPC_BREAKPOINT = 1, /* EXC_PPC_BREAKPOINT */
+
+ /* With MD_EXCEPTION_MAC_BAD_INSTRUCTION on x86, see also x86 interrupt
+ * values below. */
+ MD_EXCEPTION_CODE_MAC_X86_INVALID_OPERATION = 1, /* EXC_I386_INVOP */
+
+ /* With MD_EXCEPTION_MAC_ARITHMETIC on x86 */
+ MD_EXCEPTION_CODE_MAC_X86_DIV = 1, /* EXC_I386_DIV */
+ MD_EXCEPTION_CODE_MAC_X86_INTO = 2, /* EXC_I386_INTO */
+ MD_EXCEPTION_CODE_MAC_X86_NOEXT = 3, /* EXC_I386_NOEXT */
+ MD_EXCEPTION_CODE_MAC_X86_EXTOVR = 4, /* EXC_I386_EXTOVR */
+ MD_EXCEPTION_CODE_MAC_X86_EXTERR = 5, /* EXC_I386_EXTERR */
+ MD_EXCEPTION_CODE_MAC_X86_EMERR = 6, /* EXC_I386_EMERR */
+ MD_EXCEPTION_CODE_MAC_X86_BOUND = 7, /* EXC_I386_BOUND */
+ MD_EXCEPTION_CODE_MAC_X86_SSEEXTERR = 8, /* EXC_I386_SSEEXTERR */
+
+ /* With MD_EXCEPTION_MAC_BREAKPOINT on x86 */
+ MD_EXCEPTION_CODE_MAC_X86_SGL = 1, /* EXC_I386_SGL */
+ MD_EXCEPTION_CODE_MAC_X86_BPT = 2, /* EXC_I386_BPT */
+
+ /* With MD_EXCEPTION_MAC_BAD_INSTRUCTION on x86. These are the raw
+ * x86 interrupt codes. Most of these are mapped to other Mach
+ * exceptions and codes, are handled, or should not occur in user space.
+ * A few of these will do occur with MD_EXCEPTION_MAC_BAD_INSTRUCTION. */
+ /* EXC_I386_DIVERR = 0: mapped to EXC_ARITHMETIC/EXC_I386_DIV */
+ /* EXC_I386_SGLSTP = 1: mapped to EXC_BREAKPOINT/EXC_I386_SGL */
+ /* EXC_I386_NMIFLT = 2: should not occur in user space */
+ /* EXC_I386_BPTFLT = 3: mapped to EXC_BREAKPOINT/EXC_I386_BPT */
+ /* EXC_I386_INTOFLT = 4: mapped to EXC_ARITHMETIC/EXC_I386_INTO */
+ /* EXC_I386_BOUNDFLT = 5: mapped to EXC_ARITHMETIC/EXC_I386_BOUND */
+ /* EXC_I386_INVOPFLT = 6: mapped to EXC_BAD_INSTRUCTION/EXC_I386_INVOP */
+ /* EXC_I386_NOEXTFLT = 7: should be handled by the kernel */
+ /* EXC_I386_DBLFLT = 8: should be handled (if possible) by the kernel */
+ /* EXC_I386_EXTOVRFLT = 9: mapped to EXC_BAD_ACCESS/(PROT_READ|PROT_EXEC) */
+ MD_EXCEPTION_CODE_MAC_X86_INVALID_TASK_STATE_SEGMENT = 10,
+ /* EXC_INVTSSFLT */
+ MD_EXCEPTION_CODE_MAC_X86_SEGMENT_NOT_PRESENT = 11,
+ /* EXC_SEGNPFLT */
+ MD_EXCEPTION_CODE_MAC_X86_STACK_FAULT = 12,
+ /* EXC_STKFLT */
+ MD_EXCEPTION_CODE_MAC_X86_GENERAL_PROTECTION_FAULT = 13,
+ /* EXC_GPFLT */
+ /* EXC_I386_PGFLT = 14: should not occur in user space */
+ /* EXC_I386_EXTERRFLT = 16: mapped to EXC_ARITHMETIC/EXC_I386_EXTERR */
+ MD_EXCEPTION_CODE_MAC_X86_ALIGNMENT_FAULT = 17,
+ /* EXC_ALIGNFLT (for vector operations) */
+ /* EXC_I386_ENOEXTFLT = 32: should be handled by the kernel */
+ /* EXC_I386_ENDPERR = 33: should not occur */
+} MDExceptionCodeMac;
+
+
+typedef struct {
+ u_int32_t thread_id; /* Thread in which the exception
+ * occurred. Corresponds to
+ * (MDRawThread).thread_id. */
+ u_int32_t __align;
+ MDException exception_record;
+ MDLocationDescriptor thread_context; /* MDRawContext[CPU] */
+} MDRawExceptionStream; /* MINIDUMP_EXCEPTION_STREAM */
+
+
+typedef union {
+ struct {
+ u_int32_t vendor_id[3]; /* cpuid 0: eax, ebx, ecx */
+ u_int32_t version_information; /* cpuid 1: eax */
+ u_int32_t feature_information; /* cpuid 1: edx */
+ u_int32_t amd_extended_cpu_features; /* cpuid 0x80000001, ebx */
+ } x86_cpu_info;
+ struct {
+ u_int64_t processor_features[2];
+ } other_cpu_info;
+} MDCPUInformation; /* CPU_INFORMATION */
+
+
+typedef struct {
+ /* The next 3 fields and numberOfProcessors are from the SYSTEM_INFO
+ * structure as returned by GetSystemInfo */
+ u_int16_t processor_architecture;
+ u_int16_t processor_level; /* x86: 5 = 586, 6 = 686, ... */
+ u_int16_t processor_revision; /* x86: 0xMMSS, where MM=model,
+ * SS=stepping */
+ union {
+ u_int16_t reserved0;
+ struct {
+ u_int8_t number_of_processors;
+ u_int8_t product_type; /* Windows: VER_NT_* from WinNT.h */
+ };
+ };
+
+ /* The next 5 fields are from the OSVERSIONINFO structure as returned
+ * by GetVersionEx */
+ u_int32_t major_version;
+ u_int32_t minor_version;
+ u_int32_t build_number;
+ u_int32_t platform_id;
+ MDRVA csd_version_rva; /* MDString further identifying the
+ * host OS.
+ * Windows: name of the installed OS
+ * service pack.
+ * Mac OS X: the Apple OS build number
+ * (sw_vers -buildVersion).
+ * Linux: uname -srvmo */
+
+ union {
+ u_int32_t reserved1;
+ struct {
+ u_int16_t suite_mask; /* Windows: VER_SUITE_* from WinNT.h */
+ u_int16_t reserved2;
+ };
+ };
+ MDCPUInformation cpu;
+} MDRawSystemInfo; /* MINIDUMP_SYSTEM_INFO */
+
+/* For (MDRawSystemInfo).processor_architecture: */
+typedef enum {
+ MD_CPU_ARCHITECTURE_X86 = 0, /* PROCESSOR_ARCHITECTURE_INTEL */
+ MD_CPU_ARCHITECTURE_MIPS = 1, /* PROCESSOR_ARCHITECTURE_MIPS */
+ MD_CPU_ARCHITECTURE_ALPHA = 2, /* PROCESSOR_ARCHITECTURE_ALPHA */
+ MD_CPU_ARCHITECTURE_PPC = 3, /* PROCESSOR_ARCHITECTURE_PPC */
+ MD_CPU_ARCHITECTURE_SHX = 4, /* PROCESSOR_ARCHITECTURE_SHX
+ * (Super-H) */
+ MD_CPU_ARCHITECTURE_ARM = 5, /* PROCESSOR_ARCHITECTURE_ARM */
+ MD_CPU_ARCHITECTURE_IA64 = 6, /* PROCESSOR_ARCHITECTURE_IA64 */
+ MD_CPU_ARCHITECTURE_ALPHA64 = 7, /* PROCESSOR_ARCHITECTURE_ALPHA64 */
+ MD_CPU_ARCHITECTURE_MSIL = 8, /* PROCESSOR_ARCHITECTURE_MSIL
+ * (Microsoft Intermediate Language) */
+ MD_CPU_ARCHITECTURE_AMD64 = 9, /* PROCESSOR_ARCHITECTURE_AMD64 */
+ MD_CPU_ARCHITECTURE_X86_WIN64 = 10,
+ /* PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 (WoW64) */
+ MD_CPU_ARCHITECTURE_UNKNOWN = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */
+} MDCPUArchitecture;
+
+/* For (MDRawSystemInfo).platform_id: */
+typedef enum {
+ MD_OS_WIN32S = 0, /* VER_PLATFORM_WIN32s (Windows 3.1) */
+ MD_OS_WIN32_WINDOWS = 1, /* VER_PLATFORM_WIN32_WINDOWS (Windows 95-98-Me) */
+ MD_OS_WIN32_NT = 2, /* VER_PLATFORM_WIN32_NT (Windows NT, 2000+) */
+ MD_OS_WIN32_CE = 3, /* VER_PLATFORM_WIN32_CE, VER_PLATFORM_WIN32_HH
+ * (Windows CE, Windows Mobile, "Handheld") */
+
+ /* The following values are Breakpad-defined. */
+ MD_OS_UNIX = 0x8000, /* Generic Unix-ish */
+ MD_OS_MAC_OS_X = 0x8101, /* Mac OS X/Darwin */
+ MD_OS_LINUX = 0x8201, /* Linux */
+} MDOSPlatform;
+
+
+typedef struct {
+ u_int32_t size_of_info; /* Length of entire MDRawMiscInfo structure. */
+ u_int32_t flags1;
+
+ /* The next field is only valid if flags1 contains
+ * MD_MISCINFO_FLAGS1_PROCESS_ID. */
+ u_int32_t process_id;
+
+ /* The next 3 fields are only valid if flags1 contains
+ * MD_MISCINFO_FLAGS1_PROCESS_TIMES. */
+ u_int32_t process_create_time; /* time_t process started */
+ u_int32_t process_user_time; /* seconds of user CPU time */
+ u_int32_t process_kernel_time; /* seconds of kernel CPU time */
+
+ /* The following fields are not present in MINIDUMP_MISC_INFO but are
+ * in MINIDUMP_MISC_INFO_2. When this struct is populated, these values
+ * may not be set. Use flags1 or sizeOfInfo to determine whether these
+ * values are present. These are only valid when flags1 contains
+ * MD_MISCINFO_FLAGS1_PROCESSOR_POWER_INFO. */
+ u_int32_t processor_max_mhz;
+ u_int32_t processor_current_mhz;
+ u_int32_t processor_mhz_limit;
+ u_int32_t processor_max_idle_state;
+ u_int32_t processor_current_idle_state;
+} MDRawMiscInfo; /* MINIDUMP_MISC_INFO, MINIDUMP_MISC_INFO2 */
+
+#define MD_MISCINFO_SIZE 24
+#define MD_MISCINFO2_SIZE 44
+
+/* For (MDRawMiscInfo).flags1. These values indicate which fields in the
+ * MDRawMiscInfoStructure are valid. */
+typedef enum {
+ MD_MISCINFO_FLAGS1_PROCESS_ID = 0x00000001,
+ /* MINIDUMP_MISC1_PROCESS_ID */
+ MD_MISCINFO_FLAGS1_PROCESS_TIMES = 0x00000002,
+ /* MINIDUMP_MISC1_PROCESS_TIMES */
+ MD_MISCINFO_FLAGS1_PROCESSOR_POWER_INFO = 0x00000004
+ /* MINIDUMP_MISC1_PROCESSOR_POWER_INFO */
+} MDMiscInfoFlags1;
+
+
+/*
+ * Breakpad extension types
+ */
+
+
+typedef struct {
+ /* validity is a bitmask with values from MDBreakpadInfoValidity, indicating
+ * which of the other fields in the structure are valid. */
+ u_int32_t validity;
+
+ /* Thread ID of the handler thread. dump_thread_id should correspond to
+ * the thread_id of an MDRawThread in the minidump's MDRawThreadList if
+ * a dedicated thread in that list was used to produce the minidump. If
+ * the MDRawThreadList does not contain a dedicated thread used to produce
+ * the minidump, this field should be set to 0 and the validity field
+ * must not contain MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID. */
+ u_int32_t dump_thread_id;
+
+ /* Thread ID of the thread that requested the minidump be produced. As
+ * with dump_thread_id, requesting_thread_id should correspond to the
+ * thread_id of an MDRawThread in the minidump's MDRawThreadList. For
+ * minidumps produced as a result of an exception, requesting_thread_id
+ * will be the same as the MDRawExceptionStream's thread_id field. For
+ * minidumps produced "manually" at the program's request,
+ * requesting_thread_id will indicate which thread caused the dump to be
+ * written. If the minidump was produced at the request of something
+ * other than a thread in the MDRawThreadList, this field should be set
+ * to 0 and the validity field must not contain
+ * MD_BREAKPAD_INFO_VALID_REQUESTING_THREAD_ID. */
+ u_int32_t requesting_thread_id;
+} MDRawBreakpadInfo;
+
+/* For (MDRawBreakpadInfo).validity: */
+typedef enum {
+ /* When set, the dump_thread_id field is valid. */
+ MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID = 1 << 0,
+
+ /* When set, the requesting_thread_id field is valid. */
+ MD_BREAKPAD_INFO_VALID_REQUESTING_THREAD_ID = 1 << 1
+} MDBreakpadInfoValidity;
+
+typedef struct {
+ /* expression, function, and file are 0-terminated UTF-16 strings. They
+ * may be truncated if necessary, but should always be 0-terminated when
+ * written to a file.
+ * Fixed-length strings are used because MiniDumpWriteDump doesn't offer
+ * a way for user streams to point to arbitrary RVAs for strings. */
+ u_int16_t expression[128]; /* Assertion that failed... */
+ u_int16_t function[128]; /* ...within this function... */
+ u_int16_t file[128]; /* ...in this file... */
+ u_int32_t line; /* ...at this line. */
+ u_int32_t type;
+} MDRawAssertionInfo;
+
+/* For (MDRawAssertionInfo).info: */
+typedef enum {
+ MD_ASSERTION_INFO_TYPE_UNKNOWN = 0,
+
+ /* Used for assertions that would be raised by the MSVC CRT but are
+ * directed to an invalid parameter handler instead. */
+ MD_ASSERTION_INFO_TYPE_INVALID_PARAMETER
+} MDAssertionInfoData;
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+
+#endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_FORMAT_H__ */
diff --git a/src/google_breakpad/processor/basic_source_line_resolver.h b/src/google_breakpad/processor/basic_source_line_resolver.h
new file mode 100644
index 00000000..2052bacb
--- /dev/null
+++ b/src/google_breakpad/processor/basic_source_line_resolver.h
@@ -0,0 +1,84 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// BasicSourceLineResolver implements SourceLineResolverInterface, using
+// address map files produced by a compatible writer, e.g. PDBSourceLineWriter.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__
+
+#include <ext/hash_map>
+
+#include "google_breakpad/processor/source_line_resolver_interface.h"
+
+namespace google_breakpad {
+
+using std::string;
+using __gnu_cxx::hash_map;
+
+class BasicSourceLineResolver : public SourceLineResolverInterface {
+ public:
+ BasicSourceLineResolver();
+ virtual ~BasicSourceLineResolver();
+
+ // SourceLineResolverInterface methods, see source_line_resolver_interface.h
+ // for more details.
+
+ // Adds a module to this resolver, returning true on success.
+ // The given map_file is read into memory, and its symbols will be
+ // retained until the BasicSourceLineResolver is destroyed.
+ virtual bool LoadModule(const string &module_name, const string &map_file);
+
+ virtual bool HasModule(const string &module_name) const;
+
+ virtual StackFrameInfo* FillSourceLineInfo(StackFrame *frame) const;
+
+ private:
+ template<class T> class MemAddrMap;
+ struct Line;
+ struct Function;
+ struct PublicSymbol;
+ struct File;
+ struct HashString {
+ size_t operator()(const string &s) const;
+ };
+ class Module;
+
+ // All of the modules we've loaded
+ typedef hash_map<string, Module*, HashString> ModuleMap;
+ ModuleMap *modules_;
+
+ // Disallow unwanted copy ctor and assignment operator
+ BasicSourceLineResolver(const BasicSourceLineResolver&);
+ void operator=(const BasicSourceLineResolver&);
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__
diff --git a/src/google_breakpad/processor/call_stack.h b/src/google_breakpad/processor/call_stack.h
new file mode 100644
index 00000000..21f595e7
--- /dev/null
+++ b/src/google_breakpad/processor/call_stack.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// call_stack.h: A call stack comprised of stack frames.
+//
+// This class manages a vector of stack frames. It is used instead of
+// exposing the vector directly to allow the CallStack to own StackFrame
+// pointers without having to publicly export the linked_ptr class. A
+// CallStack must be composed of pointers instead of objects to allow for
+// CPU-specific StackFrame subclasses.
+//
+// By convention, the stack frame at index 0 is the innermost callee frame,
+// and the frame at the highest index in a call stack is the outermost
+// caller. CallStack only allows stacks to be built by pushing frames,
+// beginning with the innermost callee frame.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_CALL_STACK_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_CALL_STACK_H__
+
+#include <vector>
+
+namespace google_breakpad {
+
+using std::vector;
+
+struct StackFrame;
+template<typename T> class linked_ptr;
+
+class CallStack {
+ public:
+ CallStack() { Clear(); }
+ ~CallStack();
+
+ // Resets the CallStack to its initial empty state
+ void Clear();
+
+ const vector<StackFrame*>* frames() const { return &frames_; }
+
+ private:
+ // Stackwalker is responsible for building the frames_ vector.
+ friend class Stackwalker;
+
+ // Storage for pushed frames.
+ vector<StackFrame*> frames_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCSSOR_CALL_STACK_H__
diff --git a/src/google_breakpad/processor/code_module.h b/src/google_breakpad/processor/code_module.h
new file mode 100644
index 00000000..66cda97b
--- /dev/null
+++ b/src/google_breakpad/processor/code_module.h
@@ -0,0 +1,93 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// code_module.h: Carries information about code modules that are loaded
+// into a process.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULE_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULE_H__
+
+#include <string>
+
+namespace google_breakpad {
+
+using std::string;
+
+class CodeModule {
+ public:
+ virtual ~CodeModule() {}
+
+ // The base address of this code module as it was loaded by the process.
+ // (u_int64_t)-1 on error.
+ virtual u_int64_t base_address() const = 0;
+
+ // The size of the code module. 0 on error.
+ virtual u_int64_t size() const = 0;
+
+ // The path or file name that the code module was loaded from. Empty on
+ // error.
+ virtual string code_file() const = 0;
+
+ // An identifying string used to discriminate between multiple versions and
+ // builds of the same code module. This may contain a uuid, timestamp,
+ // version number, or any combination of this or other information, in an
+ // implementation-defined format. Empty on error.
+ virtual string code_identifier() const = 0;
+
+ // The filename containing debugging information associated with the code
+ // module. If debugging information is stored in a file separate from the
+ // code module itself (as is the case when .pdb or .dSYM files are used),
+ // this will be different from code_file. If debugging information is
+ // stored in the code module itself (possibly prior to stripping), this
+ // will be the same as code_file. Empty on error.
+ virtual string debug_file() const = 0;
+
+ // An identifying string similar to code_identifier, but identifies a
+ // specific version and build of the associated debug file. This may be
+ // the same as code_identifier when the debug_file and code_file are
+ // identical or when the same identifier is used to identify distinct
+ // debug and code files.
+ virtual string debug_identifier() const = 0;
+
+ // A human-readable representation of the code module's version. Empty on
+ // error.
+ virtual string version() const = 0;
+
+ // Creates a new copy of this CodeModule object, which the caller takes
+ // ownership of. The new CodeModule may be of a different concrete class
+ // than the CodeModule being copied, but will behave identically to the
+ // copied CodeModule as far as the CodeModule interface is concerned.
+ virtual const CodeModule* Copy() const = 0;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULE_H__
diff --git a/src/google_breakpad/processor/code_modules.h b/src/google_breakpad/processor/code_modules.h
new file mode 100644
index 00000000..29c55d4e
--- /dev/null
+++ b/src/google_breakpad/processor/code_modules.h
@@ -0,0 +1,98 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// code_modules.h: Contains all of the CodeModule objects that were loaded
+// into a single process.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__
+
+#include "google_breakpad/common/breakpad_types.h"
+
+namespace google_breakpad {
+
+class CodeModule;
+
+class CodeModules {
+ public:
+ virtual ~CodeModules() {}
+
+ // The number of contained CodeModule objects.
+ virtual unsigned int module_count() const = 0;
+
+ // Random access to modules. Returns the module whose code is present
+ // at the address indicated by |address|. If no module is present at this
+ // address, returns NULL. Ownership of the returned CodeModule is retained
+ // by the CodeModules object; pointers returned by this method are valid for
+ // comparison with pointers returned by the other Get methods.
+ virtual const CodeModule* GetModuleForAddress(u_int64_t address) const = 0;
+
+ // Returns the module corresponding to the main executable. If there is
+ // no main executable, returns NULL. Ownership of the returned CodeModule
+ // is retained by the CodeModules object; pointers returned by this method
+ // are valid for comparison with pointers returned by the other Get
+ // methods.
+ virtual const CodeModule* GetMainModule() const = 0;
+
+ // Sequential access to modules. A sequence number of 0 corresponds to the
+ // module residing lowest in memory. If the sequence number is out of
+ // range, returns NULL. Ownership of the returned CodeModule is retained
+ // by the CodeModules object; pointers returned by this method are valid for
+ // comparison with pointers returned by the other Get methods.
+ virtual const CodeModule* GetModuleAtSequence(
+ unsigned int sequence) const = 0;
+
+ // Sequential access to modules. This is similar to GetModuleAtSequence,
+ // except no ordering requirement is enforced. A CodeModules implementation
+ // may return CodeModule objects from GetModuleAtIndex in any order it
+ // wishes, provided that the order remain the same throughout the life of
+ // the CodeModules object. Typically, GetModuleAtIndex would be used by
+ // a caller to enumerate all CodeModule objects quickly when the enumeration
+ // does not require any ordering. If the index argument is out of range,
+ // returns NULL. Ownership of the returned CodeModule is retained by
+ // the CodeModules object; pointers returned by this method are valid for
+ // comparison with pointers returned by the other Get methods.
+ virtual const CodeModule* GetModuleAtIndex(unsigned int index) const = 0;
+
+ // Creates a new copy of this CodeModules object, which the caller takes
+ // ownership of. The new object will also contain copies of the existing
+ // object's child CodeModule objects. The new CodeModules object may be of
+ // a different concrete class than the object being copied, but will behave
+ // identically to the copied object as far as the CodeModules and CodeModule
+ // interfaces are concerned, except that the order that GetModuleAtIndex
+ // returns objects in may differ between a copy and the original CodeModules
+ // object.
+ virtual const CodeModules* Copy() const = 0;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULES_H__
diff --git a/src/google_breakpad/processor/memory_region.h b/src/google_breakpad/processor/memory_region.h
new file mode 100644
index 00000000..1ac3fe8d
--- /dev/null
+++ b/src/google_breakpad/processor/memory_region.h
@@ -0,0 +1,76 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// memory_region.h: Access to memory regions.
+//
+// A MemoryRegion provides virtual access to a range of memory. It is an
+// abstraction allowing the actual source of memory to be independent of
+// methods which need to access a virtual memory space.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_MEMORY_REGION_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_MEMORY_REGION_H__
+
+
+#include "google_breakpad/common/breakpad_types.h"
+
+
+namespace google_breakpad {
+
+
+class MemoryRegion {
+ public:
+ virtual ~MemoryRegion() {}
+
+ // The base address of this memory region.
+ virtual u_int64_t GetBase() = 0;
+
+ // The size of this memory region.
+ virtual u_int32_t GetSize() = 0;
+
+ // Access to data of various sizes within the memory region. address
+ // is a pointer to read, and it must lie within the memory region as
+ // defined by its base address and size. The location pointed to by
+ // value is set to the value at address. Byte-swapping is performed
+ // if necessary so that the value is appropriate for the running
+ // program. Returns true on success. Fails and returns false if address
+ // is out of the region's bounds (after considering the width of value),
+ // or for other types of errors.
+ virtual bool GetMemoryAtAddress(u_int64_t address, u_int8_t* value) = 0;
+ virtual bool GetMemoryAtAddress(u_int64_t address, u_int16_t* value) = 0;
+ virtual bool GetMemoryAtAddress(u_int64_t address, u_int32_t* value) = 0;
+ virtual bool GetMemoryAtAddress(u_int64_t address, u_int64_t* value) = 0;
+};
+
+
+} // namespace google_breakpad
+
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_MEMORY_REGION_H__
diff --git a/src/google_breakpad/processor/minidump.h b/src/google_breakpad/processor/minidump.h
new file mode 100644
index 00000000..b632654d
--- /dev/null
+++ b/src/google_breakpad/processor/minidump.h
@@ -0,0 +1,813 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.h: A minidump reader.
+//
+// The basic structure of this module tracks the structure of the minidump
+// file itself. At the top level, a minidump file is represented by a
+// Minidump object. Like most other classes in this module, Minidump
+// provides a Read method that initializes the object with information from
+// the file. Most of the classes in this file are wrappers around the
+// "raw" structures found in the minidump file itself, and defined in
+// minidump_format.h. For example, each thread is represented by a
+// MinidumpThread object, whose parameters are specified in an MDRawThread
+// structure. A properly byte-swapped MDRawThread can be obtained from a
+// MinidumpThread easily by calling its thread() method.
+//
+// Most of the module lazily reads only the portion of the minidump file
+// necessary to fulfill the user's request. Calling Minidump::Read
+// only reads the minidump's directory. The thread list is not read until
+// it is needed, and even once it's read, the memory regions for each
+// thread's stack aren't read until they're needed. This strategy avoids
+// unnecessary file input, and allocating memory for data in which the user
+// has no interest. Note that although memory allocations for a typical
+// minidump file are not particularly large, it is possible for legitimate
+// minidumps to be sizable. A full-memory minidump, for example, contains
+// a snapshot of the entire mapped memory space. Even a normal minidump,
+// with stack memory only, can be large if, for example, the dump was
+// generated in response to a crash that occurred due to an infinite-
+// recursion bug that caused the stack's limits to be exceeded. Finally,
+// some users of this library will unfortunately find themselves in the
+// position of having to process potentially-hostile minidumps that might
+// attempt to cause problems by forcing the minidump processor to over-
+// allocate memory.
+//
+// Memory management in this module is based on a strict
+// you-don't-own-anything policy. The only object owned by the user is
+// the top-level Minidump object, the creation and destruction of which
+// must be the user's own responsibility. All other objects obtained
+// through interaction with this module are ultimately owned by the
+// Minidump object, and will be freed upon the Minidump object's destruction.
+// Because memory regions can potentially involve large allocations, a
+// FreeMemory method is provided by MinidumpMemoryRegion, allowing the user
+// to release data when it is no longer needed. Use of this method is
+// optional but recommended. If freed data is later required, it will
+// be read back in from the minidump file again.
+//
+// There is one exception to this memory management policy:
+// Minidump::ReadString will return a string object to the user, and the user
+// is responsible for its deletion.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__
+
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "google_breakpad/common/minidump_format.h"
+#include "google_breakpad/processor/code_module.h"
+#include "google_breakpad/processor/code_modules.h"
+#include "google_breakpad/processor/memory_region.h"
+
+
+namespace google_breakpad {
+
+
+using std::map;
+using std::string;
+using std::vector;
+
+
+class Minidump;
+template<typename AddressType, typename EntryType> class RangeMap;
+
+
+// MinidumpObject is the base of all Minidump* objects except for Minidump
+// itself.
+class MinidumpObject {
+ public:
+ virtual ~MinidumpObject() {}
+
+ protected:
+ explicit MinidumpObject(Minidump* minidump);
+
+ // Refers to the Minidump object that is the ultimate parent of this
+ // Some MinidumpObjects are owned by other MinidumpObjects, but at the
+ // root of the ownership tree is always a Minidump. The Minidump object
+ // is kept here for access to its seeking and reading facilities, and
+ // for access to data about the minidump file itself, such as whether
+ // it should be byte-swapped.
+ Minidump* minidump_;
+
+ // MinidumpObjects are not valid when created. When a subclass populates
+ // its own fields, it can set valid_ to true. Accessors and mutators may
+ // wish to consider or alter the valid_ state as they interact with
+ // objects.
+ bool valid_;
+};
+
+
+// This class exists primarily to provide a virtual destructor in a base
+// class common to all objects that might be stored in
+// Minidump::mStreamObjects. Some object types (MinidumpContext) will
+// never be stored in Minidump::mStreamObjects, but are represented as
+// streams and adhere to the same interface, and may be derived from
+// this class.
+class MinidumpStream : public MinidumpObject {
+ public:
+ virtual ~MinidumpStream() {}
+
+ protected:
+ explicit MinidumpStream(Minidump* minidump);
+
+ private:
+ // Populate (and validate) the MinidumpStream. minidump_ is expected
+ // to be positioned at the beginning of the stream, so that the next
+ // read from the minidump will be at the beginning of the stream.
+ // expected_size should be set to the stream's length as contained in
+ // the MDRawDirectory record or other identifying record. A class
+ // that implements MinidumpStream can compare expected_size to a
+ // known size as an integrity check.
+ virtual bool Read(u_int32_t expected_size) = 0;
+};
+
+
+// MinidumpContext carries a CPU-specific MDRawContext structure, which
+// contains CPU context such as register states. Each thread has its
+// own context, and the exception record, if present, also has its own
+// context. Note that if the exception record is present, the context it
+// refers to is probably what the user wants to use for the exception
+// thread, instead of that thread's own context. The exception thread's
+// context (as opposed to the exception record's context) will contain
+// context for the exception handler (which performs minidump generation),
+// and not the context that caused the exception (which is probably what the
+// user wants).
+class MinidumpContext : public MinidumpStream {
+ public:
+ virtual ~MinidumpContext();
+
+ // Returns an MD_CONTEXT_* value such as MD_CONTEXT_X86 or MD_CONTEXT_PPC
+ // identifying the CPU type that the context was collected from. The
+ // returned value will identify the CPU only, and will have any other
+ // MD_CONTEXT_* bits masked out. Returns 0 on failure.
+ u_int32_t GetContextCPU() const;
+
+ // Returns raw CPU-specific context data for the named CPU type. If the
+ // context data does not match the CPU type or does not exist, returns
+ // NULL.
+ const MDRawContextX86* GetContextX86() const;
+ const MDRawContextPPC* GetContextPPC() const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class MinidumpThread;
+ friend class MinidumpException;
+
+ explicit MinidumpContext(Minidump* minidump);
+
+ bool Read(u_int32_t expected_size);
+
+ // Free the CPU-specific context structure.
+ void FreeContext();
+
+ // If the minidump contains a SYSTEM_INFO_STREAM, makes sure that the
+ // system info stream gives an appropriate CPU type matching the context
+ // CPU type in context_cpu_type. Returns false if the CPU type does not
+ // match. Returns true if the CPU type matches or if the minidump does
+ // not contain a system info stream.
+ bool CheckAgainstSystemInfo(u_int32_t context_cpu_type);
+
+ // The CPU-specific context structure.
+ union {
+ MDRawContextBase* base;
+ MDRawContextX86* x86;
+ MDRawContextPPC* ppc;
+ } context_;
+};
+
+
+// MinidumpMemoryRegion does not wrap any MDRaw structure, and only contains
+// a reference to an MDMemoryDescriptor. This object is intended to wrap
+// portions of a minidump file that contain memory dumps. In normal
+// minidumps, each MinidumpThread owns a MinidumpMemoryRegion corresponding
+// to the thread's stack memory. MinidumpMemoryList also gives access to
+// memory regions in its list as MinidumpMemoryRegions. This class
+// adheres to MemoryRegion so that it may be used as a data provider to
+// the Stackwalker family of classes.
+class MinidumpMemoryRegion : public MinidumpObject,
+ public MemoryRegion {
+ public:
+ virtual ~MinidumpMemoryRegion();
+
+ // Returns a pointer to the base of the memory region. Returns the
+ // cached value if available, otherwise, reads the minidump file and
+ // caches the memory region.
+ const u_int8_t* GetMemory();
+
+ // The address of the base of the memory region.
+ u_int64_t GetBase();
+
+ // The size, in bytes, of the memory region.
+ u_int32_t GetSize();
+
+ // Frees the cached memory region, if cached.
+ void FreeMemory();
+
+ // Obtains the value of memory at the pointer specified by address.
+ bool GetMemoryAtAddress(u_int64_t address, u_int8_t* value);
+ bool GetMemoryAtAddress(u_int64_t address, u_int16_t* value);
+ bool GetMemoryAtAddress(u_int64_t address, u_int32_t* value);
+ bool GetMemoryAtAddress(u_int64_t address, u_int64_t* value);
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class MinidumpThread;
+ friend class MinidumpMemoryList;
+
+ explicit MinidumpMemoryRegion(Minidump* minidump);
+
+ // Identify the base address and size of the memory region, and the
+ // location it may be found in the minidump file.
+ void SetDescriptor(MDMemoryDescriptor* descriptor);
+
+ // Implementation for GetMemoryAtAddress
+ template<typename T> bool GetMemoryAtAddressInternal(u_int64_t address,
+ T* value);
+
+ // Base address and size of the memory region, and its position in the
+ // minidump file.
+ MDMemoryDescriptor* descriptor_;
+
+ // Cached memory.
+ vector<u_int8_t>* memory_;
+};
+
+
+// MinidumpThread contains information about a thread of execution,
+// including a snapshot of the thread's stack and CPU context. For
+// the thread that caused an exception, the context carried by
+// MinidumpException is probably desired instead of the CPU context
+// provided here.
+class MinidumpThread : public MinidumpObject {
+ public:
+ virtual ~MinidumpThread();
+
+ const MDRawThread* thread() const { return valid_ ? &thread_ : NULL; }
+ MinidumpMemoryRegion* GetMemory();
+ MinidumpContext* GetContext();
+
+ // The thread ID is used to determine if a thread is the exception thread,
+ // so a special getter is provided to retrieve this data from the
+ // MDRawThread structure. Returns false if the thread ID cannot be
+ // determined.
+ bool GetThreadID(u_int32_t *thread_id) const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ // These objects are managed by MinidumpThreadList.
+ friend class MinidumpThreadList;
+
+ explicit MinidumpThread(Minidump* minidump);
+
+ // This works like MinidumpStream::Read, but is driven by
+ // MinidumpThreadList. No size checking is done, because
+ // MinidumpThreadList handles that directly.
+ bool Read();
+
+ MDRawThread thread_;
+ MinidumpMemoryRegion* memory_;
+ MinidumpContext* context_;
+};
+
+
+// MinidumpThreadList contains all of the threads (as MinidumpThreads) in
+// a process.
+class MinidumpThreadList : public MinidumpStream {
+ public:
+ virtual ~MinidumpThreadList();
+
+ unsigned int thread_count() const { return valid_ ? thread_count_ : 0; }
+
+ // Sequential access to threads.
+ MinidumpThread* GetThreadAtIndex(unsigned int index) const;
+
+ // Random access to threads.
+ MinidumpThread* GetThreadByID(u_int32_t thread_id);
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ typedef map<u_int32_t, MinidumpThread*> IDToThreadMap;
+ typedef vector<MinidumpThread> MinidumpThreads;
+
+ static const u_int32_t kStreamType = MD_THREAD_LIST_STREAM;
+
+ explicit MinidumpThreadList(Minidump* aMinidump);
+
+ bool Read(u_int32_t aExpectedSize);
+
+ // Access to threads using the thread ID as the key.
+ IDToThreadMap id_to_thread_map_;
+
+ // The list of threads.
+ MinidumpThreads* threads_;
+ u_int32_t thread_count_;
+};
+
+
+// MinidumpModule wraps MDRawModule, which contains information about loaded
+// code modules. Access is provided to various data referenced indirectly
+// by MDRawModule, such as the module's name and a specification for where
+// to locate debugging information for the module.
+class MinidumpModule : public MinidumpObject,
+ public CodeModule {
+ public:
+ virtual ~MinidumpModule();
+
+ const MDRawModule* module() const { return valid_ ? &module_ : NULL; }
+
+ // CodeModule implementation
+ virtual u_int64_t base_address() const {
+ return valid_ ? module_.base_of_image : static_cast<u_int64_t>(-1);
+ }
+ virtual u_int64_t size() const { return valid_ ? module_.size_of_image : 0; }
+ virtual string code_file() const;
+ virtual string code_identifier() const;
+ virtual string debug_file() const;
+ virtual string debug_identifier() const;
+ virtual string version() const;
+ virtual const CodeModule* Copy() const;
+
+ // The CodeView record, which contains information to locate the module's
+ // debugging information (pdb). This is returned as u_int8_t* because
+ // the data can be of types MDCVInfoPDB20* or MDCVInfoPDB70*, or it may be
+ // of a type unknown to Breakpad, in which case the raw data will still be
+ // returned but no byte-swapping will have been performed. Check the
+ // record's signature in the first four bytes to differentiate between
+ // the various types. Current toolchains generate modules which carry
+ // MDCVInfoPDB70 by default. Returns a pointer to the CodeView record on
+ // success, and NULL on failure. On success, the optional |size| argument
+ // is set to the size of the CodeView record.
+ const u_int8_t* GetCVRecord(u_int32_t* size);
+
+ // The miscellaneous debug record, which is obsolete. Current toolchains
+ // do not generate this type of debugging information (dbg), and this
+ // field is not expected to be present. Returns a pointer to the debugging
+ // record on success, and NULL on failure. On success, the optional |size|
+ // argument is set to the size of the debugging record.
+ const MDImageDebugMisc* GetMiscRecord(u_int32_t* size);
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ // These objects are managed by MinidumpModuleList.
+ friend class MinidumpModuleList;
+
+ explicit MinidumpModule(Minidump* minidump);
+
+ // This works like MinidumpStream::Read, but is driven by
+ // MinidumpModuleList. No size checking is done, because
+ // MinidumpModuleList handles that directly.
+ bool Read();
+
+ // Reads indirectly-referenced data, including the module name, CodeView
+ // record, and miscellaneous debugging record. This is necessary to allow
+ // MinidumpModuleList to fully construct MinidumpModule objects without
+ // requiring seeks to read a contiguous set of MinidumpModule objects.
+ // All auxiliary data should be available when Read is called, in order to
+ // allow the CodeModule getters to be const methods.
+ bool ReadAuxiliaryData();
+
+ // True after a successful Read. This is different from valid_, which is
+ // not set true until ReadAuxiliaryData also completes successfully.
+ // module_valid_ is only used by ReadAuxiliaryData and the functions it
+ // calls to determine whether the object is ready for auxiliary data to
+ // be read.
+ bool module_valid_;
+
+ MDRawModule module_;
+
+ // Cached module name.
+ const string* name_;
+
+ // Cached CodeView record - this is MDCVInfoPDB20 or (likely)
+ // MDCVInfoPDB70, or possibly something else entirely. Stored as a u_int8_t
+ // because the structure contains a variable-sized string and its exact
+ // size cannot be known until it is processed.
+ vector<u_int8_t>* cv_record_;
+
+ // If cv_record_ is present, cv_record_signature_ contains a copy of the
+ // CodeView record's first four bytes, for ease of determinining the
+ // type of structure that cv_record_ contains.
+ u_int32_t cv_record_signature_;
+
+ // Cached MDImageDebugMisc (usually not present), stored as u_int8_t
+ // because the structure contains a variable-sized string and its exact
+ // size cannot be known until it is processed.
+ vector<u_int8_t>* misc_record_;
+};
+
+
+// MinidumpModuleList contains all of the loaded code modules for a process
+// in the form of MinidumpModules. It maintains a map of these modules
+// so that it may easily provide a code module corresponding to a specific
+// address.
+class MinidumpModuleList : public MinidumpStream,
+ public CodeModules {
+ public:
+ virtual ~MinidumpModuleList();
+
+ // CodeModules implementation.
+ virtual unsigned int module_count() const {
+ return valid_ ? module_count_ : 0;
+ }
+ virtual const MinidumpModule* GetModuleForAddress(u_int64_t address) const;
+ virtual const MinidumpModule* GetMainModule() const;
+ virtual const MinidumpModule* GetModuleAtSequence(
+ unsigned int sequence) const;
+ virtual const MinidumpModule* GetModuleAtIndex(unsigned int index) const;
+ virtual const CodeModules* Copy() const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ typedef vector<MinidumpModule> MinidumpModules;
+
+ static const u_int32_t kStreamType = MD_MODULE_LIST_STREAM;
+
+ explicit MinidumpModuleList(Minidump* minidump);
+
+ bool Read(u_int32_t expected_size);
+
+ // Access to modules using addresses as the key.
+ RangeMap<u_int64_t, unsigned int> *range_map_;
+
+ MinidumpModules *modules_;
+ u_int32_t module_count_;
+};
+
+
+// MinidumpMemoryList corresponds to a minidump's MEMORY_LIST_STREAM stream,
+// which references the snapshots of all of the memory regions contained
+// within the minidump. For a normal minidump, this includes stack memory
+// (also referenced by each MinidumpThread, in fact, the MDMemoryDescriptors
+// here and in MDRawThread both point to exactly the same data in a
+// minidump file, conserving space), as well as a 256-byte snapshot of memory
+// surrounding the instruction pointer in the case of an exception. Other
+// types of minidumps may contain significantly more memory regions. Full-
+// memory minidumps contain all of a process' mapped memory.
+class MinidumpMemoryList : public MinidumpStream {
+ public:
+ virtual ~MinidumpMemoryList();
+
+ unsigned int region_count() const { return valid_ ? region_count_ : 0; }
+
+ // Sequential access to memory regions.
+ MinidumpMemoryRegion* GetMemoryRegionAtIndex(unsigned int index);
+
+ // Random access to memory regions. Returns the region encompassing
+ // the address identified by address.
+ MinidumpMemoryRegion* GetMemoryRegionForAddress(u_int64_t address);
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ typedef vector<MDMemoryDescriptor> MemoryDescriptors;
+ typedef vector<MinidumpMemoryRegion> MemoryRegions;
+
+ static const u_int32_t kStreamType = MD_MEMORY_LIST_STREAM;
+
+ explicit MinidumpMemoryList(Minidump* minidump);
+
+ bool Read(u_int32_t expected_size);
+
+ // Access to memory regions using addresses as the key.
+ RangeMap<u_int64_t, unsigned int> *range_map_;
+
+ // The list of descriptors. This is maintained separately from the list
+ // of regions, because MemoryRegion doesn't own its MemoryDescriptor, it
+ // maintains a pointer to it. descriptors_ provides the storage for this
+ // purpose.
+ MemoryDescriptors *descriptors_;
+
+ // The list of regions.
+ MemoryRegions *regions_;
+ u_int32_t region_count_;
+};
+
+
+// MinidumpException wraps MDRawExceptionStream, which contains information
+// about the exception that caused the minidump to be generated, if the
+// minidump was generated in an exception handler called as a result of
+// an exception. It also provides access to a MinidumpContext object,
+// which contains the CPU context for the exception thread at the time
+// the exception occurred.
+class MinidumpException : public MinidumpStream {
+ public:
+ virtual ~MinidumpException();
+
+ const MDRawExceptionStream* exception() const {
+ return valid_ ? &exception_ : NULL;
+ }
+
+ // The thread ID is used to determine if a thread is the exception thread,
+ // so a special getter is provided to retrieve this data from the
+ // MDRawExceptionStream structure. Returns false if the thread ID cannot
+ // be determined.
+ bool GetThreadID(u_int32_t *thread_id) const;
+
+ MinidumpContext* GetContext();
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ static const u_int32_t kStreamType = MD_EXCEPTION_STREAM;
+
+ explicit MinidumpException(Minidump* minidump);
+
+ bool Read(u_int32_t expected_size);
+
+ MDRawExceptionStream exception_;
+ MinidumpContext* context_;
+};
+
+
+// MinidumpSystemInfo wraps MDRawSystemInfo and provides information about
+// the system on which the minidump was generated. See also MinidumpMiscInfo.
+class MinidumpSystemInfo : public MinidumpStream {
+ public:
+ virtual ~MinidumpSystemInfo();
+
+ const MDRawSystemInfo* system_info() const {
+ return valid_ ? &system_info_ : NULL;
+ }
+
+ // GetOS and GetCPU return textual representations of the operating system
+ // and CPU that produced the minidump. Unlike most other Minidump* methods,
+ // they return string objects, not weak pointers. Defined values for
+ // GetOS() are "mac", "windows", and "linux". Defined values for GetCPU
+ // are "x86" and "ppc". These methods return an empty string when their
+ // values are unknown.
+ string GetOS();
+ string GetCPU();
+
+ // I don't know what CSD stands for, but this field is documented as
+ // returning a textual representation of the OS service pack. On other
+ // platforms, this provides additional information about an OS version
+ // level beyond major.minor.micro. Returns NULL if unknown.
+ const string* GetCSDVersion();
+
+ // If a CPU vendor string can be determined, returns a pointer to it,
+ // otherwise, returns NULL. CPU vendor strings can be determined from
+ // x86 CPUs with CPUID 0.
+ const string* GetCPUVendor();
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ static const u_int32_t kStreamType = MD_SYSTEM_INFO_STREAM;
+
+ explicit MinidumpSystemInfo(Minidump* minidump);
+
+ bool Read(u_int32_t expected_size);
+
+ MDRawSystemInfo system_info_;
+
+ // Textual representation of the OS service pack, for minidumps produced
+ // by MiniDumpWriteDump on Windows.
+ const string* csd_version_;
+
+ // A string identifying the CPU vendor, if known.
+ const string* cpu_vendor_;
+};
+
+
+// MinidumpMiscInfo wraps MDRawMiscInfo and provides information about
+// the process that generated the minidump, and optionally additional system
+// information. See also MinidumpSystemInfo.
+class MinidumpMiscInfo : public MinidumpStream {
+ public:
+ const MDRawMiscInfo* misc_info() const {
+ return valid_ ? &misc_info_ : NULL;
+ }
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ static const u_int32_t kStreamType = MD_MISC_INFO_STREAM;
+
+ explicit MinidumpMiscInfo(Minidump* minidump_);
+
+ bool Read(u_int32_t expected_size_);
+
+ MDRawMiscInfo misc_info_;
+};
+
+
+// MinidumpBreakpadInfo wraps MDRawBreakpadInfo, which is an optional stream in
+// a minidump that provides additional information about the process state
+// at the time the minidump was generated.
+class MinidumpBreakpadInfo : public MinidumpStream {
+ public:
+ const MDRawBreakpadInfo* breakpad_info() const {
+ return valid_ ? &breakpad_info_ : NULL;
+ }
+
+ // These thread IDs are used to determine if threads deserve special
+ // treatment, so special getters are provided to retrieve this data from
+ // the MDRawBreakpadInfo structure. The getters return false if the thread
+ // IDs cannot be determined.
+ bool GetDumpThreadID(u_int32_t *thread_id) const;
+ bool GetRequestingThreadID(u_int32_t *thread_id) const;
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ friend class Minidump;
+
+ static const u_int32_t kStreamType = MD_BREAKPAD_INFO_STREAM;
+
+ explicit MinidumpBreakpadInfo(Minidump* minidump_);
+
+ bool Read(u_int32_t expected_size_);
+
+ MDRawBreakpadInfo breakpad_info_;
+};
+
+
+// Minidump is the user's interface to a minidump file. It wraps MDRawHeader
+// and provides access to the minidump's top-level stream directory.
+class Minidump {
+ public:
+ // path is the pathname of a file containing the minidump.
+ explicit Minidump(const string& path);
+
+ ~Minidump();
+
+ const MDRawHeader* header() const { return valid_ ? &header_ : NULL; }
+
+ // Reads the minidump file's header and top-level stream directory.
+ // The minidump is expected to be positioned at the beginning of the
+ // header. Read() sets up the stream list and map, and validates the
+ // Minidump object.
+ bool Read();
+
+ // The next set of methods are stubs that call GetStream. They exist to
+ // force code generation of the templatized API within the module, and
+ // to avoid exposing an ugly API (GetStream needs to accept a garbage
+ // parameter).
+ MinidumpThreadList* GetThreadList();
+ MinidumpModuleList* GetModuleList();
+ MinidumpMemoryList* GetMemoryList();
+ MinidumpException* GetException();
+ MinidumpSystemInfo* GetSystemInfo();
+ MinidumpMiscInfo* GetMiscInfo();
+ MinidumpBreakpadInfo* GetBreakpadInfo();
+
+ // The next set of methods are provided for users who wish to access
+ // data in minidump files directly, while leveraging the rest of
+ // this class and related classes to handle the basic minidump
+ // structure and known stream types.
+
+ unsigned int GetDirectoryEntryCount() const {
+ return valid_ ? header_.stream_count : 0;
+ }
+ const MDRawDirectory* GetDirectoryEntryAtIndex(unsigned int index) const;
+
+ // The next 2 methods are lower-level I/O routines. They use fd_.
+
+ // Reads count bytes from the minidump at the current position into
+ // the storage area pointed to by bytes. bytes must be of sufficient
+ // size. After the read, the file position is advanced by count.
+ bool ReadBytes(void* bytes, size_t count);
+
+ // Sets the position of the minidump file to offset.
+ bool SeekSet(off_t offset);
+
+ // The next 2 methods are medium-level I/O routines.
+
+ // ReadString returns a string which is owned by the caller! offset
+ // specifies the offset that a length-encoded string is stored at in the
+ // minidump file.
+ string* ReadString(off_t offset);
+
+ // SeekToStreamType positions the file at the beginning of a stream
+ // identified by stream_type, and informs the caller of the stream's
+ // length by setting *stream_length. Because stream_map maps each stream
+ // type to only one stream in the file, this might mislead the user into
+ // thinking that the stream that this seeks to is the only stream with
+ // type stream_type. That can't happen for streams that these classes
+ // deal with directly, because they're only supposed to be present in the
+ // file singly, and that's verified when stream_map_ is built. Users who
+ // are looking for other stream types should be aware of this
+ // possibility, and consider using GetDirectoryEntryAtIndex (possibly
+ // with GetDirectoryEntryCount) if expecting multiple streams of the same
+ // type in a single minidump file.
+ bool SeekToStreamType(u_int32_t stream_type, u_int32_t* stream_length);
+
+ bool swap() const { return valid_ ? swap_ : false; }
+
+ // Print a human-readable representation of the object to stdout.
+ void Print();
+
+ private:
+ // MinidumpStreamInfo is used in the MinidumpStreamMap. It lets
+ // the Minidump object locate interesting streams quickly, and
+ // provides a convenient place to stash MinidumpStream objects.
+ struct MinidumpStreamInfo {
+ MinidumpStreamInfo() : stream_index(0), stream(NULL) {}
+ ~MinidumpStreamInfo() { delete stream; }
+
+ // Index into the MinidumpDirectoryEntries vector
+ unsigned int stream_index;
+
+ // Pointer to the stream if cached, or NULL if not yet populated
+ MinidumpStream* stream;
+ };
+
+ typedef vector<MDRawDirectory> MinidumpDirectoryEntries;
+ typedef map<u_int32_t, MinidumpStreamInfo> MinidumpStreamMap;
+
+ template<typename T> T* GetStream(T** stream);
+
+ // Opens the minidump file, or if already open, seeks to the beginning.
+ bool Open();
+
+ MDRawHeader header_;
+
+ // The list of streams.
+ MinidumpDirectoryEntries* directory_;
+
+ // Access to streams using the stream type as the key.
+ MinidumpStreamMap* stream_map_;
+
+ // The pathname of the minidump file to process, set in the constructor.
+ const string path_;
+
+ // The file descriptor for all file I/O. Used by ReadBytes and SeekSet.
+ // Set based on the |path_| member by Open, which is called by Read.
+ int fd_;
+
+ // swap_ is true if the minidump file should be byte-swapped. If the
+ // minidump was produced by a CPU that is other-endian than the CPU
+ // processing the minidump, this will be true. If the two CPUs are
+ // same-endian, this will be false.
+ bool swap_;
+
+ // Validity of the Minidump structure, false immediately after
+ // construction or after a failed Read(); true following a successful
+ // Read().
+ bool valid_;
+};
+
+
+} // namespace google_breakpad
+
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__
diff --git a/src/google_breakpad/processor/minidump_processor.h b/src/google_breakpad/processor/minidump_processor.h
new file mode 100644
index 00000000..9c53ed74
--- /dev/null
+++ b/src/google_breakpad/processor/minidump_processor.h
@@ -0,0 +1,91 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
+
+#include <string>
+
+namespace google_breakpad {
+
+using std::string;
+
+class Minidump;
+class ProcessState;
+class SourceLineResolverInterface;
+class SymbolSupplier;
+class SystemInfo;
+
+class MinidumpProcessor {
+ public:
+ // Return type for Process()
+ enum ProcessResult {
+ PROCESS_OK, // the minidump was processed successfully
+ PROCESS_ERROR, // there was an error processing the minidump
+ PROCESS_INTERRUPTED, // processing was interrupted by the SymbolSupplier
+ };
+
+ // Initializes this MinidumpProcessor. supplier should be an
+ // implementation of the SymbolSupplier abstract base class.
+ MinidumpProcessor(SymbolSupplier *supplier,
+ SourceLineResolverInterface *resolver);
+ ~MinidumpProcessor();
+
+ // Processes the minidump file and fills process_state with the result.
+ ProcessResult Process(const string &minidump_file,
+ ProcessState *process_state);
+
+ // Populates the cpu_* fields of the |info| parameter with textual
+ // representations of the CPU type that the minidump in |dump| was
+ // produced on.
+ static void GetCPUInfo(Minidump *dump, SystemInfo *info);
+
+ // Populates the os_* fields of the |info| parameter with textual
+ // representations of the operating system that the minidump in |dump|
+ // was produced on.
+ static void GetOSInfo(Minidump *dump, SystemInfo *info);
+
+ // Returns a textual representation of the reason that a crash occurred,
+ // if the minidump in dump was produced as a result of a crash. Returns
+ // an empty string if this information cannot be determined. If address
+ // is non-NULL, it will be set to contain the address that caused the
+ // exception, if this information is available. This will be a code
+ // address when the crash was caused by problems such as illegal
+ // instructions or divisions by zero, or a data address when the crash
+ // was caused by a memory access violation.
+ static string GetCrashReason(Minidump *dump, u_int64_t *address);
+
+ private:
+ SymbolSupplier *supplier_;
+ SourceLineResolverInterface *resolver_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
diff --git a/src/google_breakpad/processor/process_state.h b/src/google_breakpad/processor/process_state.h
new file mode 100644
index 00000000..af95247e
--- /dev/null
+++ b/src/google_breakpad/processor/process_state.h
@@ -0,0 +1,114 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// process_state.h: A snapshot of a process, in a fully-digested state.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__
+
+#include <string>
+#include <vector>
+#include "google_breakpad/processor/system_info.h"
+
+namespace google_breakpad {
+
+using std::string;
+using std::vector;
+
+class CallStack;
+class CodeModules;
+
+class ProcessState {
+ public:
+ ProcessState() : modules_(NULL) { Clear(); }
+ ~ProcessState();
+
+ // Resets the ProcessState to its default values
+ void Clear();
+
+ // Accessors. See the data declarations below.
+ u_int32_t time_date_stamp() const { return time_date_stamp_; }
+ bool crashed() const { return crashed_; }
+ string crash_reason() const { return crash_reason_; }
+ u_int64_t crash_address() const { return crash_address_; }
+ int requesting_thread() const { return requesting_thread_; }
+ const vector<CallStack*>* threads() const { return &threads_; }
+ const SystemInfo* system_info() const { return &system_info_; }
+ const CodeModules* modules() const { return modules_; }
+
+ private:
+ // MinidumpProcessor is responsible for building ProcessState objects.
+ friend class MinidumpProcessor;
+
+ // The time-date stamp of the minidump (time_t format)
+ u_int32_t time_date_stamp_;
+
+ // True if the process crashed, false if the dump was produced outside
+ // of an exception handler.
+ bool crashed_;
+
+ // If the process crashed, the type of crash. OS- and possibly CPU-
+ // specific. For example, "EXCEPTION_ACCESS_VIOLATION" (Windows),
+ // "EXC_BAD_ACCESS / KERN_INVALID_ADDRESS" (Mac OS X), "SIGSEGV"
+ // (other Unix).
+ string crash_reason_;
+
+ // If the process crashed, and if crash_reason implicates memory,
+ // the memory address that caused the crash. For data access errors,
+ // this will be the data address that caused the fault. For code errors,
+ // this will be the address of the instruction that caused the fault.
+ u_int64_t crash_address_;
+
+ // The index of the thread that requested a dump be written in the
+ // threads vector. If a dump was produced as a result of a crash, this
+ // will point to the thread that crashed. If the dump was produced as
+ // by user code without crashing, and the dump contains extended Breakpad
+ // information, this will point to the thread that requested the dump.
+ // If the dump was not produced as a result of an exception and no
+ // extended Breakpad information is present, this field will be set to -1,
+ // indicating that the dump thread is not available.
+ int requesting_thread_;
+
+ // Stacks for each thread (except possibly the exception handler
+ // thread) at the time of the crash.
+ vector<CallStack*> threads_;
+
+ // OS and CPU information.
+ SystemInfo system_info_;
+
+ // The modules that were loaded into the process represented by the
+ // ProcessState.
+ const CodeModules *modules_;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_PROCESS_STATE_H__
diff --git a/src/google_breakpad/processor/source_line_resolver_interface.h b/src/google_breakpad/processor/source_line_resolver_interface.h
new file mode 100644
index 00000000..192177b2
--- /dev/null
+++ b/src/google_breakpad/processor/source_line_resolver_interface.h
@@ -0,0 +1,79 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// Abstract interface to return function/file/line info for a memory address.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
+
+#include <string>
+#include "google_breakpad/common/breakpad_types.h"
+
+namespace google_breakpad {
+
+using std::string;
+
+struct StackFrame;
+struct StackFrameInfo;
+
+class SourceLineResolverInterface {
+ public:
+ typedef u_int64_t MemAddr;
+
+ virtual ~SourceLineResolverInterface() {}
+
+ // Adds a module to this resolver, returning true on success.
+ //
+ // module_name may be an arbitrary string. Typically, it will be the
+ // filename of the module, optionally with version identifiers.
+ //
+ // map_file should contain line/address mappings for this module.
+ virtual bool LoadModule(const string &module_name,
+ const string &map_file) = 0;
+
+ // Returns true if a module with the given name has been loaded.
+ virtual bool HasModule(const string &module_name) const = 0;
+
+ // Fills in the function_base, function_name, source_file_name,
+ // and source_line fields of the StackFrame. The instruction and
+ // module_name fields must already be filled in. Additional debugging
+ // information, if available, is returned. If the information is not
+ // available, returns NULL. A NULL return value does not indicate an
+ // error. The caller takes ownership of any returned StackFrameInfo
+ // object.
+ virtual StackFrameInfo* FillSourceLineInfo(StackFrame *frame) const = 0;
+
+ protected:
+ // SourceLineResolverInterface cannot be instantiated except by subclasses
+ SourceLineResolverInterface() {}
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__
diff --git a/src/google_breakpad/processor/stack_frame.h b/src/google_breakpad/processor/stack_frame.h
new file mode 100644
index 00000000..b330f8ae
--- /dev/null
+++ b/src/google_breakpad/processor/stack_frame.h
@@ -0,0 +1,84 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__
+
+#include <string>
+#include "google_breakpad/common/breakpad_types.h"
+
+namespace google_breakpad {
+
+class CodeModule;
+
+using std::string;
+
+struct StackFrame {
+ StackFrame()
+ : instruction(),
+ module(NULL),
+ function_name(),
+ function_base(),
+ source_file_name(),
+ source_line(),
+ source_line_base() {}
+ virtual ~StackFrame() {}
+
+ // The program counter location as an absolute virtual address. For the
+ // innermost called frame in a stack, this will be an exact program counter
+ // or instruction pointer value. For all other frames, this will be within
+ // the instruction that caused execution to branch to a called function,
+ // but may not necessarily point to the exact beginning of that instruction.
+ u_int64_t instruction;
+
+ // The module in which the instruction resides.
+ const CodeModule *module;
+
+ // The function name, may be omitted if debug symbols are not available.
+ string function_name;
+
+ // The start address of the function, may be omitted if debug symbols
+ // are not available.
+ u_int64_t function_base;
+
+ // The source file name, may be omitted if debug symbols are not available.
+ string source_file_name;
+
+ // The (1-based) source line number, may be omitted if debug symbols are
+ // not available.
+ int source_line;
+
+ // The start address of the source line, may be omitted if debug symbols
+ // are not available.
+ u_int64_t source_line_base;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__
diff --git a/src/google_breakpad/processor/stack_frame_cpu.h b/src/google_breakpad/processor/stack_frame_cpu.h
new file mode 100644
index 00000000..8af5ffee
--- /dev/null
+++ b/src/google_breakpad/processor/stack_frame_cpu.h
@@ -0,0 +1,103 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// stack_frame_cpu.h: CPU-specific StackFrame extensions.
+//
+// These types extend the StackFrame structure to carry CPU-specific register
+// state. They are defined in this header instead of stack_frame.h to
+// avoid the need to include minidump_format.h when only the generic
+// StackFrame type is needed.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_CPU_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_CPU_H__
+
+#include "google_breakpad/common/minidump_format.h"
+#include "google_breakpad/processor/stack_frame.h"
+
+namespace google_breakpad {
+
+struct StackFrameX86 : public StackFrame {
+ // ContextValidity has one entry for each relevant hardware pointer register
+ // (%eip and %esp) and one entry for each nonvolatile (callee-save) register.
+ enum ContextValidity {
+ CONTEXT_VALID_NONE = 0,
+ CONTEXT_VALID_EIP = 1 << 0,
+ CONTEXT_VALID_ESP = 1 << 1,
+ CONTEXT_VALID_EBP = 1 << 2,
+ CONTEXT_VALID_EBX = 1 << 3,
+ CONTEXT_VALID_ESI = 1 << 4,
+ CONTEXT_VALID_EDI = 1 << 5,
+ CONTEXT_VALID_ALL = -1
+ };
+
+ StackFrameX86() : context(), context_validity(CONTEXT_VALID_NONE) {}
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, the values of nonvolatile registers may be
+ // present, given sufficient debugging information. Refer to
+ // context_validity.
+ MDRawContextX86 context;
+
+ // context_validity is actually ContextValidity, but int is used because
+ // the OR operator doesn't work well with enumerated types. This indicates
+ // which fields in context are valid.
+ int context_validity;
+};
+
+struct StackFramePPC : public StackFrame {
+ // ContextValidity should eventually contain entries for the validity of
+ // other nonvolatile (callee-save) registers as in
+ // StackFrameX86::ContextValidity, but the ppc stackwalker doesn't currently
+ // locate registers other than the ones listed here.
+ enum ContextValidity {
+ CONTEXT_VALID_NONE = 0,
+ CONTEXT_VALID_SRR0 = 1 << 0,
+ CONTEXT_VALID_GPR1 = 1 << 1,
+ CONTEXT_VALID_ALL = -1
+ };
+
+ StackFramePPC() : context(), context_validity(CONTEXT_VALID_NONE) {}
+
+ // Register state. This is only fully valid for the topmost frame in a
+ // stack. In other frames, the values of nonvolatile registers may be
+ // present, given sufficient debugging information. Refer to
+ // context_validity.
+ MDRawContextPPC context;
+
+ // context_validity is actually ContextValidity, but int is used because
+ // the OR operator doesn't work well with enumerated types. This indicates
+ // which fields in context are valid.
+ int context_validity;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_CPU_H__
diff --git a/src/google_breakpad/processor/stackwalker.h b/src/google_breakpad/processor/stackwalker.h
new file mode 100644
index 00000000..cc21e57b
--- /dev/null
+++ b/src/google_breakpad/processor/stackwalker.h
@@ -0,0 +1,140 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// stackwalker.h: Generic stackwalker.
+//
+// The Stackwalker class is an abstract base class providing common generic
+// methods that apply to stacks from all systems. Specific implementations
+// will extend this class by providing GetContextFrame and GetCallerFrame
+// methods to fill in system-specific data in a StackFrame structure.
+// Stackwalker assembles these StackFrame strucutres into a CallStack.
+//
+// Author: Mark Mentovai
+
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__
+
+#include <vector>
+
+namespace google_breakpad {
+
+class CallStack;
+class CodeModules;
+template<typename T> class linked_ptr;
+class MemoryRegion;
+class MinidumpContext;
+class SourceLineResolverInterface;
+struct StackFrame;
+struct StackFrameInfo;
+class SymbolSupplier;
+class SystemInfo;
+
+using std::vector;
+
+
+class Stackwalker {
+ public:
+ virtual ~Stackwalker() {}
+
+ // Populates the given CallStack by calling GetContextFrame and
+ // GetCallerFrame. The frames are further processed to fill all available
+ // data. Returns true if the stackwalk completed, or false if it was
+ // interrupted by SymbolSupplier::GetSymbolFile().
+ bool Walk(CallStack *stack);
+
+ // Returns a new concrete subclass suitable for the CPU that a stack was
+ // generated on, according to the CPU type indicated by the context
+ // argument. If no suitable concrete subclass exists, returns NULL.
+ static Stackwalker* StackwalkerForCPU(const SystemInfo *system_info,
+ MinidumpContext *context,
+ MemoryRegion *memory,
+ const CodeModules *modules,
+ SymbolSupplier *supplier,
+ SourceLineResolverInterface *resolver);
+
+ protected:
+ // system_info identifies the operating system, NULL or empty if unknown.
+ // memory identifies a MemoryRegion that provides the stack memory
+ // for the stack to walk. modules, if non-NULL, is a CodeModules
+ // object that is used to look up which code module each stack frame is
+ // associated with. supplier is an optional caller-supplied SymbolSupplier
+ // implementation. If supplier is NULL, source line info will not be
+ // resolved. resolver is an instance of SourceLineResolverInterface
+ // (see source_line_resolver_interface.h and basic_source_line_resolver.h).
+ // If resolver is NULL, source line info will not be resolved.
+ Stackwalker(const SystemInfo *system_info,
+ MemoryRegion *memory,
+ const CodeModules *modules,
+ SymbolSupplier *supplier,
+ SourceLineResolverInterface *resolver);
+
+ // Information about the system that produced the minidump. Subclasses
+ // and the SymbolSupplier may find this information useful.
+ const SystemInfo *system_info_;
+
+ // The stack memory to walk. Subclasses will require this region to
+ // get information from the stack.
+ MemoryRegion *memory_;
+
+ private:
+ // Obtains the context frame, the innermost called procedure in a stack
+ // trace. Returns NULL on failure. GetContextFrame allocates a new
+ // StackFrame (or StackFrame subclass), ownership of which is taken by
+ // the caller.
+ virtual StackFrame* GetContextFrame() = 0;
+
+ // Obtains a caller frame. Each call to GetCallerFrame should return the
+ // frame that called the last frame returned by GetContextFrame or
+ // GetCallerFrame. To aid this purpose, stack contains the CallStack
+ // made of frames that have already been walked. GetCallerFrame should
+ // return NULL on failure or when there are no more caller frames (when
+ // the end of the stack has been reached). GetCallerFrame allocates a new
+ // StackFrame (or StackFrame subclass), ownership of which is taken by
+ // the caller.
+ virtual StackFrame* GetCallerFrame(
+ const CallStack *stack,
+ const vector< linked_ptr<StackFrameInfo> > &stack_frame_info) = 0;
+
+ // A list of modules, for populating each StackFrame's module information.
+ // This field is optional and may be NULL.
+ const CodeModules *modules_;
+
+ // The optional SymbolSupplier for resolving source line info.
+ SymbolSupplier *supplier_;
+
+ // The SourceLineResolver implementation
+ SourceLineResolverInterface *resolver_;
+};
+
+
+} // namespace google_breakpad
+
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__
diff --git a/src/google_breakpad/processor/symbol_supplier.h b/src/google_breakpad/processor/symbol_supplier.h
new file mode 100644
index 00000000..8fc88a66
--- /dev/null
+++ b/src/google_breakpad/processor/symbol_supplier.h
@@ -0,0 +1,72 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// The caller may implement the SymbolSupplier abstract base class
+// to provide symbols for a given module.
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_SYMBOL_SUPPLIER_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_SYMBOL_SUPPLIER_H__
+
+#include <string>
+
+namespace google_breakpad {
+
+using std::string;
+class CodeModule;
+class SystemInfo;
+
+class SymbolSupplier {
+ public:
+ // Result type for GetSymbolFile
+ enum SymbolResult {
+ // no symbols were found, but continue processing
+ NOT_FOUND,
+
+ // symbols were found, and the path has been placed in symbol_file
+ FOUND,
+
+ // stops processing the minidump immediately
+ INTERRUPT,
+ };
+
+ virtual ~SymbolSupplier() {}
+
+ // Retrieves the symbol file for the given CodeModule, placing the
+ // path in symbol_file if successful. system_info contains strings
+ // identifying the operating system and CPU; SymbolSupplier may use to help
+ // locate the symbol file. system_info may be NULL or its fields may be
+ // empty if these values are unknown.
+ virtual SymbolResult GetSymbolFile(const CodeModule *module,
+ const SystemInfo *system_info,
+ string *symbol_file) = 0;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_SYMBOL_SUPPLIER_H__
diff --git a/src/google_breakpad/processor/system_info.h b/src/google_breakpad/processor/system_info.h
new file mode 100644
index 00000000..49776b75
--- /dev/null
+++ b/src/google_breakpad/processor/system_info.h
@@ -0,0 +1,89 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// 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 Inc. 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.
+
+// system_info.h: Information about the system that was running a program
+// when a crash report was produced.
+//
+// Author: Mark Mentovai
+
+#ifndef GOOGLE_BREAKPAD_PROCESSOR_SYSTEM_INFO_H__
+#define GOOGLE_BREAKPAD_PROCESSOR_SYSTEM_INFO_H__
+
+#include <string>
+
+namespace google_breakpad {
+
+using std::string;
+
+struct SystemInfo {
+ public:
+ // Resets the SystemInfo object to its default values.
+ void Clear() {
+ os.clear();
+ os_short.clear();
+ os_version.clear();
+ cpu.clear();
+ cpu_info.clear();
+ }
+
+ // A string identifying the operating system, such as "Windows NT",
+ // "Mac OS X", or "Linux". If the information is present in the dump but
+ // its value is unknown, this field will contain a numeric value. If
+ // the information is not present in the dump, this field will be empty.
+ string os;
+
+ // A short form of the os string, using lowercase letters and no spaces,
+ // suitable for use in a filesystem. Possible values are "windows",
+ // "mac", and "linux". Empty if the information is not present in the dump
+ // or if the OS given by the dump is unknown. The values stored in this
+ // field should match those used by MinidumpSystemInfo::GetOS.
+ string os_short;
+
+ // A string identifying the version of the operating system, such as
+ // "5.1.2600 Service Pack 2" or "10.4.8 8L2127". If the dump does not
+ // contain this information, this field will be empty.
+ string os_version;
+
+ // A string identifying the basic CPU family, such as "x86" or "ppc".
+ // If this information is present in the dump but its value is unknown,
+ // this field will contain a numeric value. If the information is not
+ // present in the dump, this field will be empty. The values stored in
+ // this field should match those used by MinidumpSystemInfo::GetCPU.
+ string cpu;
+
+ // A string further identifying the specific CPU, such as
+ // "GenuineIntel level 6 model 13 stepping 8". If the information is not
+ // present in the dump, or additional identifying information is not
+ // defined for the CPU family, this field will be empty.
+ string cpu_info;
+};
+
+} // namespace google_breakpad
+
+#endif // GOOGLE_BREAKPAD_PROCESSOR_SYSTEM_INFO_H__