PageRenderTime 37ms CodeModel.GetById 7ms app.highlight 22ms RepoModel.GetById 2ms app.codeStats 0ms

/thirdparty/breakpad/google_breakpad/common/minidump_cpu_amd64.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 235 lines | 105 code | 26 blank | 104 comment | 0 complexity | 172d6800f10e9a259dc43193d09f5e73 MD5 | raw file
  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 amd64.  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#ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_AMD64_H__
 74#define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_AMD64_H__
 75
 76
 77/*
 78 * AMD64 support, see WINNT.H
 79 */
 80
 81typedef struct {
 82  u_int16_t  control_word;
 83  u_int16_t  status_word;
 84  u_int8_t   tag_word;
 85  u_int8_t   reserved1;
 86  u_int16_t  error_opcode;
 87  u_int32_t  error_offset;
 88  u_int16_t  error_selector;
 89  u_int16_t  reserved2;
 90  u_int32_t  data_offset;
 91  u_int16_t  data_selector;
 92  u_int16_t  reserved3;
 93  u_int32_t  mx_csr;
 94  u_int32_t  mx_csr_mask;
 95  u_int128_t float_registers[8];
 96  u_int128_t xmm_registers[16];
 97  u_int8_t   reserved4[96];
 98} MDXmmSaveArea32AMD64;  /* XMM_SAVE_AREA32 */
 99
100#define MD_CONTEXT_AMD64_VR_COUNT 26
101
102typedef struct {
103  /*
104   * Register parameter home addresses.
105   */
106  u_int64_t  p1_home;
107  u_int64_t  p2_home;
108  u_int64_t  p3_home;
109  u_int64_t  p4_home;
110  u_int64_t  p5_home;
111  u_int64_t  p6_home;
112
113  /* The next field determines the layout of the structure, and which parts
114   * of it are populated */
115  u_int32_t  context_flags;
116  u_int32_t  mx_csr;
117
118  /* The next register is included with MD_CONTEXT_AMD64_CONTROL */
119  u_int16_t  cs;
120
121  /* The next 4 registers are included with MD_CONTEXT_AMD64_SEGMENTS */
122  u_int16_t  ds;
123  u_int16_t  es;
124  u_int16_t  fs;
125  u_int16_t  gs;
126
127  /* The next 2 registers are included with MD_CONTEXT_AMD64_CONTROL */
128  u_int16_t  ss;
129  u_int32_t  eflags;
130  
131  /* The next 6 registers are included with MD_CONTEXT_AMD64_DEBUG_REGISTERS */
132  u_int64_t  dr0;
133  u_int64_t  dr1;
134  u_int64_t  dr2;
135  u_int64_t  dr3;
136  u_int64_t  dr6;
137  u_int64_t  dr7;
138
139  /* The next 4 registers are included with MD_CONTEXT_AMD64_INTEGER */
140  u_int64_t  rax;
141  u_int64_t  rcx;
142  u_int64_t  rdx;
143  u_int64_t  rbx;
144
145  /* The next register is included with MD_CONTEXT_AMD64_CONTROL */
146  u_int64_t  rsp;
147
148  /* The next 11 registers are included with MD_CONTEXT_AMD64_INTEGER */
149  u_int64_t  rbp;
150  u_int64_t  rsi;
151  u_int64_t  rdi;
152  u_int64_t  r8;
153  u_int64_t  r9;
154  u_int64_t  r10;
155  u_int64_t  r11;
156  u_int64_t  r12;
157  u_int64_t  r13;
158  u_int64_t  r14;
159  u_int64_t  r15;
160
161  /* The next register is included with MD_CONTEXT_AMD64_CONTROL */
162  u_int64_t  rip;
163
164  /* The next set of registers are included with
165   * MD_CONTEXT_AMD64_FLOATING_POINT
166   */
167  union {
168    MDXmmSaveArea32AMD64 flt_save;
169    struct {
170      u_int128_t header[2];
171      u_int128_t legacy[8];
172      u_int128_t xmm0;
173      u_int128_t xmm1;
174      u_int128_t xmm2;
175      u_int128_t xmm3;
176      u_int128_t xmm4;
177      u_int128_t xmm5;
178      u_int128_t xmm6;
179      u_int128_t xmm7;
180      u_int128_t xmm8;
181      u_int128_t xmm9;
182      u_int128_t xmm10;
183      u_int128_t xmm11;
184      u_int128_t xmm12;
185      u_int128_t xmm13;
186      u_int128_t xmm14;
187      u_int128_t xmm15;
188    } sse_registers;
189  };
190
191  u_int128_t vector_register[MD_CONTEXT_AMD64_VR_COUNT];
192  u_int64_t  vector_control;
193
194  /* The next 5 registers are included with MD_CONTEXT_AMD64_DEBUG_REGISTERS */
195  u_int64_t debug_control;
196  u_int64_t last_branch_to_rip;
197  u_int64_t last_branch_from_rip;
198  u_int64_t last_exception_to_rip;
199  u_int64_t last_exception_from_rip;
200  
201} MDRawContextAMD64;  /* CONTEXT */
202
203/* For (MDRawContextAMD64).context_flags.  These values indicate the type of
204 * context stored in the structure.  The high 24 bits identify the CPU, the
205 * low 8 bits identify the type of context saved. */
206#define MD_CONTEXT_AMD64 0x00100000  /* CONTEXT_AMD64 */
207#define MD_CONTEXT_AMD64_CONTROL         (MD_CONTEXT_AMD64 | 0x00000001)
208     /* CONTEXT_CONTROL */
209#define MD_CONTEXT_AMD64_INTEGER         (MD_CONTEXT_AMD64 | 0x00000002)
210     /* CONTEXT_INTEGER */
211#define MD_CONTEXT_AMD64_SEGMENTS        (MD_CONTEXT_AMD64 | 0x00000004)
212     /* CONTEXT_SEGMENTS */
213#define MD_CONTEXT_AMD64_FLOATING_POINT  (MD_CONTEXT_AMD64 | 0x00000008)
214     /* CONTEXT_FLOATING_POINT */
215#define MD_CONTEXT_AMD64_DEBUG_REGISTERS (MD_CONTEXT_AMD64 | 0x00000010)
216     /* CONTEXT_DEBUG_REGISTERS */
217#define MD_CONTEXT_AMD64_XSTATE          (MD_CONTEXT_AMD64 | 0x00000040)
218     /* CONTEXT_XSTATE */
219
220/* WinNT.h refers to CONTEXT_MMX_REGISTERS but doesn't appear to define it
221 * I think it really means CONTEXT_FLOATING_POINT.
222 */
223
224#define MD_CONTEXT_AMD64_FULL            (MD_CONTEXT_AMD64_CONTROL | \
225                                          MD_CONTEXT_AMD64_INTEGER | \
226                                          MD_CONTEXT_AMD64_FLOATING_POINT)
227     /* CONTEXT_FULL */
228
229#define MD_CONTEXT_AMD64_ALL             (MD_CONTEXT_AMD64_FULL | \
230                                          MD_CONTEXT_AMD64_SEGMENTS | \
231                                          MD_CONTEXT_X86_DEBUG_REGISTERS)
232     /* CONTEXT_ALL */
233
234
235#endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_AMD64_H__ */