1 //===-- RegisterContextNetBSD_x86_64.cpp ------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "RegisterContextNetBSD_x86_64.h"
11 #include "RegisterContextPOSIX_x86.h"
12 #include "llvm/ADT/Triple.h"
13 #include "llvm/Support/Compiler.h"
17 using namespace lldb_private;
20 // src/sys/arch/amd64/include/frame_regs.h
32 uint64_t r14; /* 10 */
33 uint64_t r15; /* 11 */
34 uint64_t rbp; /* 12 */
35 uint64_t rbx; /* 13 */
36 uint64_t rax; /* 14 */
41 uint64_t trapno; /* 19 */
42 uint64_t err; /* 20 */
43 uint64_t rip; /* 21 */
45 uint64_t rflags; /* 23 */
46 uint64_t rsp; /* 24 */
51 uint64_t dr[16]; /* debug registers */
52 /* Index 0-3: debug address registers */
53 /* Index 4-5: reserved */
54 /* Index 6: debug status */
55 /* Index 7: debug control */
56 /* Index 8-15: reserved */
60 * src/sys/arch/amd64/include/mcontext.h
63 * __gregset_t __gregs;
64 * __greg_t _mc_tlsbase;
65 * __fpregset_t __fpregs;
76 #define DR_OFFSET(reg_index) \
77 (LLVM_EXTENSION offsetof(UserArea, dbg) + \
78 LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
81 //---------------------------------------------------------------------------
82 // Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
84 //---------------------------------------------------------------------------
85 #define DECLARE_REGISTER_INFOS_X86_64_STRUCT
86 #include "RegisterInfos_x86_64.h"
87 #undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
89 static const RegisterInfo *
90 PrivateGetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
91 switch (target_arch.GetMachine()) {
92 case llvm::Triple::x86_64:
93 return g_register_infos_x86_64;
95 assert(false && "Unhandled target architecture.");
101 PrivateGetRegisterCount(const lldb_private::ArchSpec &target_arch) {
102 switch (target_arch.GetMachine()) {
103 case llvm::Triple::x86_64:
104 return static_cast<uint32_t>(sizeof(g_register_infos_x86_64) /
105 sizeof(g_register_infos_x86_64[0]));
107 assert(false && "Unhandled target architecture.");
112 RegisterContextNetBSD_x86_64::RegisterContextNetBSD_x86_64(
113 const ArchSpec &target_arch)
114 : lldb_private::RegisterInfoInterface(target_arch),
115 m_register_info_p(PrivateGetRegisterInfoPtr(target_arch)),
116 m_register_count(PrivateGetRegisterCount(target_arch)) {}
118 size_t RegisterContextNetBSD_x86_64::GetGPRSize() const { return sizeof(GPR); }
120 const RegisterInfo *RegisterContextNetBSD_x86_64::GetRegisterInfo() const {
121 return m_register_info_p;
124 uint32_t RegisterContextNetBSD_x86_64::GetRegisterCount() const {
125 return m_register_count;