1 /* Copyright 2009 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 ARM. 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 40 * ensuring that all members are aligned on their natural boundaries. 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 * Because precise data type sizes are crucial for this implementation to 55 * function properly and portably, a set of primitive types with known sizes 56 * are used as the basis of each structure defined by this file. 57 * 58 * Author: Julian Seward 59 */ 60 61 /* 62 * ARM support 63 */ 64 65 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_ARM_H__ 66 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_ARM_H__ 67 68 #define MD_FLOATINGSAVEAREA_ARM_FPR_COUNT 32 69 #define MD_FLOATINGSAVEAREA_ARM_FPEXTRA_COUNT 8 70 71 /* 72 * Note that these structures *do not* map directly to the CONTEXT 73 * structure defined in WinNT.h in the Windows Mobile SDK. That structure 74 * does not accomodate VFPv3, and I'm unsure if it was ever used in the 75 * wild anyway, as Windows CE only seems to produce "cedumps" which 76 * are not exactly minidumps. 77 */ 78 typedef struct { 79 uint64_t fpscr; /* FPU status register */ 80 81 /* 32 64-bit floating point registers, d0 .. d31. */ 82 uint64_t regs[MD_FLOATINGSAVEAREA_ARM_FPR_COUNT]; 83 84 /* Miscellaneous control words */ 85 uint32_t extra[MD_FLOATINGSAVEAREA_ARM_FPEXTRA_COUNT]; 86 } MDFloatingSaveAreaARM; 87 88 #define MD_CONTEXT_ARM_GPR_COUNT 16 89 90 typedef struct { 91 /* The next field determines the layout of the structure, and which parts 92 * of it are populated 93 */ 94 uint32_t context_flags; 95 96 /* 16 32-bit integer registers, r0 .. r15 97 * Note the following fixed uses: 98 * r13 is the stack pointer 99 * r14 is the link register 100 * r15 is the program counter 101 */ 102 uint32_t iregs[MD_CONTEXT_ARM_GPR_COUNT]; 103 104 /* CPSR (flags, basically): 32 bits: 105 bit 31 - N (negative) 106 bit 30 - Z (zero) 107 bit 29 - C (carry) 108 bit 28 - V (overflow) 109 bit 27 - Q (saturation flag, sticky) 110 All other fields -- ignore */ 111 uint32_t cpsr; 112 113 /* The next field is included with MD_CONTEXT_ARM_FLOATING_POINT */ 114 MDFloatingSaveAreaARM float_save; 115 116 } MDRawContextARM; 117 118 /* Indices into iregs for registers with a dedicated or conventional 119 * purpose. 120 */ 121 enum MDARMRegisterNumbers { 122 MD_CONTEXT_ARM_REG_IOS_FP = 7, 123 MD_CONTEXT_ARM_REG_FP = 11, 124 MD_CONTEXT_ARM_REG_SP = 13, 125 MD_CONTEXT_ARM_REG_LR = 14, 126 MD_CONTEXT_ARM_REG_PC = 15 127 }; 128 129 /* For (MDRawContextARM).context_flags. These values indicate the type of 130 * context stored in the structure. */ 131 /* CONTEXT_ARM from the Windows CE 5.0 SDK. This value isn't correct 132 * because this bit can be used for flags. Presumably this value was 133 * never actually used in minidumps, but only in "CEDumps" which 134 * are a whole parallel minidump file format for Windows CE. 135 * Therefore, Breakpad defines its own value for ARM CPUs. 136 */ 137 #define MD_CONTEXT_ARM_OLD 0x00000040 138 /* This value was chosen to avoid likely conflicts with MD_CONTEXT_* 139 * for other CPUs. */ 140 #define MD_CONTEXT_ARM 0x40000000 141 #define MD_CONTEXT_ARM_INTEGER (MD_CONTEXT_ARM | 0x00000002) 142 #define MD_CONTEXT_ARM_FLOATING_POINT (MD_CONTEXT_ARM | 0x00000004) 143 144 #define MD_CONTEXT_ARM_FULL (MD_CONTEXT_ARM_INTEGER | \ 145 MD_CONTEXT_ARM_FLOATING_POINT) 146 147 #define MD_CONTEXT_ARM_ALL (MD_CONTEXT_ARM_INTEGER | \ 148 MD_CONTEXT_ARM_FLOATING_POINT) 149 150 #endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_ARM_H__ */ 151