• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2013 Google Inc.
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 
30 /* minidump_format.h: A cross-platform reimplementation of minidump-related
31  * portions of DbgHelp.h from the Windows Platform SDK.
32  *
33  * (This is C99 source, please don't corrupt it with C++.)
34  *
35  * This file contains the necessary definitions to read minidump files
36  * produced on ARM.  These files may be read on any platform provided
37  * that the alignments of these structures on the processing system are
38  * identical to the alignments of these structures on the producing system.
39  * For this reason, precise-sized types are used.  The structures defined
40  * by this file have been laid out to minimize alignment problems by
41  * ensuring that all members are aligned on their natural boundaries.
42  * In some cases, tail-padding may be significant when different ABIs specify
43  * different tail-padding behaviors.  To avoid problems when reading or
44  * writing affected structures, MD_*_SIZE macros are provided where needed,
45  * containing the useful size of the structures without padding.
46  *
47  * Structures that are defined by Microsoft to contain a zero-length array
48  * are instead defined here to contain an array with one element, as
49  * zero-length arrays are forbidden by standard C and C++.  In these cases,
50  * *_minsize constants are provided to be used in place of sizeof.  For a
51  * cleaner interface to these sizes when using C++, see minidump_size.h.
52  *
53  * These structures are also sufficient to populate minidump files.
54  *
55  * Because precise data type sizes are crucial for this implementation to
56  * function properly and portably, a set of primitive types with known sizes
57  * are used as the basis of each structure defined by this file.
58  *
59  * Author: Colin Blundell
60  */
61 
62 /*
63  * ARM64 support
64  */
65 
66 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_ARM64_H__
67 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_ARM64_H__
68 
69 #include "google_breakpad/common/breakpad_types.h"
70 
71 #define MD_FLOATINGSAVEAREA_ARM64_FPR_COUNT 32
72 #define MD_CONTEXT_ARM64_GPR_COUNT 33
73 
74 typedef struct {
75   /* 32 128-bit floating point registers, d0 .. d31. */
76   uint128_struct regs[MD_FLOATINGSAVEAREA_ARM64_FPR_COUNT];
77 
78   uint32_t fpcr;       /* FPU control register */
79   uint32_t fpsr;       /* FPU status register */
80 } MDFloatingSaveAreaARM64;
81 
82 /* For (MDRawContextARM64).context_flags.  These values indicate the type of
83  * context stored in the structure. */
84 #define MD_CONTEXT_ARM64 0x00400000
85 #define MD_CONTEXT_ARM64_CONTROL (MD_CONTEXT_ARM64 | 0x00000001)
86 #define MD_CONTEXT_ARM64_INTEGER (MD_CONTEXT_ARM64 | 0x00000002)
87 #define MD_CONTEXT_ARM64_FLOATING_POINT (MD_CONTEXT_ARM64 | 0x00000004)
88 #define MD_CONTEXT_ARM64_DEBUG (MD_CONTEXT_ARM64 | 0x00000008)
89 #define MD_CONTEXT_ARM64_FULL (MD_CONTEXT_ARM64_CONTROL | \
90                                MD_CONTEXT_ARM64_INTEGER | \
91                                MD_CONTEXT_ARM64_FLOATING_POINT)
92 #define MD_CONTEXT_ARM64_ALL (MD_CONTEXT_ARM64_FULL | MD_CONTEXT_ARM64_DEBUG)
93 
94 typedef struct {
95   /* Determines which fields of this struct are populated */
96   uint32_t context_flags;
97 
98   /* CPSR (flags, basically): 32 bits:
99         bit 31 - N (negative)
100         bit 30 - Z (zero)
101         bit 29 - C (carry)
102         bit 28 - V (overflow)
103         bit 27 - Q (saturation flag, sticky)
104      All other fields -- ignore */
105   uint32_t cpsr;
106 
107   /* 33 64-bit integer registers, x0 .. x31 + the PC
108    * Note the following fixed uses:
109    *   x29 is the frame pointer
110    *   x30 is the link register
111    *   x31 is the stack pointer
112    *   The PC is effectively x32.
113    */
114   uint64_t iregs[MD_CONTEXT_ARM64_GPR_COUNT];
115 
116   /* The next field is included with MD_CONTEXT64_ARM_FLOATING_POINT */
117   MDFloatingSaveAreaARM64 float_save;
118 
119   uint32_t bcr[8];
120   uint64_t bvr[8];
121   uint32_t wcr[2];
122   uint64_t wvr[2];
123 } MDRawContextARM64;
124 
125 typedef struct {
126   uint32_t       fpsr;      /* FPU status register */
127   uint32_t       fpcr;      /* FPU control register */
128 
129   /* 32 128-bit floating point registers, d0 .. d31. */
130   uint128_struct regs[MD_FLOATINGSAVEAREA_ARM64_FPR_COUNT];
131 } MDFloatingSaveAreaARM64_Old;
132 
133 /* Use the same 32-bit alignment when accessing this structure from 64-bit code
134  * as is used natively in 32-bit code. */
135 #pragma pack(push, 4)
136 
137 typedef struct {
138   /* The next field determines the layout of the structure, and which parts
139    * of it are populated
140    */
141   uint64_t      context_flags;
142 
143   /* 33 64-bit integer registers, x0 .. x31 + the PC
144    * Note the following fixed uses:
145    *   x29 is the frame pointer
146    *   x30 is the link register
147    *   x31 is the stack pointer
148    *   The PC is effectively x32.
149    */
150   uint64_t     iregs[MD_CONTEXT_ARM64_GPR_COUNT];
151 
152   /* CPSR (flags, basically): 32 bits:
153         bit 31 - N (negative)
154         bit 30 - Z (zero)
155         bit 29 - C (carry)
156         bit 28 - V (overflow)
157         bit 27 - Q (saturation flag, sticky)
158      All other fields -- ignore */
159   uint32_t    cpsr;
160 
161   /* The next field is included with MD_CONTEXT64_ARM_FLOATING_POINT */
162   MDFloatingSaveAreaARM64_Old float_save;
163 
164 } MDRawContextARM64_Old;
165 
166 #pragma pack(pop)
167 
168 /* Indices into iregs for registers with a dedicated or conventional
169  * purpose.
170  */
171 enum MDARM64RegisterNumbers {
172   MD_CONTEXT_ARM64_REG_FP     = 29,
173   MD_CONTEXT_ARM64_REG_LR     = 30,
174   MD_CONTEXT_ARM64_REG_SP     = 31,
175   MD_CONTEXT_ARM64_REG_PC     = 32
176 };
177 
178 /* For (MDRawContextARM64_Old).context_flags.  These values indicate the type of
179  * context stored in the structure. MD_CONTEXT_ARM64_OLD is Breakpad-defined.
180  * This value was chosen to avoid likely conflicts with MD_CONTEXT_*
181  * for other CPUs. */
182 #define MD_CONTEXT_ARM64_OLD                   0x80000000
183 #define MD_CONTEXT_ARM64_INTEGER_OLD           (MD_CONTEXT_ARM64_OLD | 0x00000002)
184 #define MD_CONTEXT_ARM64_FLOATING_POINT_OLD    (MD_CONTEXT_ARM64_OLD | 0x00000004)
185 
186 #define MD_CONTEXT_ARM64_FULL_OLD              (MD_CONTEXT_ARM64_INTEGER_OLD | \
187                                           MD_CONTEXT_ARM64_FLOATING_POINT_OLD)
188 
189 #define MD_CONTEXT_ARM64_ALL_OLD               (MD_CONTEXT_ARM64_INTEGER_OLD | \
190                                           MD_CONTEXT_ARM64_FLOATING_POINT_OLD)
191 
192 #endif  /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_ARM64_H__ */
193