1*0eae32dcSDimitry Andric //===-- RegisterContextFreeBSDKernel_x86_64.cpp ---------------------------===//
2*0eae32dcSDimitry Andric //
3*0eae32dcSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0eae32dcSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0eae32dcSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0eae32dcSDimitry Andric //
7*0eae32dcSDimitry Andric //===----------------------------------------------------------------------===//
8*0eae32dcSDimitry Andric 
9*0eae32dcSDimitry Andric #include "RegisterContextFreeBSDKernel_x86_64.h"
10*0eae32dcSDimitry Andric 
11*0eae32dcSDimitry Andric #include "lldb/Target/Process.h"
12*0eae32dcSDimitry Andric #include "lldb/Target/Thread.h"
13*0eae32dcSDimitry Andric #include "lldb/Utility/RegisterValue.h"
14*0eae32dcSDimitry Andric #include "llvm/Support/Endian.h"
15*0eae32dcSDimitry Andric 
16*0eae32dcSDimitry Andric using namespace lldb;
17*0eae32dcSDimitry Andric using namespace lldb_private;
18*0eae32dcSDimitry Andric 
RegisterContextFreeBSDKernel_x86_64(Thread & thread,RegisterInfoInterface * register_info,lldb::addr_t pcb_addr)19*0eae32dcSDimitry Andric RegisterContextFreeBSDKernel_x86_64::RegisterContextFreeBSDKernel_x86_64(
20*0eae32dcSDimitry Andric     Thread &thread, RegisterInfoInterface *register_info, lldb::addr_t pcb_addr)
21*0eae32dcSDimitry Andric     : RegisterContextPOSIX_x86(thread, 0, register_info), m_pcb_addr(pcb_addr) {
22*0eae32dcSDimitry Andric }
23*0eae32dcSDimitry Andric 
ReadGPR()24*0eae32dcSDimitry Andric bool RegisterContextFreeBSDKernel_x86_64::ReadGPR() { return true; }
25*0eae32dcSDimitry Andric 
ReadFPR()26*0eae32dcSDimitry Andric bool RegisterContextFreeBSDKernel_x86_64::ReadFPR() { return true; }
27*0eae32dcSDimitry Andric 
WriteGPR()28*0eae32dcSDimitry Andric bool RegisterContextFreeBSDKernel_x86_64::WriteGPR() {
29*0eae32dcSDimitry Andric   assert(0);
30*0eae32dcSDimitry Andric   return false;
31*0eae32dcSDimitry Andric }
32*0eae32dcSDimitry Andric 
WriteFPR()33*0eae32dcSDimitry Andric bool RegisterContextFreeBSDKernel_x86_64::WriteFPR() {
34*0eae32dcSDimitry Andric   assert(0);
35*0eae32dcSDimitry Andric   return false;
36*0eae32dcSDimitry Andric }
37*0eae32dcSDimitry Andric 
ReadRegister(const RegisterInfo * reg_info,RegisterValue & value)38*0eae32dcSDimitry Andric bool RegisterContextFreeBSDKernel_x86_64::ReadRegister(
39*0eae32dcSDimitry Andric     const RegisterInfo *reg_info, RegisterValue &value) {
40*0eae32dcSDimitry Andric   if (m_pcb_addr == LLDB_INVALID_ADDRESS)
41*0eae32dcSDimitry Andric     return false;
42*0eae32dcSDimitry Andric 
43*0eae32dcSDimitry Andric   struct {
44*0eae32dcSDimitry Andric     llvm::support::ulittle64_t r15;
45*0eae32dcSDimitry Andric     llvm::support::ulittle64_t r14;
46*0eae32dcSDimitry Andric     llvm::support::ulittle64_t r13;
47*0eae32dcSDimitry Andric     llvm::support::ulittle64_t r12;
48*0eae32dcSDimitry Andric     llvm::support::ulittle64_t rbp;
49*0eae32dcSDimitry Andric     llvm::support::ulittle64_t rsp;
50*0eae32dcSDimitry Andric     llvm::support::ulittle64_t rbx;
51*0eae32dcSDimitry Andric     llvm::support::ulittle64_t rip;
52*0eae32dcSDimitry Andric   } pcb;
53*0eae32dcSDimitry Andric 
54*0eae32dcSDimitry Andric   Status error;
55*0eae32dcSDimitry Andric   size_t rd =
56*0eae32dcSDimitry Andric       m_thread.GetProcess()->ReadMemory(m_pcb_addr, &pcb, sizeof(pcb), error);
57*0eae32dcSDimitry Andric   if (rd != sizeof(pcb))
58*0eae32dcSDimitry Andric     return false;
59*0eae32dcSDimitry Andric 
60*0eae32dcSDimitry Andric   uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
61*0eae32dcSDimitry Andric   switch (reg) {
62*0eae32dcSDimitry Andric #define REG(x)                                                                 \
63*0eae32dcSDimitry Andric   case lldb_##x##_x86_64:                                                      \
64*0eae32dcSDimitry Andric     value = pcb.x;                                                             \
65*0eae32dcSDimitry Andric     break;
66*0eae32dcSDimitry Andric 
67*0eae32dcSDimitry Andric     REG(r15);
68*0eae32dcSDimitry Andric     REG(r14);
69*0eae32dcSDimitry Andric     REG(r13);
70*0eae32dcSDimitry Andric     REG(r12);
71*0eae32dcSDimitry Andric     REG(rbp);
72*0eae32dcSDimitry Andric     REG(rsp);
73*0eae32dcSDimitry Andric     REG(rbx);
74*0eae32dcSDimitry Andric     REG(rip);
75*0eae32dcSDimitry Andric 
76*0eae32dcSDimitry Andric #undef REG
77*0eae32dcSDimitry Andric 
78*0eae32dcSDimitry Andric   default:
79*0eae32dcSDimitry Andric     return false;
80*0eae32dcSDimitry Andric   }
81*0eae32dcSDimitry Andric 
82*0eae32dcSDimitry Andric   return true;
83*0eae32dcSDimitry Andric }
84*0eae32dcSDimitry Andric 
WriteRegister(const RegisterInfo * reg_info,const RegisterValue & value)85*0eae32dcSDimitry Andric bool RegisterContextFreeBSDKernel_x86_64::WriteRegister(
86*0eae32dcSDimitry Andric     const RegisterInfo *reg_info, const RegisterValue &value) {
87*0eae32dcSDimitry Andric   return false;
88*0eae32dcSDimitry Andric }
89