1 //===-- RegisterContextNetBSD_x86_64.cpp ------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "RegisterContextNetBSD_x86_64.h"
10 #include "RegisterContextPOSIX_x86.h"
11 #include "llvm/ADT/Triple.h"
12 #include "llvm/Support/Compiler.h"
16 using namespace lldb_private;
19 // src/sys/arch/amd64/include/frame_regs.h
31 uint64_t r14; /* 10 */
32 uint64_t r15; /* 11 */
33 uint64_t rbp; /* 12 */
34 uint64_t rbx; /* 13 */
35 uint64_t rax; /* 14 */
40 uint64_t trapno; /* 19 */
41 uint64_t err; /* 20 */
42 uint64_t rip; /* 21 */
44 uint64_t rflags; /* 23 */
45 uint64_t rsp; /* 24 */
50 uint64_t dr[16]; /* debug registers */
51 /* Index 0-3: debug address registers */
52 /* Index 4-5: reserved */
53 /* Index 6: debug status */
54 /* Index 7: debug control */
55 /* Index 8-15: reserved */
59 * src/sys/arch/amd64/include/mcontext.h
62 * __gregset_t __gregs;
63 * __greg_t _mc_tlsbase;
64 * __fpregset_t __fpregs;
75 #define DR_OFFSET(reg_index) \
76 (LLVM_EXTENSION offsetof(UserArea, dbg) + \
77 LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
80 // Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
82 #define DECLARE_REGISTER_INFOS_X86_64_STRUCT
83 #include "RegisterInfos_x86_64.h"
84 #undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
86 static const RegisterInfo *
87 PrivateGetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
88 switch (target_arch.GetMachine()) {
89 case llvm::Triple::x86_64:
90 return g_register_infos_x86_64;
92 assert(false && "Unhandled target architecture.");
98 PrivateGetRegisterCount(const lldb_private::ArchSpec &target_arch) {
99 switch (target_arch.GetMachine()) {
100 case llvm::Triple::x86_64:
101 return static_cast<uint32_t>(sizeof(g_register_infos_x86_64) /
102 sizeof(g_register_infos_x86_64[0]));
104 assert(false && "Unhandled target architecture.");
109 RegisterContextNetBSD_x86_64::RegisterContextNetBSD_x86_64(
110 const ArchSpec &target_arch)
111 : lldb_private::RegisterInfoInterface(target_arch),
112 m_register_info_p(PrivateGetRegisterInfoPtr(target_arch)),
113 m_register_count(PrivateGetRegisterCount(target_arch)) {}
115 size_t RegisterContextNetBSD_x86_64::GetGPRSize() const { return sizeof(GPR); }
117 const RegisterInfo *RegisterContextNetBSD_x86_64::GetRegisterInfo() const {
118 return m_register_info_p;
121 uint32_t RegisterContextNetBSD_x86_64::GetRegisterCount() const {
122 return m_register_count;