1 /* Copyright 2006 Google LLC 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above 10 * copyright notice, this list of conditions and the following disclaimer 11 * in the documentation and/or other materials provided with the 12 * distribution. 13 * * Neither the name of Google LLC nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 28 29 /* minidump_format.h: A cross-platform reimplementation of minidump-related 30 * portions of DbgHelp.h from the Windows Platform SDK. 31 * 32 * (This is C99 source, please don't corrupt it with C++.) 33 * 34 * This file contains the necessary definitions to read minidump files 35 * produced on ppc. These files may be read on any platform provided 36 * that the alignments of these structures on the processing system are 37 * identical to the alignments of these structures on the producing system. 38 * For this reason, precise-sized types are used. The structures defined 39 * by this file have been laid out to minimize alignment problems by ensuring 40 * ensuring that all members are aligned on their natural boundaries. In 41 * In some cases, tail-padding may be significant when different ABIs specify 42 * different tail-padding behaviors. To avoid problems when reading or 43 * writing affected structures, MD_*_SIZE macros are provided where needed, 44 * containing the useful size of the structures without padding. 45 * 46 * Structures that are defined by Microsoft to contain a zero-length array 47 * are instead defined here to contain an array with one element, as 48 * zero-length arrays are forbidden by standard C and C++. In these cases, 49 * *_minsize constants are provided to be used in place of sizeof. For a 50 * cleaner interface to these sizes when using C++, see minidump_size.h. 51 * 52 * These structures are also sufficient to populate minidump files. 53 * 54 * These definitions may be extended to support handling minidump files 55 * for other CPUs and other operating systems. 56 * 57 * Because precise data type sizes are crucial for this implementation to 58 * function properly and portably in terms of interoperability with minidumps 59 * produced by DbgHelp on Windows, a set of primitive types with known sizes 60 * are used as the basis of each structure defined by this file. DbgHelp 61 * on Windows is assumed to be the reference implementation; this file 62 * seeks to provide a cross-platform compatible implementation. To avoid 63 * collisions with the types and values defined and used by DbgHelp in the 64 * event that this implementation is used on Windows, each type and value 65 * defined here is given a new name, beginning with "MD". Names of the 66 * equivalent types and values in the Windows Platform SDK are given in 67 * comments. 68 * 69 * Author: Mark Mentovai 70 * Change to split into its own file: Neal Sidhwaney */ 71 72 /* 73 * Breakpad minidump extension for PowerPC support. Based on Darwin/Mac OS X' 74 * mach/ppc/_types.h 75 */ 76 77 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC_H__ 78 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC_H__ 79 80 #define MD_FLOATINGSAVEAREA_PPC_FPR_COUNT 32 81 82 typedef struct { 83 /* fpregs is a double[32] in mach/ppc/_types.h, but a uint64_t is used 84 * here for precise sizing. */ 85 uint64_t fpregs[MD_FLOATINGSAVEAREA_PPC_FPR_COUNT]; 86 uint32_t fpscr_pad; 87 uint32_t fpscr; /* Status/control */ 88 } MDFloatingSaveAreaPPC; /* Based on ppc_float_state */ 89 90 91 #define MD_VECTORSAVEAREA_PPC_VR_COUNT 32 92 93 typedef struct { 94 /* Vector registers (including vscr) are 128 bits, but mach/ppc/_types.h 95 * exposes them as four 32-bit quantities. */ 96 uint128_struct save_vr[MD_VECTORSAVEAREA_PPC_VR_COUNT]; 97 uint128_struct save_vscr; /* Status/control */ 98 uint32_t save_pad5[4]; 99 uint32_t save_vrvalid; /* Indicates which vector registers are saved */ 100 uint32_t save_pad6[7]; 101 } MDVectorSaveAreaPPC; /* ppc_vector_state */ 102 103 104 #define MD_CONTEXT_PPC_GPR_COUNT 32 105 106 /* Use the same 32-bit alignment when accessing this structure from 64-bit code 107 * as is used natively in 32-bit code. #pragma pack is a MSVC extension 108 * supported by gcc. */ 109 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC) 110 #pragma pack(4) 111 #else 112 #pragma pack(push, 4) 113 #endif 114 115 typedef struct { 116 /* context_flags is not present in ppc_thread_state, but it aids 117 * identification of MDRawContextPPC among other raw context types, 118 * and it guarantees alignment when we get to float_save. */ 119 uint32_t context_flags; 120 121 uint32_t srr0; /* Machine status save/restore: stores pc 122 * (instruction) */ 123 uint32_t srr1; /* Machine status save/restore: stores msr 124 * (ps, program/machine state) */ 125 /* ppc_thread_state contains 32 fields, r0 .. r31. Here, an array is 126 * used for brevity. */ 127 uint32_t gpr[MD_CONTEXT_PPC_GPR_COUNT]; 128 uint32_t cr; /* Condition */ 129 uint32_t xer; /* Integer (fiXed-point) exception */ 130 uint32_t lr; /* Link */ 131 uint32_t ctr; /* Count */ 132 uint32_t mq; /* Multiply/Quotient (PPC 601, POWER only) */ 133 uint32_t vrsave; /* Vector save */ 134 135 /* float_save and vector_save aren't present in ppc_thread_state, but 136 * are represented in separate structures that still define a thread's 137 * context. */ 138 MDFloatingSaveAreaPPC float_save; 139 MDVectorSaveAreaPPC vector_save; 140 } MDRawContextPPC; /* Based on ppc_thread_state */ 141 142 /* Indices into gpr for registers with a dedicated or conventional purpose. */ 143 enum MDPPCRegisterNumbers { 144 MD_CONTEXT_PPC_REG_SP = 1 145 }; 146 147 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC) 148 #pragma pack(0) 149 #else 150 #pragma pack(pop) 151 #endif 152 153 /* For (MDRawContextPPC).context_flags. These values indicate the type of 154 * context stored in the structure. MD_CONTEXT_PPC is Breakpad-defined. Its 155 * value was chosen to avoid likely conflicts with MD_CONTEXT_* for other 156 * CPUs. */ 157 #define MD_CONTEXT_PPC 0x20000000 158 #define MD_CONTEXT_PPC_BASE (MD_CONTEXT_PPC | 0x00000001) 159 #define MD_CONTEXT_PPC_FLOATING_POINT (MD_CONTEXT_PPC | 0x00000008) 160 #define MD_CONTEXT_PPC_VECTOR (MD_CONTEXT_PPC | 0x00000020) 161 162 #define MD_CONTEXT_PPC_FULL MD_CONTEXT_PPC_BASE 163 #define MD_CONTEXT_PPC_ALL (MD_CONTEXT_PPC_FULL | \ 164 MD_CONTEXT_PPC_FLOATING_POINT | \ 165 MD_CONTEXT_PPC_VECTOR) 166 167 #endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC_H__ */ 168