LLDB  mainline
RegisterContextMinidump_x86_64.h
Go to the documentation of this file.
1 //===-- RegisterContextMinidump_x86_64.h ------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_64_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_64_H
11 
12 #include "MinidumpTypes.h"
13 
16 
18 
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/BitmaskEnum.h"
21 #include "llvm/Support/Endian.h"
22 
23 // C includes
24 // C++ includes
25 
26 namespace lldb_private {
27 
28 namespace minidump {
29 
30 // This function receives an ArrayRef pointing to the bytes of the Minidump
31 // register context and returns a DataBuffer that's ordered by the offsets
32 // specified in the RegisterInfoInterface argument
33 // This way we can reuse the already existing register contexts
34 lldb::DataBufferSP
35 ConvertMinidumpContext_x86_64(llvm::ArrayRef<uint8_t> source_data,
36  RegisterInfoInterface *target_reg_interface);
37 
38 struct Uint128 {
39  llvm::support::ulittle64_t high;
40  llvm::support::ulittle64_t low;
41 };
42 
43 // Reference: see breakpad/crashpad source or WinNT.h
45  llvm::support::ulittle16_t control_word;
46  llvm::support::ulittle16_t status_word;
47  uint8_t tag_word;
48  uint8_t reserved1;
49  llvm::support::ulittle16_t error_opcode;
50  llvm::support::ulittle32_t error_offset;
51  llvm::support::ulittle16_t error_selector;
52  llvm::support::ulittle16_t reserved2;
53  llvm::support::ulittle32_t data_offset;
54  llvm::support::ulittle16_t data_selector;
55  llvm::support::ulittle16_t reserved3;
56  llvm::support::ulittle32_t mx_csr;
57  llvm::support::ulittle32_t mx_csr_mask;
60  uint8_t reserved4[96];
61 };
62 
64  // Register parameter home addresses.
65  llvm::support::ulittle64_t p1_home;
66  llvm::support::ulittle64_t p2_home;
67  llvm::support::ulittle64_t p3_home;
68  llvm::support::ulittle64_t p4_home;
69  llvm::support::ulittle64_t p5_home;
70  llvm::support::ulittle64_t p6_home;
71 
72  // The context_flags field determines which parts
73  // of the structure are populated (have valid values)
74  llvm::support::ulittle32_t context_flags;
75  llvm::support::ulittle32_t mx_csr;
76 
77  // The next register is included with
78  // MinidumpContext_x86_64_Flags::Control
79  llvm::support::ulittle16_t cs;
80 
81  // The next 4 registers are included with
82  // MinidumpContext_x86_64_Flags::Segments
83  llvm::support::ulittle16_t ds;
84  llvm::support::ulittle16_t es;
85  llvm::support::ulittle16_t fs;
86  llvm::support::ulittle16_t gs;
87 
88  // The next 2 registers are included with
89  // MinidumpContext_x86_64_Flags::Control
90  llvm::support::ulittle16_t ss;
91  llvm::support::ulittle32_t eflags;
92 
93  // The next 6 registers are included with
94  // MinidumpContext_x86_64_Flags::DebugRegisters
95  llvm::support::ulittle64_t dr0;
96  llvm::support::ulittle64_t dr1;
97  llvm::support::ulittle64_t dr2;
98  llvm::support::ulittle64_t dr3;
99  llvm::support::ulittle64_t dr6;
100  llvm::support::ulittle64_t dr7;
101 
102  // The next 4 registers are included with
103  // MinidumpContext_x86_64_Flags::Integer
104  llvm::support::ulittle64_t rax;
105  llvm::support::ulittle64_t rcx;
106  llvm::support::ulittle64_t rdx;
107  llvm::support::ulittle64_t rbx;
108 
109  // The next register is included with
110  // MinidumpContext_x86_64_Flags::Control
111  llvm::support::ulittle64_t rsp;
112 
113  // The next 11 registers are included with
114  // MinidumpContext_x86_64_Flags::Integer
115  llvm::support::ulittle64_t rbp;
116  llvm::support::ulittle64_t rsi;
117  llvm::support::ulittle64_t rdi;
118  llvm::support::ulittle64_t r8;
119  llvm::support::ulittle64_t r9;
120  llvm::support::ulittle64_t r10;
121  llvm::support::ulittle64_t r11;
122  llvm::support::ulittle64_t r12;
123  llvm::support::ulittle64_t r13;
124  llvm::support::ulittle64_t r14;
125  llvm::support::ulittle64_t r15;
126 
127  // The next register is included with
128  // MinidumpContext_x86_64_Flags::Control
129  llvm::support::ulittle64_t rip;
130 
131  // The next set of registers are included with
132  // MinidumpContext_x86_64_Flags:FloatingPoint
133  union FPR {
135  struct {
139  } sse_registers;
140  };
141 
142  enum {
143  VRCount = 26,
144  };
145 
147  llvm::support::ulittle64_t vector_control;
148 
149  // The next 5 registers are included with
150  // MinidumpContext_x86_64_Flags::DebugRegisters
151  llvm::support::ulittle64_t debug_control;
152  llvm::support::ulittle64_t last_branch_to_rip;
153  llvm::support::ulittle64_t last_branch_from_rip;
154  llvm::support::ulittle64_t last_exception_to_rip;
155  llvm::support::ulittle64_t last_exception_from_rip;
156 };
157 
158 // For context_flags. These values indicate the type of
159 // context stored in the structure. The high 24 bits identify the CPU, the
160 // low 8 bits identify the type of context saved.
162 
164  x86_64_Flag = 0x00100000,
165  Control = x86_64_Flag | 0x00000001,
166  Integer = x86_64_Flag | 0x00000002,
167  Segments = x86_64_Flag | 0x00000004,
168  FloatingPoint = x86_64_Flag | 0x00000008,
169  DebugRegisters = x86_64_Flag | 0x00000010,
170  XState = x86_64_Flag | 0x00000040,
171 
174 
175  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All)
176 };
177 
178 } // end namespace minidump
179 } // end namespace lldb_private
180 #endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_64_H
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::data_selector
llvm::support::ulittle16_t data_selector
Definition: RegisterContextMinidump_x86_64.h:54
lldb_private::minidump::MinidumpContext_x86_64_Flags::Integer
@ Integer
lldb_private::minidump::MinidumpContext_x86_64::FPR::xmm
Uint128 xmm[16]
Definition: RegisterContextMinidump_x86_64.h:138
lldb_private::minidump::MinidumpContext_x86_64::dr2
llvm::support::ulittle64_t dr2
Definition: RegisterContextMinidump_x86_64.h:97
lldb_private::minidump::MinidumpContext_x86_64::dr0
llvm::support::ulittle64_t dr0
Definition: RegisterContextMinidump_x86_64.h:95
lldb_private::minidump::MinidumpContext_x86_64::rsi
llvm::support::ulittle64_t rsi
Definition: RegisterContextMinidump_x86_64.h:116
lldb_private::minidump::MinidumpContext_x86_64::p5_home
llvm::support::ulittle64_t p5_home
Definition: RegisterContextMinidump_x86_64.h:69
lldb_private::minidump::LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
lldb_private::minidump::MinidumpContext_x86_64::r14
llvm::support::ulittle64_t r14
Definition: RegisterContextMinidump_x86_64.h:124
MinidumpTypes.h
lldb_private::minidump::MinidumpContext_x86_64::p6_home
llvm::support::ulittle64_t p6_home
Definition: RegisterContextMinidump_x86_64.h:70
lldb_private::minidump::MinidumpContext_x86_64::dr6
llvm::support::ulittle64_t dr6
Definition: RegisterContextMinidump_x86_64.h:99
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::reserved2
llvm::support::ulittle16_t reserved2
Definition: RegisterContextMinidump_x86_64.h:52
lldb_private::minidump::MinidumpContext_x86_64::last_exception_to_rip
llvm::support::ulittle64_t last_exception_to_rip
Definition: RegisterContextMinidump_x86_64.h:154
lldb_private::minidump::MinidumpContext_x86_64
Definition: RegisterContextMinidump_x86_64.h:63
lldb_private::minidump::MinidumpContext_x86_64::r15
llvm::support::ulittle64_t r15
Definition: RegisterContextMinidump_x86_64.h:125
lldb_private::minidump::MinidumpContext_x86_64::VRCount
@ VRCount
Definition: RegisterContextMinidump_x86_64.h:143
lldb_private::minidump::Uint128::high
llvm::support::ulittle64_t high
Definition: RegisterContextMinidump_x86_64.h:39
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::mx_csr
llvm::support::ulittle32_t mx_csr
Definition: RegisterContextMinidump_x86_64.h:56
lldb_private::minidump::MinidumpContext_x86_64::vector_register
Uint128 vector_register[VRCount]
Definition: RegisterContextMinidump_x86_64.h:146
lldb_private::minidump::MinidumpContext_x86_64_Flags
MinidumpContext_x86_64_Flags
Definition: RegisterContextMinidump_x86_64.h:163
lldb_private::minidump::MinidumpContext_x86_64::fs
llvm::support::ulittle16_t fs
Definition: RegisterContextMinidump_x86_64.h:85
lldb_private::minidump::MinidumpContext_x86_64::rcx
llvm::support::ulittle64_t rcx
Definition: RegisterContextMinidump_x86_64.h:105
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::error_selector
llvm::support::ulittle16_t error_selector
Definition: RegisterContextMinidump_x86_64.h:51
lldb_private::minidump::MinidumpContext_x86_64::context_flags
llvm::support::ulittle32_t context_flags
Definition: RegisterContextMinidump_x86_64.h:74
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::reserved1
uint8_t reserved1
Definition: RegisterContextMinidump_x86_64.h:48
RegisterInfoInterface.h
lldb_private::minidump::MinidumpContext_x86_64::p1_home
llvm::support::ulittle64_t p1_home
Definition: RegisterContextMinidump_x86_64.h:65
lldb_private::minidump::MinidumpContext_x86_64::eflags
llvm::support::ulittle32_t eflags
Definition: RegisterContextMinidump_x86_64.h:91
lldb_private::minidump::MinidumpContext_x86_64::ss
llvm::support::ulittle16_t ss
Definition: RegisterContextMinidump_x86_64.h:90
lldb_private::minidump::MinidumpContext_x86_64::rbp
llvm::support::ulittle64_t rbp
Definition: RegisterContextMinidump_x86_64.h:115
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::error_offset
llvm::support::ulittle32_t error_offset
Definition: RegisterContextMinidump_x86_64.h:50
lldb_private::minidump::Uint128
Definition: RegisterContextMinidump_x86_64.h:38
lldb_private::minidump::MinidumpContext_x86_64_Flags::All
@ All
lldb_private::minidump::MinidumpContext_x86_64::r8
llvm::support::ulittle64_t r8
Definition: RegisterContextMinidump_x86_64.h:118
lldb_private::minidump::MinidumpContext_x86_64::p2_home
llvm::support::ulittle64_t p2_home
Definition: RegisterContextMinidump_x86_64.h:66
lldb_private::minidump::MinidumpContext_x86_64::gs
llvm::support::ulittle16_t gs
Definition: RegisterContextMinidump_x86_64.h:86
lldb_private::minidump::MinidumpContext_x86_64::dr7
llvm::support::ulittle64_t dr7
Definition: RegisterContextMinidump_x86_64.h:100
lldb_private::minidump::MinidumpXMMSaveArea32AMD64
Definition: RegisterContextMinidump_x86_64.h:44
lldb_private::minidump::ConvertMinidumpContext_x86_64
lldb::DataBufferSP ConvertMinidumpContext_x86_64(llvm::ArrayRef< uint8_t > source_data, RegisterInfoInterface *target_reg_interface)
Definition: RegisterContextMinidump_x86_64.cpp:47
lldb_private::minidump::Uint128::low
llvm::support::ulittle64_t low
Definition: RegisterContextMinidump_x86_64.h:40
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::error_opcode
llvm::support::ulittle16_t error_opcode
Definition: RegisterContextMinidump_x86_64.h:49
lldb_private::minidump::MinidumpContext_x86_64_Flags::Control
@ Control
lldb_private::minidump::MinidumpContext_x86_64_Flags::Segments
@ Segments
lldb_private::minidump::MinidumpContext_x86_64::r13
llvm::support::ulittle64_t r13
Definition: RegisterContextMinidump_x86_64.h:123
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::tag_word
uint8_t tag_word
Definition: RegisterContextMinidump_x86_64.h:47
lldb_private::minidump::MinidumpContext_x86_64::rip
llvm::support::ulittle64_t rip
Definition: RegisterContextMinidump_x86_64.h:129
lldb_private::minidump::MinidumpContext_x86_64_Flags::XState
@ XState
lldb_private::minidump::MinidumpContext_x86_64::rdx
llvm::support::ulittle64_t rdx
Definition: RegisterContextMinidump_x86_64.h:106
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::reserved3
llvm::support::ulittle16_t reserved3
Definition: RegisterContextMinidump_x86_64.h:55
lldb_private::minidump::MinidumpContext_x86_64::last_branch_from_rip
llvm::support::ulittle64_t last_branch_from_rip
Definition: RegisterContextMinidump_x86_64.h:153
lldb_private::minidump::MinidumpContext_x86_64::debug_control
llvm::support::ulittle64_t debug_control
Definition: RegisterContextMinidump_x86_64.h:151
lldb_private::minidump::MinidumpContext_x86_64::mx_csr
llvm::support::ulittle32_t mx_csr
Definition: RegisterContextMinidump_x86_64.h:75
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::float_registers
Uint128 float_registers[8]
Definition: RegisterContextMinidump_x86_64.h:58
lldb_private::minidump::MinidumpContext_x86_64::rax
llvm::support::ulittle64_t rax
Definition: RegisterContextMinidump_x86_64.h:104
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::data_offset
llvm::support::ulittle32_t data_offset
Definition: RegisterContextMinidump_x86_64.h:53
lldb_private::minidump::MinidumpContext_x86_64::last_exception_from_rip
llvm::support::ulittle64_t last_exception_from_rip
Definition: RegisterContextMinidump_x86_64.h:155
lldb_private::minidump::MinidumpContext_x86_64_Flags::FloatingPoint
@ FloatingPoint
uint32_t
lldb_private::minidump::MinidumpContext_x86_64::last_branch_to_rip
llvm::support::ulittle64_t last_branch_to_rip
Definition: RegisterContextMinidump_x86_64.h:152
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::xmm_registers
Uint128 xmm_registers[16]
Definition: RegisterContextMinidump_x86_64.h:59
lldb_private::minidump::MinidumpContext_x86_64_Flags::x86_64_Flag
@ x86_64_Flag
lldb_private::minidump::MinidumpContext_x86_64::rsp
llvm::support::ulittle64_t rsp
Definition: RegisterContextMinidump_x86_64.h:111
lldb_private::minidump::MinidumpContext_x86_64::r11
llvm::support::ulittle64_t r11
Definition: RegisterContextMinidump_x86_64.h:121
lldb_private::minidump::MinidumpContext_x86_64::r9
llvm::support::ulittle64_t r9
Definition: RegisterContextMinidump_x86_64.h:119
lldb_private::minidump::MinidumpContext_x86_64::FPR::header
Uint128 header[2]
Definition: RegisterContextMinidump_x86_64.h:136
lldb_private::minidump::MinidumpContext_x86_64::rdi
llvm::support::ulittle64_t rdi
Definition: RegisterContextMinidump_x86_64.h:117
lldb_private::minidump::MinidumpContext_x86_64::vector_control
llvm::support::ulittle64_t vector_control
Definition: RegisterContextMinidump_x86_64.h:147
lldb-x86-register-enums.h
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::control_word
llvm::support::ulittle16_t control_word
Definition: RegisterContextMinidump_x86_64.h:45
lldb_private::minidump::MinidumpContext_x86_64::FPR::sse_registers
struct lldb_private::minidump::MinidumpContext_x86_64::FPR::@89 sse_registers
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::minidump::MinidumpContext_x86_64::FPR::legacy
Uint128 legacy[8]
Definition: RegisterContextMinidump_x86_64.h:137
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::mx_csr_mask
llvm::support::ulittle32_t mx_csr_mask
Definition: RegisterContextMinidump_x86_64.h:57
lldb_private::minidump::MinidumpContext_x86_64::dr3
llvm::support::ulittle64_t dr3
Definition: RegisterContextMinidump_x86_64.h:98
lldb_private::minidump::MinidumpContext_x86_64::ds
llvm::support::ulittle16_t ds
Definition: RegisterContextMinidump_x86_64.h:83
lldb_private::minidump::MinidumpContext_x86_64::FPR
Definition: RegisterContextMinidump_x86_64.h:133
lldb_private::minidump::MinidumpContext_x86_64::dr1
llvm::support::ulittle64_t dr1
Definition: RegisterContextMinidump_x86_64.h:96
lldb_private::minidump::MinidumpContext_x86_64::r10
llvm::support::ulittle64_t r10
Definition: RegisterContextMinidump_x86_64.h:120
lldb_private::minidump::MinidumpContext_x86_64::FPR::flt_save
MinidumpXMMSaveArea32AMD64 flt_save
Definition: RegisterContextMinidump_x86_64.h:134
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::status_word
llvm::support::ulittle16_t status_word
Definition: RegisterContextMinidump_x86_64.h:46
lldb_private::minidump::MinidumpContext_x86_64::p4_home
llvm::support::ulittle64_t p4_home
Definition: RegisterContextMinidump_x86_64.h:68
lldb_private::minidump::MinidumpContext_x86_64_Flags::Full
@ Full
lldb_private::minidump::MinidumpContext_x86_64::cs
llvm::support::ulittle16_t cs
Definition: RegisterContextMinidump_x86_64.h:79
RegisterContext.h
lldb_private::minidump::MinidumpContext_x86_64::p3_home
llvm::support::ulittle64_t p3_home
Definition: RegisterContextMinidump_x86_64.h:67
lldb_private::minidump::MinidumpXMMSaveArea32AMD64::reserved4
uint8_t reserved4[96]
Definition: RegisterContextMinidump_x86_64.h:60
lldb_private::minidump::MinidumpContext_x86_64::es
llvm::support::ulittle16_t es
Definition: RegisterContextMinidump_x86_64.h:84
lldb_private::minidump::MinidumpContext_x86_64::rbx
llvm::support::ulittle64_t rbx
Definition: RegisterContextMinidump_x86_64.h:107
lldb_private::minidump::MinidumpContext_x86_64_Flags::DebugRegisters
@ DebugRegisters
lldb_private::minidump::MinidumpContext_x86_64::r12
llvm::support::ulittle64_t r12
Definition: RegisterContextMinidump_x86_64.h:122