/thirdparty/breakpad/google_breakpad/common/minidump_cpu_x86.h

http://github.com/tomahawk-player/tomahawk · C Header · 174 lines · 59 code · 17 blank · 98 comment · 0 complexity · 65d2e1cdd1622c926f324316eb39aaa6 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. /* 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 x86. 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. #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_X86_H__
  71. #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_X86_H__
  72. #define MD_FLOATINGSAVEAREA_X86_REGISTERAREA_SIZE 80
  73. /* SIZE_OF_80387_REGISTERS */
  74. typedef struct {
  75. u_int32_t control_word;
  76. u_int32_t status_word;
  77. u_int32_t tag_word;
  78. u_int32_t error_offset;
  79. u_int32_t error_selector;
  80. u_int32_t data_offset;
  81. u_int32_t data_selector;
  82. /* register_area contains eight 80-bit (x87 "long double") quantities for
  83. * floating-point registers %st0 (%mm0) through %st7 (%mm7). */
  84. u_int8_t register_area[MD_FLOATINGSAVEAREA_X86_REGISTERAREA_SIZE];
  85. u_int32_t cr0_npx_state;
  86. } MDFloatingSaveAreaX86; /* FLOATING_SAVE_AREA */
  87. #define MD_CONTEXT_X86_EXTENDED_REGISTERS_SIZE 512
  88. /* MAXIMUM_SUPPORTED_EXTENSION */
  89. typedef struct {
  90. /* The next field determines the layout of the structure, and which parts
  91. * of it are populated */
  92. u_int32_t context_flags;
  93. /* The next 6 registers are included with MD_CONTEXT_X86_DEBUG_REGISTERS */
  94. u_int32_t dr0;
  95. u_int32_t dr1;
  96. u_int32_t dr2;
  97. u_int32_t dr3;
  98. u_int32_t dr6;
  99. u_int32_t dr7;
  100. /* The next field is included with MD_CONTEXT_X86_FLOATING_POINT */
  101. MDFloatingSaveAreaX86 float_save;
  102. /* The next 4 registers are included with MD_CONTEXT_X86_SEGMENTS */
  103. u_int32_t gs;
  104. u_int32_t fs;
  105. u_int32_t es;
  106. u_int32_t ds;
  107. /* The next 6 registers are included with MD_CONTEXT_X86_INTEGER */
  108. u_int32_t edi;
  109. u_int32_t esi;
  110. u_int32_t ebx;
  111. u_int32_t edx;
  112. u_int32_t ecx;
  113. u_int32_t eax;
  114. /* The next 6 registers are included with MD_CONTEXT_X86_CONTROL */
  115. u_int32_t ebp;
  116. u_int32_t eip;
  117. u_int32_t cs; /* WinNT.h says "must be sanitized" */
  118. u_int32_t eflags; /* WinNT.h says "must be sanitized" */
  119. u_int32_t esp;
  120. u_int32_t ss;
  121. /* The next field is included with MD_CONTEXT_X86_EXTENDED_REGISTERS.
  122. * It contains vector (MMX/SSE) registers. It it laid out in the
  123. * format used by the fxsave and fsrstor instructions, so it includes
  124. * a copy of the x87 floating-point registers as well. See FXSAVE in
  125. * "Intel Architecture Software Developer's Manual, Volume 2." */
  126. u_int8_t extended_registers[
  127. MD_CONTEXT_X86_EXTENDED_REGISTERS_SIZE];
  128. } MDRawContextX86; /* CONTEXT */
  129. /* For (MDRawContextX86).context_flags. These values indicate the type of
  130. * context stored in the structure. The high 24 bits identify the CPU, the
  131. * low 8 bits identify the type of context saved. */
  132. #define MD_CONTEXT_X86 0x00010000
  133. /* CONTEXT_i386, CONTEXT_i486: identifies CPU */
  134. #define MD_CONTEXT_X86_CONTROL (MD_CONTEXT_X86 | 0x00000001)
  135. /* CONTEXT_CONTROL */
  136. #define MD_CONTEXT_X86_INTEGER (MD_CONTEXT_X86 | 0x00000002)
  137. /* CONTEXT_INTEGER */
  138. #define MD_CONTEXT_X86_SEGMENTS (MD_CONTEXT_X86 | 0x00000004)
  139. /* CONTEXT_SEGMENTS */
  140. #define MD_CONTEXT_X86_FLOATING_POINT (MD_CONTEXT_X86 | 0x00000008)
  141. /* CONTEXT_FLOATING_POINT */
  142. #define MD_CONTEXT_X86_DEBUG_REGISTERS (MD_CONTEXT_X86 | 0x00000010)
  143. /* CONTEXT_DEBUG_REGISTERS */
  144. #define MD_CONTEXT_X86_EXTENDED_REGISTERS (MD_CONTEXT_X86 | 0x00000020)
  145. /* CONTEXT_EXTENDED_REGISTERS */
  146. #define MD_CONTEXT_X86_XSTATE (MD_CONTEXT_X86 | 0x00000040)
  147. /* CONTEXT_XSTATE */
  148. #define MD_CONTEXT_X86_FULL (MD_CONTEXT_X86_CONTROL | \
  149. MD_CONTEXT_X86_INTEGER | \
  150. MD_CONTEXT_X86_SEGMENTS)
  151. /* CONTEXT_FULL */
  152. #define MD_CONTEXT_X86_ALL (MD_CONTEXT_X86_FULL | \
  153. MD_CONTEXT_X86_FLOATING_POINT | \
  154. MD_CONTEXT_X86_DEBUG_REGISTERS | \
  155. MD_CONTEXT_X86_EXTENDED_REGISTERS)
  156. /* CONTEXT_ALL */
  157. #endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_X86_H__ */