Planeshift

minidump_cpu_arm.h

Go to the documentation of this file.
00001 /* Copyright (c) 2009, Google Inc.
00002  * All rights reserved.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are
00006  * met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  * notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above
00011  * copyright notice, this list of conditions and the following disclaimer
00012  * in the documentation and/or other materials provided with the
00013  * distribution.
00014  *     * Neither the name of Google Inc. nor the names of its
00015  * contributors may be used to endorse or promote products derived from
00016  * this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00024  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
00029 
00030 /* minidump_format.h: A cross-platform reimplementation of minidump-related
00031  * portions of DbgHelp.h from the Windows Platform SDK.
00032  *
00033  * (This is C99 source, please don't corrupt it with C++.)
00034  *
00035  * This file contains the necessary definitions to read minidump files
00036  * produced on ARM.  These files may be read on any platform provided
00037  * that the alignments of these structures on the processing system are
00038  * identical to the alignments of these structures on the producing system.
00039  * For this reason, precise-sized types are used.  The structures defined
00040  * by this file have been laid out to minimize alignment problems by
00041  * ensuring that all members are aligned on their natural boundaries.
00042  * In some cases, tail-padding may be significant when different ABIs specify
00043  * different tail-padding behaviors.  To avoid problems when reading or
00044  * writing affected structures, MD_*_SIZE macros are provided where needed,
00045  * containing the useful size of the structures without padding.
00046  *
00047  * Structures that are defined by Microsoft to contain a zero-length array
00048  * are instead defined here to contain an array with one element, as
00049  * zero-length arrays are forbidden by standard C and C++.  In these cases,
00050  * *_minsize constants are provided to be used in place of sizeof.  For a
00051  * cleaner interface to these sizes when using C++, see minidump_size.h.
00052  *
00053  * These structures are also sufficient to populate minidump files.
00054  *
00055  * Because precise data type sizes are crucial for this implementation to
00056  * function properly and portably, a set of primitive types with known sizes
00057  * are used as the basis of each structure defined by this file.
00058  *
00059  * Author: Julian Seward
00060  */
00061 
00062 /*
00063  * ARM support
00064  */
00065 
00066 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_ARM_H__
00067 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_ARM_H__
00068 
00069 #define MD_FLOATINGSAVEAREA_ARM_FPR_COUNT 32
00070 #define MD_FLOATINGSAVEAREA_ARM_FPEXTRA_COUNT 8
00071 
00072 /*
00073  * Note that these structures *do not* map directly to the CONTEXT
00074  * structure defined in WinNT.h in the Windows Mobile SDK. That structure
00075  * does not accomodate VFPv3, and I'm unsure if it was ever used in the
00076  * wild anyway, as Windows CE only seems to produce "cedumps" which
00077  * are not exactly minidumps.
00078  */
00079 typedef struct {
00080   uint64_t      fpscr;      /* FPU status register */
00081 
00082   /* 32 64-bit floating point registers, d0 .. d31. */
00083   uint64_t      regs[MD_FLOATINGSAVEAREA_ARM_FPR_COUNT];
00084 
00085   /* Miscellaneous control words */
00086   uint32_t     extra[MD_FLOATINGSAVEAREA_ARM_FPEXTRA_COUNT];
00087 } MDFloatingSaveAreaARM;
00088 
00089 #define MD_CONTEXT_ARM_GPR_COUNT 16
00090 
00091 typedef struct {
00092   /* The next field determines the layout of the structure, and which parts
00093    * of it are populated
00094    */
00095   uint32_t      context_flags;
00096 
00097   /* 16 32-bit integer registers, r0 .. r15
00098    * Note the following fixed uses:
00099    *   r13 is the stack pointer
00100    *   r14 is the link register
00101    *   r15 is the program counter
00102    */
00103   uint32_t     iregs[MD_CONTEXT_ARM_GPR_COUNT];
00104 
00105   /* CPSR (flags, basically): 32 bits:
00106         bit 31 - N (negative)
00107         bit 30 - Z (zero)
00108         bit 29 - C (carry)
00109         bit 28 - V (overflow)
00110         bit 27 - Q (saturation flag, sticky)
00111      All other fields -- ignore */
00112   uint32_t    cpsr;
00113 
00114   /* The next field is included with MD_CONTEXT_ARM_FLOATING_POINT */
00115   MDFloatingSaveAreaARM float_save;
00116 
00117 } MDRawContextARM;
00118 
00119 /* Indices into iregs for registers with a dedicated or conventional
00120  * purpose.
00121  */
00122 enum MDARMRegisterNumbers {
00123   MD_CONTEXT_ARM_REG_IOS_FP = 7,
00124   MD_CONTEXT_ARM_REG_FP     = 11,
00125   MD_CONTEXT_ARM_REG_SP     = 13,
00126   MD_CONTEXT_ARM_REG_LR     = 14,
00127   MD_CONTEXT_ARM_REG_PC     = 15
00128 };
00129 
00130 /* For (MDRawContextARM).context_flags.  These values indicate the type of
00131  * context stored in the structure. */
00132 /* CONTEXT_ARM from the Windows CE 5.0 SDK. This value isn't correct
00133  * because this bit can be used for flags. Presumably this value was
00134  * never actually used in minidumps, but only in "CEDumps" which
00135  * are a whole parallel minidump file format for Windows CE.
00136  * Therefore, Breakpad defines its own value for ARM CPUs.
00137  */
00138 #define MD_CONTEXT_ARM_OLD               0x00000040
00139 /* This value was chosen to avoid likely conflicts with MD_CONTEXT_*
00140  * for other CPUs. */
00141 #define MD_CONTEXT_ARM                   0x40000000
00142 #define MD_CONTEXT_ARM_INTEGER           (MD_CONTEXT_ARM | 0x00000002)
00143 #define MD_CONTEXT_ARM_FLOATING_POINT    (MD_CONTEXT_ARM | 0x00000004)
00144 
00145 #define MD_CONTEXT_ARM_FULL              (MD_CONTEXT_ARM_INTEGER | \
00146                                           MD_CONTEXT_ARM_FLOATING_POINT)
00147 
00148 #define MD_CONTEXT_ARM_ALL               (MD_CONTEXT_ARM_INTEGER | \
00149                                           MD_CONTEXT_ARM_FLOATING_POINT)
00150 
00151 #endif  /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_ARM_H__ */