minidump_context.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. // Copyright 2014 The Crashpad Authors. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
  15. #define CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
  16. #include <stdint.h>
  17. #include "base/compiler_specific.h"
  18. #include "snapshot/cpu_context.h"
  19. #include "util/numeric/int128.h"
  20. namespace crashpad {
  21. //! \brief Architecture-independent flags for `context_flags` fields in Minidump
  22. //! context structures.
  23. //
  24. // https://zachsaw.blogspot.com/2010/11/wow64-bug-getthreadcontext-may-return.html#c5639760895973344002
  25. enum MinidumpContextFlags : uint32_t {
  26. //! \brief The thread was executing a trap handler in kernel mode
  27. //! (`CONTEXT_EXCEPTION_ACTIVE`).
  28. //!
  29. //! If this bit is set, it indicates that the context is from a thread that
  30. //! was executing a trap handler in the kernel. This bit is only valid when
  31. //! ::kMinidumpContextExceptionReporting is also set. This bit is only used on
  32. //! Windows.
  33. kMinidumpContextExceptionActive = 0x08000000,
  34. //! \brief The thread was executing a system call in kernel mode
  35. //! (`CONTEXT_SERVICE_ACTIVE`).
  36. //!
  37. //! If this bit is set, it indicates that the context is from a thread that
  38. //! was executing a system call in the kernel. This bit is only valid when
  39. //! ::kMinidumpContextExceptionReporting is also set. This bit is only used on
  40. //! Windows.
  41. kMinidumpContextServiceActive = 0x10000000,
  42. //! \brief Kernel-mode state reporting is desired
  43. //! (`CONTEXT_EXCEPTION_REQUEST`).
  44. //!
  45. //! This bit is not used in context structures containing snapshots of thread
  46. //! CPU context. It used when calling `GetThreadContext()` on Windows to
  47. //! specify that kernel-mode state reporting
  48. //! (::kMinidumpContextExceptionReporting) is desired in the returned context
  49. //! structure.
  50. kMinidumpContextExceptionRequest = 0x40000000,
  51. //! \brief Kernel-mode state reporting is provided
  52. //! (`CONTEXT_EXCEPTION_REPORTING`).
  53. //!
  54. //! If this bit is set, it indicates that the bits indicating how the thread
  55. //! had entered kernel mode (::kMinidumpContextExceptionActive and
  56. //! ::kMinidumpContextServiceActive) are valid. This bit is only used on
  57. //! Windows.
  58. kMinidumpContextExceptionReporting = 0x80000000,
  59. };
  60. //! \brief 32-bit x86-specifc flags for MinidumpContextX86::context_flags.
  61. enum MinidumpContextX86Flags : uint32_t {
  62. //! \brief Identifies the context structure as 32-bit x86. This is the same as
  63. //! `CONTEXT_i386` and `CONTEXT_i486` on Windows for this architecture.
  64. kMinidumpContextX86 = 0x00010000,
  65. //! \brief Indicates the validity of control registers (`CONTEXT_CONTROL`).
  66. //!
  67. //! The `ebp`, `eip`, `cs`, `eflags`, `esp`, and `ss` fields are valid.
  68. kMinidumpContextX86Control = kMinidumpContextX86 | 0x00000001,
  69. //! \brief Indicates the validity of non-control integer registers
  70. //! (`CONTEXT_INTEGER`).
  71. //!
  72. //! The `edi`, `esi`, `ebx`, `edx`, `ecx, and `eax` fields are valid.
  73. kMinidumpContextX86Integer = kMinidumpContextX86 | 0x00000002,
  74. //! \brief Indicates the validity of non-control segment registers
  75. //! (`CONTEXT_SEGMENTS`).
  76. //!
  77. //! The `gs`, `fs`, `es`, and `ds` fields are valid.
  78. kMinidumpContextX86Segment = kMinidumpContextX86 | 0x00000004,
  79. //! \brief Indicates the validity of floating-point state
  80. //! (`CONTEXT_FLOATING_POINT`).
  81. //!
  82. //! The `fsave` field is valid. The `float_save` field is included in this
  83. //! definition, but its members have no practical use asdie from `fsave`.
  84. kMinidumpContextX86FloatingPoint = kMinidumpContextX86 | 0x00000008,
  85. //! \brief Indicates the validity of debug registers
  86. //! (`CONTEXT_DEBUG_REGISTERS`).
  87. //!
  88. //! The `dr0` through `dr3`, `dr6`, and `dr7` fields are valid.
  89. kMinidumpContextX86Debug = kMinidumpContextX86 | 0x00000010,
  90. //! \brief Indicates the validity of extended registers in `fxsave` format
  91. //! (`CONTEXT_EXTENDED_REGISTERS`).
  92. //!
  93. //! The `extended_registers` field is valid and contains `fxsave` data.
  94. kMinidumpContextX86Extended = kMinidumpContextX86 | 0x00000020,
  95. //! \brief Indicates the validity of `xsave` data (`CONTEXT_XSTATE`).
  96. //!
  97. //! The context contains `xsave` data. This is used with an extended context
  98. //! structure not currently defined here.
  99. kMinidumpContextX86Xstate = kMinidumpContextX86 | 0x00000040,
  100. //! \brief Indicates the validity of control, integer, and segment registers.
  101. //! (`CONTEXT_FULL`).
  102. kMinidumpContextX86Full = kMinidumpContextX86Control |
  103. kMinidumpContextX86Integer |
  104. kMinidumpContextX86Segment,
  105. //! \brief Indicates the validity of all registers except `xsave` data.
  106. //! (`CONTEXT_ALL`).
  107. kMinidumpContextX86All = kMinidumpContextX86Full |
  108. kMinidumpContextX86FloatingPoint |
  109. kMinidumpContextX86Debug |
  110. kMinidumpContextX86Extended,
  111. };
  112. //! \brief A 32-bit x86 CPU context (register state) carried in a minidump file.
  113. //!
  114. //! This is analogous to the `CONTEXT` structure on Windows when targeting
  115. //! 32-bit x86, and the `WOW64_CONTEXT` structure when targeting an x86-family
  116. //! CPU, either 32- or 64-bit. This structure is used instead of `CONTEXT` or
  117. //! `WOW64_CONTEXT` to make it available when targeting other architectures.
  118. //!
  119. //! \note This structure doesn’t carry `dr4` or `dr5`, which are obsolete and
  120. //! normally alias `dr6` and `dr7`, respectively. See Intel Software
  121. //! Developer’s Manual, Volume 3B: System Programming, Part 2 (253669-052),
  122. //! 17.2.2 “Debug Registers DR4 and DR5”.
  123. struct MinidumpContextX86 {
  124. //! \brief A bitfield composed of values of #MinidumpContextFlags and
  125. //! #MinidumpContextX86Flags.
  126. //!
  127. //! This field identifies the context structure as a 32-bit x86 CPU context,
  128. //! and indicates which other fields in the structure are valid.
  129. uint32_t context_flags;
  130. uint32_t dr0;
  131. uint32_t dr1;
  132. uint32_t dr2;
  133. uint32_t dr3;
  134. uint32_t dr6;
  135. uint32_t dr7;
  136. // CPUContextX86::Fsave has identical layout to what the x86 CONTEXT structure
  137. // places here.
  138. CPUContextX86::Fsave fsave;
  139. union {
  140. uint32_t spare_0; // As in the native x86 CONTEXT structure since Windows 8
  141. uint32_t cr0_npx_state; // As in WOW64_CONTEXT and older SDKs’ x86 CONTEXT
  142. } float_save;
  143. uint32_t gs;
  144. uint32_t fs;
  145. uint32_t es;
  146. uint32_t ds;
  147. uint32_t edi;
  148. uint32_t esi;
  149. uint32_t ebx;
  150. uint32_t edx;
  151. uint32_t ecx;
  152. uint32_t eax;
  153. uint32_t ebp;
  154. uint32_t eip;
  155. uint32_t cs;
  156. uint32_t eflags;
  157. uint32_t esp;
  158. uint32_t ss;
  159. // CPUContextX86::Fxsave has identical layout to what the x86 CONTEXT
  160. // structure places here.
  161. CPUContextX86::Fxsave fxsave;
  162. };
  163. //! \brief x86_64-specific flags for MinidumpContextAMD64::context_flags.
  164. enum MinidumpContextAMD64Flags : uint32_t {
  165. //! \brief Identifies the context structure as x86_64. This is the same as
  166. //! `CONTEXT_AMD64` on Windows for this architecture.
  167. kMinidumpContextAMD64 = 0x00100000,
  168. //! \brief Indicates the validity of control registers (`CONTEXT_CONTROL`).
  169. //!
  170. //! The `cs`, `ss`, `eflags`, `rsp`, and `rip` fields are valid.
  171. kMinidumpContextAMD64Control = kMinidumpContextAMD64 | 0x00000001,
  172. //! \brief Indicates the validity of non-control integer registers
  173. //! (`CONTEXT_INTEGER`).
  174. //!
  175. //! The `rax`, `rcx`, `rdx`, `rbx`, `rbp`, `rsi`, `rdi`, and `r8` through
  176. //! `r15` fields are valid.
  177. kMinidumpContextAMD64Integer = kMinidumpContextAMD64 | 0x00000002,
  178. //! \brief Indicates the validity of non-control segment registers
  179. //! (`CONTEXT_SEGMENTS`).
  180. //!
  181. //! The `ds`, `es`, `fs`, and `gs` fields are valid.
  182. kMinidumpContextAMD64Segment = kMinidumpContextAMD64 | 0x00000004,
  183. //! \brief Indicates the validity of floating-point state
  184. //! (`CONTEXT_FLOATING_POINT`).
  185. //!
  186. //! The `xmm0` through `xmm15` fields are valid.
  187. kMinidumpContextAMD64FloatingPoint = kMinidumpContextAMD64 | 0x00000008,
  188. //! \brief Indicates the validity of debug registers
  189. //! (`CONTEXT_DEBUG_REGISTERS`).
  190. //!
  191. //! The `dr0` through `dr3`, `dr6`, and `dr7` fields are valid.
  192. kMinidumpContextAMD64Debug = kMinidumpContextAMD64 | 0x00000010,
  193. //! \brief Indicates the validity of `xsave` data (`CONTEXT_XSTATE`).
  194. //!
  195. //! The context contains `xsave` data. This is used with an extended context
  196. //! structure which is partly implemented for CET state only.
  197. kMinidumpContextAMD64Xstate = kMinidumpContextAMD64 | 0x00000040,
  198. //! \brief Indicates the validity of control, integer, and floating-point
  199. //! registers (`CONTEXT_FULL`).
  200. kMinidumpContextAMD64Full = kMinidumpContextAMD64Control |
  201. kMinidumpContextAMD64Integer |
  202. kMinidumpContextAMD64FloatingPoint,
  203. //! \brief Indicates the validity of all registers except `xsave` data
  204. //! (`CONTEXT_ALL`).
  205. kMinidumpContextAMD64All = kMinidumpContextAMD64Full |
  206. kMinidumpContextAMD64Segment |
  207. kMinidumpContextAMD64Debug,
  208. };
  209. //! \brief An x86_64 (AMD64) CPU context (register state) carried in a minidump
  210. //! file.
  211. //!
  212. //! This is analogous to the `CONTEXT` structure on Windows when targeting
  213. //! x86_64. This structure is used instead of `CONTEXT` to make it available
  214. //! when targeting other architectures.
  215. //!
  216. //! \note This structure doesn’t carry `dr4` or `dr5`, which are obsolete and
  217. //! normally alias `dr6` and `dr7`, respectively. See Intel Software
  218. //! Developer’s Manual, Volume 3B: System Programming, Part 2 (253669-052),
  219. //! 17.2.2 “Debug Registers DR4 and DR5”.
  220. struct alignas(16) MinidumpContextAMD64 {
  221. //! \brief Register parameter home address.
  222. //!
  223. //! On Windows, this field may contain the “home” address (on-stack, in the
  224. //! shadow area) of a parameter passed by register. This field is present for
  225. //! convenience but is not necessarily populated, even if a corresponding
  226. //! parameter was passed by register.
  227. //!
  228. //! \{
  229. uint64_t p1_home;
  230. uint64_t p2_home;
  231. uint64_t p3_home;
  232. uint64_t p4_home;
  233. uint64_t p5_home;
  234. uint64_t p6_home;
  235. //! \}
  236. //! \brief A bitfield composed of values of #MinidumpContextFlags and
  237. //! #MinidumpContextAMD64Flags.
  238. //!
  239. //! This field identifies the context structure as an x86_64 CPU context, and
  240. //! indicates which other fields in the structure are valid.
  241. uint32_t context_flags;
  242. uint32_t mx_csr;
  243. uint16_t cs;
  244. uint16_t ds;
  245. uint16_t es;
  246. uint16_t fs;
  247. uint16_t gs;
  248. uint16_t ss;
  249. uint32_t eflags;
  250. uint64_t dr0;
  251. uint64_t dr1;
  252. uint64_t dr2;
  253. uint64_t dr3;
  254. uint64_t dr6;
  255. uint64_t dr7;
  256. uint64_t rax;
  257. uint64_t rcx;
  258. uint64_t rdx;
  259. uint64_t rbx;
  260. uint64_t rsp;
  261. uint64_t rbp;
  262. uint64_t rsi;
  263. uint64_t rdi;
  264. uint64_t r8;
  265. uint64_t r9;
  266. uint64_t r10;
  267. uint64_t r11;
  268. uint64_t r12;
  269. uint64_t r13;
  270. uint64_t r14;
  271. uint64_t r15;
  272. uint64_t rip;
  273. // CPUContextX86_64::Fxsave has identical layout to what the x86_64 CONTEXT
  274. // structure places here.
  275. CPUContextX86_64::Fxsave fxsave;
  276. uint128_struct vector_register[26];
  277. uint64_t vector_control;
  278. //! \brief Model-specific debug extension register.
  279. //!
  280. //! See Intel Software Developer’s Manual, Volume 3B: System Programming, Part
  281. //! 2 (253669-051), 17.4 “Last Branch, Interrupt, and Exception Recording
  282. //! Overview”, and AMD Architecture Programmer’s Manual, Volume 2: System
  283. //! Programming (24593-3.24), 13.1.6 “Control-Transfer Breakpoint Features”.
  284. //!
  285. //! \{
  286. uint64_t debug_control;
  287. uint64_t last_branch_to_rip;
  288. uint64_t last_branch_from_rip;
  289. uint64_t last_exception_to_rip;
  290. uint64_t last_exception_from_rip;
  291. //! \}
  292. };
  293. //! \brief 32-bit ARM-specifc flags for MinidumpContextARM::context_flags.
  294. enum MinidumpContextARMFlags : uint32_t {
  295. //! \brief Identifies the context structure as 32-bit ARM.
  296. kMinidumpContextARM = 0x40000000,
  297. //! \brief Indicates the validity of integer regsiters.
  298. //!
  299. //! Regsiters `r0`-`r15` and `cpsr` are valid.
  300. kMinidumpContextARMInteger = kMinidumpContextARM | 0x00000002,
  301. //! \brief Inidicates the validity of VFP regsiters.
  302. //!
  303. //! Registers `d0`-`d31` and `fpscr` are valid.
  304. kMinidumpContextARMVFP = kMinidumpContextARM | 0x00000004,
  305. //! \brief Indicates the validity of all registers.
  306. kMinidumpContextARMAll = kMinidumpContextARMInteger | kMinidumpContextARMVFP,
  307. };
  308. //! \brief A 32-bit ARM CPU context (register state) carried in a minidump file.
  309. struct MinidumpContextARM {
  310. //! \brief A bitfield composed of values of #MinidumpContextFlags and
  311. //! #MinidumpContextARMFlags.
  312. //!
  313. //! This field identifies the context structure as a 32-bit ARM CPU context,
  314. //! and indicates which other fields in the structure are valid.
  315. uint32_t context_flags;
  316. //! \brief General-purpose registers `r0`-`r15`.
  317. uint32_t regs[11];
  318. uint32_t fp; // r11
  319. uint32_t ip; // r12
  320. uint32_t sp; // r13
  321. uint32_t lr; // r14
  322. uint32_t pc; // r15
  323. //! \brief Current program status register.
  324. uint32_t cpsr;
  325. //! \brief Floating-point status and control register.
  326. uint32_t fpscr;
  327. //! \brief VFP registers `d0`-`d31`.
  328. uint64_t vfp[32];
  329. //! \brief This space is unused. It is included for compatibility with
  330. //! breakpad (which also doesn't use it).
  331. uint32_t extra[8];
  332. };
  333. //! \brief CONTEXT_CHUNK
  334. struct MinidumpContextChunk {
  335. int32_t offset;
  336. uint32_t size;
  337. };
  338. //! \brief CONTEXT_EX
  339. struct MinidumpContextExHeader {
  340. MinidumpContextChunk all;
  341. MinidumpContextChunk legacy;
  342. MinidumpContextChunk xstate;
  343. };
  344. //! \brief XSAVE_AREA_HEADER
  345. struct MinidumpXSaveAreaHeader {
  346. uint64_t mask;
  347. uint64_t compaction_mask;
  348. uint64_t xsave_header_reserved[6];
  349. };
  350. //! \brief Offset of first xsave feature in the full extended context.
  351. //!
  352. //! This is used to calculate the final size of the extended context, and
  353. //! can be validated by calling InitializeContext2 with one XSTATE feature,
  354. //! and LocateXStateFeature to determine the first offset.
  355. //! Also see "MANAGING STATE USING THE XSAVE FEATURE SET", Ch. 13, Intel SDM.
  356. constexpr uint32_t kMinidumpAMD64XSaveOffset = 0x550;
  357. //! \brief Offset of first xsave feature within the extended context area.
  358. //!
  359. //! 0x240 is the size of the legacy area (512) + the xsave header(64 bytes)
  360. //! Intel SDM 13.4.1. This is not where the item is in the extended compacted
  361. //! context, but is the offset recorded in the minidump. It needs to be correct
  362. //! there. See https://windows-internals.com/cet-on-windows/ for some discussion
  363. //! "CONTEXT_XSTATE: Extended processor state chunk. The state is stored in the
  364. //! same format the XSAVE operation stores it with exception of the first 512
  365. //! bytes, i.e. starting from XSAVE_AREA_HEADER." This may vary by cpuid.
  366. constexpr uint32_t kXSaveAreaFirstOffset = 0x240;
  367. //! \brief XSAVE_CET_U_FORMAT
  368. struct MinidumpAMD64XSaveFormatCetU {
  369. uint64_t cetmsr;
  370. uint64_t ssp;
  371. };
  372. //! \brief 64-bit ARM-specifc flags for MinidumpContextARM64::context_flags.
  373. enum MinidumpContextARM64Flags : uint32_t {
  374. //! \brief Identifies the context structure as 64-bit ARM.
  375. kMinidumpContextARM64 = 0x00400000,
  376. //! \brief Indicates the validity of control registers.
  377. //!
  378. //! Registers `fp`, `lr`, `sp`, `pc`, and `cpsr`.
  379. kMinidumpContextARM64Control = kMinidumpContextARM64 | 0x00000001,
  380. //! \brief Indicates the validty of integer registers.
  381. //!
  382. //! Registers `x0`-`x28`.
  383. kMinidumpContextARM64Integer = kMinidumpContextARM64 | 0x00000002,
  384. //! \brief Indicates the validity of fpsimd registers.
  385. //!
  386. //! Registers `v0`-`v31`, `fpsr`, and `fpcr` are valid.
  387. kMinidumpContextARM64Fpsimd = kMinidumpContextARM64 | 0x00000004,
  388. //! \brief Indicates the validity of debug registers.
  389. //!
  390. //! `bcr`, `bvr`, `wcr`, and `wvr` are valid.
  391. kMinidumpContextARM64Debug = kMinidumpContextARM64 | 0x00000008,
  392. //! \brief Indicates the validity of control, integer and floating point
  393. //! registers.
  394. kMinidumpContextARM64Full = kMinidumpContextARM64Control |
  395. kMinidumpContextARM64Integer |
  396. kMinidumpContextARM64Fpsimd,
  397. //! \brief Indicates the validity of all registers.
  398. kMinidumpContextARM64All =
  399. kMinidumpContextARM64Full | kMinidumpContextARM64Debug,
  400. };
  401. //! \brief A 64-bit ARM CPU context (register state) carried in a minidump file.
  402. struct MinidumpContextARM64 {
  403. uint32_t context_flags;
  404. //! \brief Current program status register.
  405. uint32_t cpsr;
  406. //! \brief General-purpose registers `x0`-`x28`.
  407. uint64_t regs[29];
  408. //! \brief Frame pointer or `x29`.
  409. uint64_t fp;
  410. //! \brief Link register or `x30`.
  411. uint64_t lr;
  412. //! \brief Stack pointer or `x31`.
  413. uint64_t sp;
  414. //! \brief Program counter.
  415. uint64_t pc;
  416. //! \brief NEON registers `v0`-`v31`.
  417. uint128_struct fpsimd[32];
  418. //! \brief Floating-point control register.
  419. uint32_t fpcr;
  420. //! \brief Floating-point status register.
  421. uint32_t fpsr;
  422. //! \brief Debug registers.
  423. uint32_t bcr[8];
  424. uint64_t bvr[8];
  425. uint32_t wcr[2];
  426. uint64_t wvr[2];
  427. };
  428. //! \brief 32bit MIPS-specifc flags for MinidumpContextMIPS::context_flags.
  429. //! Based on minidump_cpu_mips.h from breakpad
  430. enum MinidumpContextMIPSFlags : uint32_t {
  431. //! \brief Identifies the context structure as MIPSEL.
  432. kMinidumpContextMIPS = 0x00040000,
  433. //! \brief Indicates the validity of integer registers.
  434. //!
  435. //! Registers `0`-`31`, `mdhi`, `mdlo`, `epc`, `badvaddr`, `status` and
  436. //! `cause` are valid.
  437. kMinidumpContextMIPSInteger = kMinidumpContextMIPS | 0x00000002,
  438. //! \brief Indicates the validity of floating point registers.
  439. //!
  440. //! Floating point registers `0`-`31`, `fpcsr` and `fir` are valid
  441. kMinidumpContextMIPSFloatingPoint = kMinidumpContextMIPS | 0x00000004,
  442. //! \brief Indicates the validity of DSP registers.
  443. //!
  444. //! Registers `hi0`-`hi2`, `lo0`-`lo2` and `dsp_control` are valid
  445. kMinidumpContextMIPSDSP = kMinidumpContextMIPS | 0x00000008,
  446. //! \brief Indicates the validity of all registers.
  447. kMinidumpContextMIPSAll = kMinidumpContextMIPSInteger |
  448. kMinidumpContextMIPSFloatingPoint |
  449. kMinidumpContextMIPSDSP,
  450. };
  451. //! \brief A 32bit MIPS CPU context (register state) carried in a minidump file.
  452. struct MinidumpContextMIPS {
  453. uint32_t context_flags;
  454. //! \brief This padding field is included for breakpad compatibility.
  455. uint32_t _pad0;
  456. //! \brief General purpose registers `0`-`31`.
  457. uint64_t regs[32];
  458. //! \brief Multiply/divide result.
  459. uint64_t mdhi, mdlo;
  460. //! \brief DSP registers.
  461. uint32_t hi[3];
  462. uint32_t lo[3];
  463. uint32_t dsp_control;
  464. //! \brief This padding field is included for breakpad compatibility.
  465. uint32_t _pad1;
  466. // \brief cp0 registers.
  467. uint64_t epc;
  468. uint64_t badvaddr;
  469. uint32_t status;
  470. uint32_t cause;
  471. //! \brief FPU registers.
  472. union {
  473. struct {
  474. float _fp_fregs;
  475. uint32_t _fp_pad;
  476. } fregs[32];
  477. double dregs[32];
  478. } fpregs;
  479. //! \brief FPU status register.
  480. uint32_t fpcsr;
  481. //! \brief FPU implementation register.
  482. uint32_t fir;
  483. };
  484. //! \brief 64bit MIPS-specifc flags for MinidumpContextMIPS64::context_flags.
  485. //! Based on minidump_cpu_mips.h from breakpad
  486. enum MinidumpContextMIPS64Flags : uint32_t {
  487. //! \brief Identifies the context structure as MIPS64EL.
  488. kMinidumpContextMIPS64 = 0x00080000,
  489. //! \brief Indicates the validity of integer registers.
  490. //!
  491. //! Registers `0`-`31`, `mdhi`, `mdlo`, `epc`, `badvaddr`, `status` and
  492. //! `cause` are valid.
  493. kMinidumpContextMIPS64Integer = kMinidumpContextMIPS64 | 0x00000002,
  494. //! \brief Indicates the validity of floating point registers.
  495. //!
  496. //! Floating point registers `0`-`31`, `fpcsr` and `fir` are valid
  497. kMinidumpContextMIPS64FloatingPoint = kMinidumpContextMIPS64 | 0x00000004,
  498. //! \brief Indicates the validity of DSP registers.
  499. //!
  500. //! Registers `hi0`-`hi2`, `lo0`-`lo2` and `dsp_control` are valid.
  501. kMinidumpContextMIPS64DSP = kMinidumpContextMIPS64 | 0x00000008,
  502. //! \brief Indicates the validity of all registers.
  503. kMinidumpContextMIPS64All = kMinidumpContextMIPS64Integer |
  504. kMinidumpContextMIPS64FloatingPoint |
  505. kMinidumpContextMIPS64DSP,
  506. };
  507. //! \brief A 32bit MIPS CPU context (register state) carried in a minidump file.
  508. struct MinidumpContextMIPS64 {
  509. uint64_t context_flags;
  510. //! \brief General purpose registers.
  511. uint64_t regs[32];
  512. //! \brief Multiply/divide result.
  513. uint64_t mdhi, mdlo;
  514. //! \brief DSP registers.
  515. uint64_t hi[3];
  516. uint64_t lo[3];
  517. uint64_t dsp_control;
  518. //! \brief cp0 registers.
  519. uint64_t epc;
  520. uint64_t badvaddr;
  521. uint64_t status;
  522. uint64_t cause;
  523. //! \brief FPU registers.
  524. union {
  525. struct {
  526. float _fp_fregs;
  527. uint32_t _fp_pad;
  528. } fregs[32];
  529. double dregs[32];
  530. } fpregs;
  531. //! \brief FPU status register.
  532. uint64_t fpcsr;
  533. //! \brief FPU implementation register.
  534. uint64_t fir;
  535. };
  536. //! \brief 64bit RISC-V-specifc flags for MinidumpContextRISCV64::context_flags.
  537. //! Based on minidump_cpu_riscv64.h from breakpad
  538. enum MinidumpContextRISCV64Flags : uint32_t {
  539. //! \brief Identifies the context structure as RISCV64.
  540. kMinidumpContextRISCV64 = 0x00080000,
  541. //! \brief Indicates the validity of integer registers.
  542. //!
  543. //! Registers `x1`-`x31` and pc are valid.
  544. kMinidumpContextRISCV64Integer = kMinidumpContextRISCV64 | 0x00000002,
  545. //! \brief Indicates the validity of floating point registers.
  546. //!
  547. //! Floating point registers `f0`-`f31`, and `fcsr` are valid
  548. kMinidumpContextRISCV64FloatingPoint = kMinidumpContextRISCV64 | 0x00000004,
  549. //! \brief Indicates the validity of all registers.
  550. kMinidumpContextRISCV64All = kMinidumpContextRISCV64Integer |
  551. kMinidumpContextRISCV64FloatingPoint,
  552. };
  553. //! \brief A 64bit RISCV CPU context (register state) carried in a minidump file.
  554. struct MinidumpContextRISCV64 {
  555. uint64_t context_flags;
  556. //! \brief General purpose registers.
  557. uint64_t regs[32];
  558. //! \brief FPU registers.
  559. uint64_t fpregs[32];
  560. //! \brief FPU status register.
  561. uint64_t fcsr;
  562. };
  563. } // namespace crashpad
  564. #endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_