PageRenderTime 40ms CodeModel.GetById 29ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-3.0, GPL-2.0
  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. /* minidump_format.h: A cross-platform reimplementation of minidump-related
  30. * portions of DbgHelp.h from the Windows Platform SDK.
  31. *
  32. * (This is C99 source, please don't corrupt it with C++.)
  33. *
  34. * This file contains the necessary definitions to read minidump files
  35. * produced on amd64. These files may be read on any platform provided
  36. * that the alignments of these structures on the processing system are
  37. * identical to the alignments of these structures on the producing system.
  38. * For this reason, precise-sized types are used. The structures defined
  39. * by this file have been laid out to minimize alignment problems by ensuring
  40. * ensuring that all members are aligned on their natural boundaries. In
  41. * In some cases, tail-padding may be significant when different ABIs specify
  42. * different tail-padding behaviors. To avoid problems when reading or
  43. * writing affected structures, MD_*_SIZE macros are provided where needed,
  44. * containing the useful size of the structures without padding.
  45. *
  46. * Structures that are defined by Microsoft to contain a zero-length array
  47. * are instead defined here to contain an array with one element, as
  48. * zero-length arrays are forbidden by standard C and C++. In these cases,
  49. * *_minsize constants are provided to be used in place of sizeof. For a
  50. * cleaner interface to these sizes when using C++, see minidump_size.h.
  51. *
  52. * These structures are also sufficient to populate minidump files.
  53. *
  54. * These definitions may be extended to support handling minidump files
  55. * for other CPUs and other operating systems.
  56. *
  57. * Because precise data type sizes are crucial for this implementation to
  58. * function properly and portably in terms of interoperability with minidumps
  59. * produced by DbgHelp on Windows, a set of primitive types with known sizes
  60. * are used as the basis of each structure defined by this file. DbgHelp
  61. * on Windows is assumed to be the reference implementation; this file
  62. * seeks to provide a cross-platform compatible implementation. To avoid
  63. * collisions with the types and values defined and used by DbgHelp in the
  64. * event that this implementation is used on Windows, each type and value
  65. * defined here is given a new name, beginning with "MD". Names of the
  66. * equivalent types and values in the Windows Platform SDK are given in
  67. * comments.
  68. *
  69. * Author: Mark Mentovai
  70. * Change to split into its own file: Neal Sidhwaney */
  71. #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_AMD64_H__
  72. #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_AMD64_H__
  73. /*
  74. * AMD64 support, see WINNT.H
  75. */
  76. typedef struct {
  77. u_int16_t control_word;
  78. u_int16_t status_word;
  79. u_int8_t tag_word;
  80. u_int8_t reserved1;
  81. u_int16_t error_opcode;
  82. u_int32_t error_offset;
  83. u_int16_t error_selector;
  84. u_int16_t reserved2;
  85. u_int32_t data_offset;
  86. u_int16_t data_selector;
  87. u_int16_t reserved3;
  88. u_int32_t mx_csr;
  89. u_int32_t mx_csr_mask;
  90. u_int128_t float_registers[8];
  91. u_int128_t xmm_registers[16];
  92. u_int8_t reserved4[96];
  93. } MDXmmSaveArea32AMD64; /* XMM_SAVE_AREA32 */
  94. #define MD_CONTEXT_AMD64_VR_COUNT 26
  95. typedef struct {
  96. /*
  97. * Register parameter home addresses.
  98. */
  99. u_int64_t p1_home;
  100. u_int64_t p2_home;
  101. u_int64_t p3_home;
  102. u_int64_t p4_home;
  103. u_int64_t p5_home;
  104. u_int64_t p6_home;
  105. /* The next field determines the layout of the structure, and which parts
  106. * of it are populated */
  107. u_int32_t context_flags;
  108. u_int32_t mx_csr;
  109. /* The next register is included with MD_CONTEXT_AMD64_CONTROL */
  110. u_int16_t cs;
  111. /* The next 4 registers are included with MD_CONTEXT_AMD64_SEGMENTS */
  112. u_int16_t ds;
  113. u_int16_t es;
  114. u_int16_t fs;
  115. u_int16_t gs;
  116. /* The next 2 registers are included with MD_CONTEXT_AMD64_CONTROL */
  117. u_int16_t ss;
  118. u_int32_t eflags;
  119. /* The next 6 registers are included with MD_CONTEXT_AMD64_DEBUG_REGISTERS */
  120. u_int64_t dr0;
  121. u_int64_t dr1;
  122. u_int64_t dr2;
  123. u_int64_t dr3;
  124. u_int64_t dr6;
  125. u_int64_t dr7;
  126. /* The next 4 registers are included with MD_CONTEXT_AMD64_INTEGER */
  127. u_int64_t rax;
  128. u_int64_t rcx;
  129. u_int64_t rdx;
  130. u_int64_t rbx;
  131. /* The next register is included with MD_CONTEXT_AMD64_CONTROL */
  132. u_int64_t rsp;
  133. /* The next 11 registers are included with MD_CONTEXT_AMD64_INTEGER */
  134. u_int64_t rbp;
  135. u_int64_t rsi;
  136. u_int64_t rdi;
  137. u_int64_t r8;
  138. u_int64_t r9;
  139. u_int64_t r10;
  140. u_int64_t r11;
  141. u_int64_t r12;
  142. u_int64_t r13;
  143. u_int64_t r14;
  144. u_int64_t r15;
  145. /* The next register is included with MD_CONTEXT_AMD64_CONTROL */
  146. u_int64_t rip;
  147. /* The next set of registers are included with
  148. * MD_CONTEXT_AMD64_FLOATING_POINT
  149. */
  150. union {
  151. MDXmmSaveArea32AMD64 flt_save;
  152. struct {
  153. u_int128_t header[2];
  154. u_int128_t legacy[8];
  155. u_int128_t xmm0;
  156. u_int128_t xmm1;
  157. u_int128_t xmm2;
  158. u_int128_t xmm3;
  159. u_int128_t xmm4;
  160. u_int128_t xmm5;
  161. u_int128_t xmm6;
  162. u_int128_t xmm7;
  163. u_int128_t xmm8;
  164. u_int128_t xmm9;
  165. u_int128_t xmm10;
  166. u_int128_t xmm11;
  167. u_int128_t xmm12;
  168. u_int128_t xmm13;
  169. u_int128_t xmm14;
  170. u_int128_t xmm15;
  171. } sse_registers;
  172. };
  173. u_int128_t vector_register[MD_CONTEXT_AMD64_VR_COUNT];
  174. u_int64_t vector_control;
  175. /* The next 5 registers are included with MD_CONTEXT_AMD64_DEBUG_REGISTERS */
  176. u_int64_t debug_control;
  177. u_int64_t last_branch_to_rip;
  178. u_int64_t last_branch_from_rip;
  179. u_int64_t last_exception_to_rip;
  180. u_int64_t last_exception_from_rip;
  181. } MDRawContextAMD64; /* CONTEXT */
  182. /* For (MDRawContextAMD64).context_flags. These values indicate the type of
  183. * context stored in the structure. The high 24 bits identify the CPU, the
  184. * low 8 bits identify the type of context saved. */
  185. #define MD_CONTEXT_AMD64 0x00100000 /* CONTEXT_AMD64 */
  186. #define MD_CONTEXT_AMD64_CONTROL (MD_CONTEXT_AMD64 | 0x00000001)
  187. /* CONTEXT_CONTROL */
  188. #define MD_CONTEXT_AMD64_INTEGER (MD_CONTEXT_AMD64 | 0x00000002)
  189. /* CONTEXT_INTEGER */
  190. #define MD_CONTEXT_AMD64_SEGMENTS (MD_CONTEXT_AMD64 | 0x00000004)
  191. /* CONTEXT_SEGMENTS */
  192. #define MD_CONTEXT_AMD64_FLOATING_POINT (MD_CONTEXT_AMD64 | 0x00000008)
  193. /* CONTEXT_FLOATING_POINT */
  194. #define MD_CONTEXT_AMD64_DEBUG_REGISTERS (MD_CONTEXT_AMD64 | 0x00000010)
  195. /* CONTEXT_DEBUG_REGISTERS */
  196. #define MD_CONTEXT_AMD64_XSTATE (MD_CONTEXT_AMD64 | 0x00000040)
  197. /* CONTEXT_XSTATE */
  198. /* WinNT.h refers to CONTEXT_MMX_REGISTERS but doesn't appear to define it
  199. * I think it really means CONTEXT_FLOATING_POINT.
  200. */
  201. #define MD_CONTEXT_AMD64_FULL (MD_CONTEXT_AMD64_CONTROL | \
  202. MD_CONTEXT_AMD64_INTEGER | \
  203. MD_CONTEXT_AMD64_FLOATING_POINT)
  204. /* CONTEXT_FULL */
  205. #define MD_CONTEXT_AMD64_ALL (MD_CONTEXT_AMD64_FULL | \
  206. MD_CONTEXT_AMD64_SEGMENTS | \
  207. MD_CONTEXT_X86_DEBUG_REGISTERS)
  208. /* CONTEXT_ALL */
  209. #endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_AMD64_H__ */