LLDB  mainline
RegisterContextOpenBSD_x86_64.cpp
Go to the documentation of this file.
1 //===-- RegisterContextOpenBSD_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 
11 #include <vector>
12 
13 using namespace lldb_private;
14 using namespace lldb;
15 
16 // /usr/include/machine/reg.h
17 typedef struct _GPR {
18  uint64_t rdi;
19  uint64_t rsi;
20  uint64_t rdx;
21  uint64_t rcx;
22  uint64_t r8;
23  uint64_t r9;
24  uint64_t r10;
25  uint64_t r11;
26  uint64_t r12;
27  uint64_t r13;
28  uint64_t r14;
29  uint64_t r15;
30  uint64_t rbp;
31  uint64_t rbx;
32  uint64_t rax;
33  uint64_t rsp;
34  uint64_t rip;
35  uint64_t rflags;
36  uint64_t cs;
37  uint64_t ss;
38  uint64_t ds;
39  uint64_t es;
40  uint64_t fs;
41  uint64_t gs;
42 } GPR;
43 
44 struct DBG {
45  uint64_t dr[16]; /* debug registers */
46  /* Index 0-3: debug address registers */
47  /* Index 4-5: reserved */
48  /* Index 6: debug status */
49  /* Index 7: debug control */
50  /* Index 8-15: reserved */
51 };
52 
53 struct UserArea {
54  GPR gpr;
55  FPR fpr;
56  DBG dbg;
57 };
58 
59 #define DR_OFFSET(reg_index) (LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
60 
61 // Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
62 // structure.
63 #define DECLARE_REGISTER_INFOS_X86_64_STRUCT
64 #include "RegisterInfos_x86_64.h"
65 #undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
66 
67 static const RegisterInfo *
69  switch (target_arch.GetMachine()) {
70  case llvm::Triple::x86_64:
71  return g_register_infos_x86_64;
72  default:
73  assert(false && "Unhandled target architecture.");
74  return nullptr;
75  }
76 }
77 
78 static uint32_t
80  switch (target_arch.GetMachine()) {
81  case llvm::Triple::x86_64:
82  return static_cast<uint32_t>(sizeof(g_register_infos_x86_64) /
83  sizeof(g_register_infos_x86_64[0]));
84  default:
85  assert(false && "Unhandled target architecture.");
86  return 0;
87  }
88 }
89 
91  const ArchSpec &target_arch)
92  : lldb_private::RegisterInfoInterface(target_arch),
93  m_register_info_p(PrivateGetRegisterInfoPtr(target_arch)),
94  m_register_count(PrivateGetRegisterCount(target_arch)) {}
95 
96 size_t RegisterContextOpenBSD_x86_64::GetGPRSize() const { return sizeof(GPR); }
97 
99  return m_register_info_p;
100 }
101 
103  return m_register_count;
104 }
DBG
Definition: RegisterContextFreeBSD_i386.cpp:38
r12
@ r12
Definition: CompactUnwindInfo.cpp:705
lldb_private::ArchSpec
Definition: ArchSpec.h:33
rax
@ rax
Definition: CompactUnwindInfo.cpp:693
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:667
r10
@ r10
Definition: CompactUnwindInfo.cpp:703
lldb_private::RegisterInfoInterface
Definition: RegisterInfoInterface.h:21
RegisterInfos_x86_64.h
rdi
@ rdi
Definition: CompactUnwindInfo.cpp:698
RegisterContextOpenBSD_x86_64.h
UserArea
Definition: RegisterContext_mips.h:368
RegisterContextOpenBSD_x86_64::GetRegisterCount
uint32_t GetRegisterCount() const override
Definition: RegisterContextOpenBSD_x86_64.cpp:102
PrivateGetRegisterCount
static uint32_t PrivateGetRegisterCount(const lldb_private::ArchSpec &target_arch)
Definition: RegisterContextOpenBSD_x86_64.cpp:79
RegisterContextPOSIX_x86.h
r8
@ r8
Definition: CompactUnwindInfo.cpp:701
RegisterContextOpenBSD_x86_64::RegisterContextOpenBSD_x86_64
RegisterContextOpenBSD_x86_64(const lldb_private::ArchSpec &target_arch)
Definition: RegisterContextOpenBSD_x86_64.cpp:90
rcx
@ rcx
Definition: CompactUnwindInfo.cpp:695
GPR
struct _GPR GPR
rbx
@ rbx
Definition: CompactUnwindInfo.cpp:696
RegisterContextOpenBSD_x86_64::m_register_count
const uint32_t m_register_count
Definition: RegisterContextOpenBSD_x86_64.h:27
r11
@ r11
Definition: CompactUnwindInfo.cpp:704
r14
@ r14
Definition: CompactUnwindInfo.cpp:707
lldb_private::FPR
Definition: RegisterContext_x86.h:363
GPR
Definition: RegisterContextFreeBSD_i386.cpp:16
rdx
@ rdx
Definition: CompactUnwindInfo.cpp:694
uint32_t
RegisterContextOpenBSD_x86_64::m_register_info_p
const lldb_private::RegisterInfo * m_register_info_p
Definition: RegisterContextOpenBSD_x86_64.h:26
rip
@ rip
Definition: CompactUnwindInfo.cpp:709
PrivateGetRegisterInfoPtr
static const RegisterInfo * PrivateGetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch)
Definition: RegisterContextOpenBSD_x86_64.cpp:68
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
r15
@ r15
Definition: CompactUnwindInfo.cpp:708
RegisterContextOpenBSD_x86_64::GetRegisterInfo
const lldb_private::RegisterInfo * GetRegisterInfo() const override
Definition: RegisterContextOpenBSD_x86_64.cpp:98
RegisterContextOpenBSD_x86_64::GetGPRSize
size_t GetGPRSize() const override
Definition: RegisterContextOpenBSD_x86_64.cpp:96
rsi
@ rsi
Definition: CompactUnwindInfo.cpp:697
r9
@ r9
Definition: CompactUnwindInfo.cpp:702
lldb
Definition: SBAddress.h:15
rbp
@ rbp
Definition: CompactUnwindInfo.cpp:699
rsp
@ rsp
Definition: CompactUnwindInfo.cpp:700
r13
@ r13
Definition: CompactUnwindInfo.cpp:706