• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2006, 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 ppc.  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 ensuring
41  * ensuring that all members are aligned on their natural boundaries.  In
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  * These definitions may be extended to support handling minidump files
56  * for other CPUs and other operating systems.
57  *
58  * Because precise data type sizes are crucial for this implementation to
59  * function properly and portably in terms of interoperability with minidumps
60  * produced by DbgHelp on Windows, a set of primitive types with known sizes
61  * are used as the basis of each structure defined by this file.  DbgHelp
62  * on Windows is assumed to be the reference implementation; this file
63  * seeks to provide a cross-platform compatible implementation.  To avoid
64  * collisions with the types and values defined and used by DbgHelp in the
65  * event that this implementation is used on Windows, each type and value
66  * defined here is given a new name, beginning with "MD".  Names of the
67  * equivalent types and values in the Windows Platform SDK are given in
68  * comments.
69  *
70  * Author: Mark Mentovai
71  * Change to split into its own file: Neal Sidhwaney */
72 
73 /*
74  * Breakpad minidump extension for PowerPC support.  Based on Darwin/Mac OS X'
75  * mach/ppc/_types.h
76  */
77 
78 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC_H__
79 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC_H__
80 
81 #define MD_FLOATINGSAVEAREA_PPC_FPR_COUNT 32
82 
83 typedef struct {
84   /* fpregs is a double[32] in mach/ppc/_types.h, but a uint64_t is used
85    * here for precise sizing. */
86   uint64_t fpregs[MD_FLOATINGSAVEAREA_PPC_FPR_COUNT];
87   uint32_t fpscr_pad;
88   uint32_t fpscr;      /* Status/control */
89 } MDFloatingSaveAreaPPC;  /* Based on ppc_float_state */
90 
91 
92 #define MD_VECTORSAVEAREA_PPC_VR_COUNT 32
93 
94 typedef struct {
95   /* Vector registers (including vscr) are 128 bits, but mach/ppc/_types.h
96    * exposes them as four 32-bit quantities. */
97   uint128_struct save_vr[MD_VECTORSAVEAREA_PPC_VR_COUNT];
98   uint128_struct save_vscr;  /* Status/control */
99   uint32_t       save_pad5[4];
100   uint32_t       save_vrvalid;  /* Indicates which vector registers are saved */
101   uint32_t       save_pad6[7];
102 } MDVectorSaveAreaPPC;  /* ppc_vector_state */
103 
104 
105 #define MD_CONTEXT_PPC_GPR_COUNT 32
106 
107 /* Use the same 32-bit alignment when accessing this structure from 64-bit code
108  * as is used natively in 32-bit code.  #pragma pack is a MSVC extension
109  * supported by gcc. */
110 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
111 #pragma pack(4)
112 #else
113 #pragma pack(push, 4)
114 #endif
115 
116 typedef struct {
117   /* context_flags is not present in ppc_thread_state, but it aids
118    * identification of MDRawContextPPC among other raw context types,
119    * and it guarantees alignment when we get to float_save. */
120   uint32_t              context_flags;
121 
122   uint32_t              srr0;    /* Machine status save/restore: stores pc
123                                   * (instruction) */
124   uint32_t              srr1;    /* Machine status save/restore: stores msr
125                                   * (ps, program/machine state) */
126   /* ppc_thread_state contains 32 fields, r0 .. r31.  Here, an array is
127    * used for brevity. */
128   uint32_t              gpr[MD_CONTEXT_PPC_GPR_COUNT];
129   uint32_t              cr;      /* Condition */
130   uint32_t              xer;     /* Integer (fiXed-point) exception */
131   uint32_t              lr;      /* Link */
132   uint32_t              ctr;     /* Count */
133   uint32_t              mq;      /* Multiply/Quotient (PPC 601, POWER only) */
134   uint32_t              vrsave;  /* Vector save */
135 
136   /* float_save and vector_save aren't present in ppc_thread_state, but
137    * are represented in separate structures that still define a thread's
138    * context. */
139   MDFloatingSaveAreaPPC float_save;
140   MDVectorSaveAreaPPC   vector_save;
141 } MDRawContextPPC;  /* Based on ppc_thread_state */
142 
143 /* Indices into gpr for registers with a dedicated or conventional purpose. */
144 enum MDPPCRegisterNumbers {
145   MD_CONTEXT_PPC_REG_SP = 1
146 };
147 
148 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
149 #pragma pack(0)
150 #else
151 #pragma pack(pop)
152 #endif
153 
154 /* For (MDRawContextPPC).context_flags.  These values indicate the type of
155  * context stored in the structure.  MD_CONTEXT_PPC is Breakpad-defined.  Its
156  * value was chosen to avoid likely conflicts with MD_CONTEXT_* for other
157  * CPUs. */
158 #define MD_CONTEXT_PPC                0x20000000
159 #define MD_CONTEXT_PPC_BASE           (MD_CONTEXT_PPC | 0x00000001)
160 #define MD_CONTEXT_PPC_FLOATING_POINT (MD_CONTEXT_PPC | 0x00000008)
161 #define MD_CONTEXT_PPC_VECTOR         (MD_CONTEXT_PPC | 0x00000020)
162 
163 #define MD_CONTEXT_PPC_FULL           MD_CONTEXT_PPC_BASE
164 #define MD_CONTEXT_PPC_ALL            (MD_CONTEXT_PPC_FULL | \
165                                        MD_CONTEXT_PPC_FLOATING_POINT | \
166                                        MD_CONTEXT_PPC_VECTOR)
167 
168 #endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC_H__ */
169