LLDB mainline
RegisterContextLinuxCore_x86_64.cpp
Go to the documentation of this file.
1//===-- RegisterContextLinuxCore_x86_64.cpp -------------------------------===//
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
10#include "lldb/Target/Thread.h"
13
14using namespace lldb_private;
15
16const uint32_t g_gpr_regnums_i386[] = {
25 LLDB_INVALID_REGNUM, // Register sets must be terminated with
26 // LLDB_INVALID_REGNUM.
27};
28static_assert((sizeof(g_gpr_regnums_i386) / sizeof(g_gpr_regnums_i386[0])) -
29 1 ==
31 "g_gpr_regnums_i386 has wrong number of register infos");
32
33const uint32_t g_lldb_regnums_i386[] = {
43 LLDB_INVALID_REGNUM // Register sets must be terminated with
44 // LLDB_INVALID_REGNUM.
45};
46static_assert((sizeof(g_lldb_regnums_i386) / sizeof(g_lldb_regnums_i386[0])) -
47 1 ==
49 "g_lldb_regnums_i386 has wrong number of register infos");
50
51const uint32_t g_avx_regnums_i386[] = {
54 LLDB_INVALID_REGNUM // Register sets must be terminated with
55 // LLDB_INVALID_REGNUM.
56};
57static_assert((sizeof(g_avx_regnums_i386) / sizeof(g_avx_regnums_i386[0])) -
58 1 ==
60 " g_avx_regnums_i386 has wrong number of register infos");
61
62static const uint32_t g_gpr_regnums_x86_64[] = {
97 x86_64_with_base::lldb_r8d, // Low 32 bits or r8
98 x86_64_with_base::lldb_r9d, // Low 32 bits or r9
99 x86_64_with_base::lldb_r10d, // Low 32 bits or r10
100 x86_64_with_base::lldb_r11d, // Low 32 bits or r11
101 x86_64_with_base::lldb_r12d, // Low 32 bits or r12
102 x86_64_with_base::lldb_r13d, // Low 32 bits or r13
103 x86_64_with_base::lldb_r14d, // Low 32 bits or r14
104 x86_64_with_base::lldb_r15d, // Low 32 bits or r15
113 x86_64_with_base::lldb_r8w, // Low 16 bits or r8
114 x86_64_with_base::lldb_r9w, // Low 16 bits or r9
115 x86_64_with_base::lldb_r10w, // Low 16 bits or r10
116 x86_64_with_base::lldb_r11w, // Low 16 bits or r11
117 x86_64_with_base::lldb_r12w, // Low 16 bits or r12
118 x86_64_with_base::lldb_r13w, // Low 16 bits or r13
119 x86_64_with_base::lldb_r14w, // Low 16 bits or r14
120 x86_64_with_base::lldb_r15w, // Low 16 bits or r15
133 x86_64_with_base::lldb_r8l, // Low 8 bits or r8
134 x86_64_with_base::lldb_r9l, // Low 8 bits or r9
135 x86_64_with_base::lldb_r10l, // Low 8 bits or r10
136 x86_64_with_base::lldb_r11l, // Low 8 bits or r11
137 x86_64_with_base::lldb_r12l, // Low 8 bits or r12
138 x86_64_with_base::lldb_r13l, // Low 8 bits or r13
139 x86_64_with_base::lldb_r14l, // Low 8 bits or r14
140 x86_64_with_base::lldb_r15l, // Low 8 bits or r15
141 LLDB_INVALID_REGNUM // Register sets must be terminated with
142 // LLDB_INVALID_REGNUM.
143};
144static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) -
145 1 ==
147 "g_gpr_regnums_x86_64 has wrong number of register infos");
148
149static const uint32_t g_lldb_regnums_x86_64[] = {
172 LLDB_INVALID_REGNUM // Register sets must be terminated with
173 // LLDB_INVALID_REGNUM.
174};
175static_assert(
176 (sizeof(g_lldb_regnums_x86_64) / sizeof(g_lldb_regnums_x86_64[0])) - 1 ==
178 "g_lldb_regnums_x86_64 has wrong number of register infos");
179
180static const uint32_t g_avx_regnums_x86_64[] = {
189 LLDB_INVALID_REGNUM // Register sets must be terminated with
190 // LLDB_INVALID_REGNUM.
191};
192static_assert((sizeof(g_avx_regnums_x86_64) / sizeof(g_avx_regnums_x86_64[0])) -
193 1 ==
195 "g_avx_regnums_x86_64 has wrong number of register infos");
196
197static const RegisterSet g_reg_sets_i386[] = {
198 {"General Purpose Registers", "gpr", k_num_gpr_registers_i386,
200 {"Floating Point Registers", "fpu", k_num_fpr_registers_i386,
202 {"Advanced Vector Extensions", "avx", k_num_avx_registers_i386,
204
206 {"General Purpose Registers", "gpr", x86_64_with_base::k_num_gpr_registers,
208 {"Floating Point Registers", "fpu", x86_64_with_base::k_num_fpr_registers,
210 {"Advanced Vector Extensions", "avx", x86_64_with_base::k_num_avx_registers,
212
214 Thread &thread, RegisterInfoInterface *register_info,
215 const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
216 : RegisterContextCorePOSIX_x86_64(thread, register_info, gpregset, notes) {}
217
219 if (IsRegisterSetAvailable(set)) {
220 switch (m_register_info_up->GetTargetArchitecture().GetMachine()) {
221 case llvm::Triple::x86:
222 return &g_reg_sets_i386[set];
223 case llvm::Triple::x86_64:
224 return &g_reg_sets_x86_64[set];
225 default:
226 assert(false && "Unhandled target architecture.");
227 return nullptr;
228 }
229 }
230 return nullptr;
231}
232
234 return GetRegInfoShared(
235 m_register_info_up->GetTargetArchitecture().GetMachine(),
236 /*with_base=*/true);
237}
const uint32_t g_lldb_regnums_i386[]
static const RegisterSet g_reg_sets_i386[]
static const uint32_t g_gpr_regnums_x86_64[]
static const uint32_t g_lldb_regnums_x86_64[]
const uint32_t g_gpr_regnums_i386[]
static const RegisterSet g_reg_sets_x86_64[]
const uint32_t g_avx_regnums_i386[]
static const uint32_t g_avx_regnums_x86_64[]
RegisterContextLinuxCore_x86_64(lldb_private::Thread &thread, lldb_private::RegisterInfoInterface *register_info, const lldb_private::DataExtractor &gpregset, llvm::ArrayRef< lldb_private::CoreNote > notes)
const lldb_private::RegisterSet * GetRegisterSet(size_t set) override
lldb_private::RegInfo & GetRegInfo() override
std::unique_ptr< lldb_private::RegisterInfoInterface > m_register_info_up
virtual bool IsRegisterSetAvailable(size_t set_index)
An data extractor class.
Definition: DataExtractor.h:48
RegisterInfo interface to patch RegisterInfo structure for archs.
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:87
A class that represents a running process on the host machine.
RegInfo & GetRegInfoShared(llvm::Triple::ArchType arch_type, bool with_base)
Registers are grouped into register sets.