/thirdparty/breakpad/google_breakpad/common/minidump_cpu_ppc.h

http://github.com/tomahawk-player/tomahawk · C++ Header · 163 lines · 50 code · 18 blank · 95 comment · 2 complexity · 4f5e466faf12d84feace399b61d77e9e 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 ppc. 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. /*
  72. * Breakpad minidump extension for PowerPC support. Based on Darwin/Mac OS X'
  73. * mach/ppc/_types.h
  74. */
  75. #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC_H__
  76. #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC_H__
  77. #define MD_FLOATINGSAVEAREA_PPC_FPR_COUNT 32
  78. typedef struct {
  79. /* fpregs is a double[32] in mach/ppc/_types.h, but a u_int64_t is used
  80. * here for precise sizing. */
  81. u_int64_t fpregs[MD_FLOATINGSAVEAREA_PPC_FPR_COUNT];
  82. u_int32_t fpscr_pad;
  83. u_int32_t fpscr; /* Status/control */
  84. } MDFloatingSaveAreaPPC; /* Based on ppc_float_state */
  85. #define MD_VECTORSAVEAREA_PPC_VR_COUNT 32
  86. typedef struct {
  87. /* Vector registers (including vscr) are 128 bits, but mach/ppc/_types.h
  88. * exposes them as four 32-bit quantities. */
  89. u_int128_t save_vr[MD_VECTORSAVEAREA_PPC_VR_COUNT];
  90. u_int128_t save_vscr; /* Status/control */
  91. u_int32_t save_pad5[4];
  92. u_int32_t save_vrvalid; /* Identifies which vector registers are saved */
  93. u_int32_t save_pad6[7];
  94. } MDVectorSaveAreaPPC; /* ppc_vector_state */
  95. #define MD_CONTEXT_PPC_GPR_COUNT 32
  96. /* Use the same 32-bit alignment when accessing this structure from 64-bit code
  97. * as is used natively in 32-bit code. #pragma pack is a MSVC extension
  98. * supported by gcc. */
  99. #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
  100. #pragma pack(4)
  101. #else
  102. #pragma pack(push, 4)
  103. #endif
  104. typedef struct {
  105. /* context_flags is not present in ppc_thread_state, but it aids
  106. * identification of MDRawContextPPC among other raw context types,
  107. * and it guarantees alignment when we get to float_save. */
  108. u_int32_t context_flags;
  109. u_int32_t srr0; /* Machine status save/restore: stores pc
  110. * (instruction) */
  111. u_int32_t srr1; /* Machine status save/restore: stores msr
  112. * (ps, program/machine state) */
  113. /* ppc_thread_state contains 32 fields, r0 .. r31. Here, an array is
  114. * used for brevity. */
  115. u_int32_t gpr[MD_CONTEXT_PPC_GPR_COUNT];
  116. u_int32_t cr; /* Condition */
  117. u_int32_t xer; /* Integer (fiXed-point) exception */
  118. u_int32_t lr; /* Link */
  119. u_int32_t ctr; /* Count */
  120. u_int32_t mq; /* Multiply/Quotient (PPC 601, POWER only) */
  121. u_int32_t vrsave; /* Vector save */
  122. /* float_save and vector_save aren't present in ppc_thread_state, but
  123. * are represented in separate structures that still define a thread's
  124. * context. */
  125. MDFloatingSaveAreaPPC float_save;
  126. MDVectorSaveAreaPPC vector_save;
  127. } MDRawContextPPC; /* Based on ppc_thread_state */
  128. #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
  129. #pragma pack(0)
  130. #else
  131. #pragma pack(pop)
  132. #endif
  133. /* For (MDRawContextPPC).context_flags. These values indicate the type of
  134. * context stored in the structure. MD_CONTEXT_PPC is Breakpad-defined. Its
  135. * value was chosen to avoid likely conflicts with MD_CONTEXT_* for other
  136. * CPUs. */
  137. #define MD_CONTEXT_PPC 0x20000000
  138. #define MD_CONTEXT_PPC_BASE (MD_CONTEXT_PPC | 0x00000001)
  139. #define MD_CONTEXT_PPC_FLOATING_POINT (MD_CONTEXT_PPC | 0x00000008)
  140. #define MD_CONTEXT_PPC_VECTOR (MD_CONTEXT_PPC | 0x00000020)
  141. #define MD_CONTEXT_PPC_FULL MD_CONTEXT_PPC_BASE
  142. #define MD_CONTEXT_PPC_ALL (MD_CONTEXT_PPC_FULL | \
  143. MD_CONTEXT_PPC_FLOATING_POINT | \
  144. MD_CONTEXT_PPC_VECTOR)
  145. #endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_PPC_H__ */