Planeshift

minidump_cpu_ppc64.h

Go to the documentation of this file.
00001 /* Copyright (c) 2008, 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 ppc64.  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 ensuring
00041  * ensuring that all members are aligned on their natural boundaries.  In
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  * These definitions may be extended to support handling minidump files
00056  * for other CPUs and other operating systems.
00057  *
00058  * Because precise data type sizes are crucial for this implementation to
00059  * function properly and portably in terms of interoperability with minidumps
00060  * produced by DbgHelp on Windows, a set of primitive types with known sizes
00061  * are used as the basis of each structure defined by this file.  DbgHelp
00062  * on Windows is assumed to be the reference implementation; this file
00063  * seeks to provide a cross-platform compatible implementation.  To avoid
00064  * collisions with the types and values defined and used by DbgHelp in the
00065  * event that this implementation is used on Windows, each type and value
00066  * defined here is given a new name, beginning with "MD".  Names of the
00067  * equivalent types and values in the Windows Platform SDK are given in
00068  * comments.
00069  *
00070  * Author: Neal Sidhwaney */
00071 
00072 
00073 /*
00074  * Breakpad minidump extension for PPC64 support.  Based on Darwin/Mac OS X'
00075  * mach/ppc/_types.h
00076  */
00077 
00078 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC64_H__
00079 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC64_H__
00080 
00081 #include "minidump_cpu_ppc.h"
00082 
00083 // these types are the same in ppc64 & ppc
00084 typedef MDFloatingSaveAreaPPC MDFloatingSaveAreaPPC64;
00085 typedef MDVectorSaveAreaPPC MDVectorSaveAreaPPC64;
00086 
00087 #define MD_CONTEXT_PPC64_GPR_COUNT MD_CONTEXT_PPC_GPR_COUNT
00088 
00089 typedef struct {
00090   /* context_flags is not present in ppc_thread_state, but it aids
00091    * identification of MDRawContextPPC among other raw context types,
00092    * and it guarantees alignment when we get to float_save. */
00093   uint64_t              context_flags;
00094 
00095   uint64_t              srr0;    /* Machine status save/restore: stores pc
00096                                   * (instruction) */
00097   uint64_t              srr1;    /* Machine status save/restore: stores msr
00098                                   * (ps, program/machine state) */
00099   /* ppc_thread_state contains 32 fields, r0 .. r31.  Here, an array is
00100    * used for brevity. */
00101   uint64_t              gpr[MD_CONTEXT_PPC64_GPR_COUNT];
00102   uint64_t              cr;      /* Condition */
00103   uint64_t              xer;     /* Integer (fiXed-point) exception */
00104   uint64_t              lr;      /* Link */
00105   uint64_t              ctr;     /* Count */
00106   uint64_t              vrsave;  /* Vector save */
00107 
00108   /* float_save and vector_save aren't present in ppc_thread_state, but
00109    * are represented in separate structures that still define a thread's
00110    * context. */
00111   MDFloatingSaveAreaPPC float_save;
00112   MDVectorSaveAreaPPC   vector_save;
00113 } MDRawContextPPC64;  /* Based on ppc_thread_state */
00114 
00115 /* For (MDRawContextPPC).context_flags.  These values indicate the type of
00116  * context stored in the structure.  MD_CONTEXT_PPC is Breakpad-defined.  Its
00117  * value was chosen to avoid likely conflicts with MD_CONTEXT_* for other
00118  * CPUs. */
00119 #define MD_CONTEXT_PPC64                0x01000000
00120 #define MD_CONTEXT_PPC64_BASE           (MD_CONTEXT_PPC64 | 0x00000001)
00121 #define MD_CONTEXT_PPC64_FLOATING_POINT (MD_CONTEXT_PPC64 | 0x00000008)
00122 #define MD_CONTEXT_PPC64_VECTOR         (MD_CONTEXT_PPC64 | 0x00000020)
00123 
00124 #define MD_CONTEXT_PPC64_FULL           MD_CONTEXT_PPC64_BASE
00125 #define MD_CONTEXT_PPC64_ALL            (MD_CONTEXT_PPC64_FULL | \
00126                                          MD_CONTEXT_PPC64_FLOATING_POINT | \
00127                                          MD_CONTEXT_PPC64_VECTOR)
00128 
00129 #endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC64_H__ */