LLDB  mainline
RegisterContextFreeBSDKernel_arm64.cpp
Go to the documentation of this file.
1 //===-- RegisterContextFreeBSDKernel_arm64.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 
12 #include "lldb/Target/Process.h"
13 #include "lldb/Target/Thread.h"
15 #include "llvm/Support/Endian.h"
16 
17 using namespace lldb;
18 using namespace lldb_private;
19 
21  Thread &thread, std::unique_ptr<RegisterInfoPOSIX_arm64> register_info_up,
22  lldb::addr_t pcb_addr)
23  : RegisterContextPOSIX_arm64(thread, std::move(register_info_up)),
24  m_pcb_addr(pcb_addr) {}
25 
27 
29 
31  assert(0);
32  return false;
33 }
34 
36  assert(0);
37  return false;
38 }
39 
41  const RegisterInfo *reg_info, RegisterValue &value) {
43  return false;
44 
45  struct {
46  llvm::support::ulittle64_t x[30];
47  llvm::support::ulittle64_t lr;
48  llvm::support::ulittle64_t _reserved;
49  llvm::support::ulittle64_t sp;
50  } pcb;
51 
52  Status error;
53  size_t rd =
54  m_thread.GetProcess()->ReadMemory(m_pcb_addr, &pcb, sizeof(pcb), error);
55  if (rd != sizeof(pcb))
56  return false;
57 
58  uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
59  switch (reg) {
60  case gpr_x0_arm64:
61  case gpr_x1_arm64:
62  case gpr_x2_arm64:
63  case gpr_x3_arm64:
64  case gpr_x4_arm64:
65  case gpr_x5_arm64:
66  case gpr_x6_arm64:
67  case gpr_x7_arm64:
68  case gpr_x8_arm64:
69  case gpr_x9_arm64:
70  case gpr_x10_arm64:
71  case gpr_x11_arm64:
72  case gpr_x12_arm64:
73  case gpr_x13_arm64:
74  case gpr_x14_arm64:
75  case gpr_x15_arm64:
76  case gpr_x16_arm64:
77  case gpr_x17_arm64:
78  case gpr_x18_arm64:
79  case gpr_x19_arm64:
80  case gpr_x20_arm64:
81  case gpr_x21_arm64:
82  case gpr_x22_arm64:
83  case gpr_x23_arm64:
84  case gpr_x24_arm64:
85  case gpr_x25_arm64:
86  case gpr_x26_arm64:
87  case gpr_x27_arm64:
88  case gpr_x28_arm64:
89  case gpr_fp_arm64:
90  static_assert(gpr_fp_arm64 - gpr_x0_arm64 == 29,
91  "nonconsecutive arm64 register numbers");
92  value = pcb.x[reg - gpr_x0_arm64];
93  break;
94  case gpr_sp_arm64:
95  value = pcb.sp;
96  break;
97  case gpr_pc_arm64:
98  // The pc of crashing thread is stored in lr.
99  value = pcb.lr;
100  break;
101  default:
102  return false;
103  }
104  return true;
105 }
106 
108  const RegisterInfo *reg_info, const RegisterValue &value) {
109  return false;
110 }
lldb_private::gpr_x21_arm64
@ gpr_x21_arm64
Definition: lldb-arm64-register-enums.h:39
RegisterContextFreeBSDKernel_arm64::m_pcb_addr
lldb::addr_t m_pcb_addr
Definition: RegisterContextFreeBSDKernel_arm64.h:38
lldb_private::gpr_x10_arm64
@ gpr_x10_arm64
Definition: lldb-arm64-register-enums.h:28
lldb_private::gpr_x13_arm64
@ gpr_x13_arm64
Definition: lldb-arm64-register-enums.h:31
lldb_private::gpr_x9_arm64
@ gpr_x9_arm64
Definition: lldb-arm64-register-enums.h:27
lldb_private::gpr_x15_arm64
@ gpr_x15_arm64
Definition: lldb-arm64-register-enums.h:33
lldb_private::gpr_x17_arm64
@ gpr_x17_arm64
Definition: lldb-arm64-register-enums.h:35
lldb_private::gpr_x28_arm64
@ gpr_x28_arm64
Definition: lldb-arm64-register-enums.h:46
lldb_private::gpr_x25_arm64
@ gpr_x25_arm64
Definition: lldb-arm64-register-enums.h:43
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::gpr_x19_arm64
@ gpr_x19_arm64
Definition: lldb-arm64-register-enums.h:37
lldb_private::gpr_x20_arm64
@ gpr_x20_arm64
Definition: lldb-arm64-register-enums.h:38
RegisterContextFreeBSDKernel_arm64::ReadGPR
bool ReadGPR() override
Definition: RegisterContextFreeBSDKernel_arm64.cpp:26
arm64_dwarf::lr
@ lr
Definition: ARM64_DWARF_Registers.h:49
RegisterValue.h
RegisterContextFreeBSDKernel_arm64::ReadRegister
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
Definition: RegisterContextFreeBSDKernel_arm64.cpp:40
lldb_private::gpr_x7_arm64
@ gpr_x7_arm64
Definition: lldb-arm64-register-enums.h:25
RegisterContextFreeBSDKernel_arm64::WriteGPR
bool WriteGPR() override
Definition: RegisterContextFreeBSDKernel_arm64.cpp:30
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::gpr_x5_arm64
@ gpr_x5_arm64
Definition: lldb-arm64-register-enums.h:23
lldb_private::gpr_x12_arm64
@ gpr_x12_arm64
Definition: lldb-arm64-register-enums.h:30
lldb_private::gpr_x18_arm64
@ gpr_x18_arm64
Definition: lldb-arm64-register-enums.h:36
lldb_private::gpr_x14_arm64
@ gpr_x14_arm64
Definition: lldb-arm64-register-enums.h:32
Process.h
RegisterContextFreeBSDKernel_arm64::RegisterContextFreeBSDKernel_arm64
RegisterContextFreeBSDKernel_arm64(lldb_private::Thread &thread, std::unique_ptr< RegisterInfoPOSIX_arm64 > register_info_up, lldb::addr_t pcb_addr)
Definition: RegisterContextFreeBSDKernel_arm64.cpp:20
lldb_private::Thread::GetProcess
lldb::ProcessSP GetProcess() const
Definition: Thread.h:153
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
RegisterContextFreeBSDKernel_arm64::WriteRegister
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
Definition: RegisterContextFreeBSDKernel_arm64.cpp:107
lldb_private::RegisterContext::m_thread
Thread & m_thread
Definition: RegisterContext.h:234
lldb::eRegisterKindLLDB
@ eRegisterKindLLDB
lldb's internal register numbers
Definition: lldb-enumerations.h:234
lldb_private::Thread
Definition: Thread.h:61
RegisterContextFreeBSDKernel_arm64.h
RegisterContextFreeBSDKernel_arm64::WriteFPR
bool WriteFPR() override
Definition: RegisterContextFreeBSDKernel_arm64.cpp:35
lldb_private::gpr_x1_arm64
@ gpr_x1_arm64
Definition: lldb-arm64-register-enums.h:19
sp
@ sp
Definition: CompactUnwindInfo.cpp:1250
lldb_private::gpr_x0_arm64
@ gpr_x0_arm64
Definition: lldb-arm64-register-enums.h:18
Thread.h
lldb_private::gpr_x16_arm64
@ gpr_x16_arm64
Definition: lldb-arm64-register-enums.h:34
lldb_private::gpr_x26_arm64
@ gpr_x26_arm64
Definition: lldb-arm64-register-enums.h:44
lldb_private::gpr_x8_arm64
@ gpr_x8_arm64
Definition: lldb-arm64-register-enums.h:26
lldb_private::gpr_pc_arm64
@ gpr_pc_arm64
Definition: lldb-arm64-register-enums.h:50
lldb_private::Status
Definition: Status.h:44
uint32_t
lldb_private::gpr_x2_arm64
@ gpr_x2_arm64
Definition: lldb-arm64-register-enums.h:20
lldb_private::gpr_x24_arm64
@ gpr_x24_arm64
Definition: lldb-arm64-register-enums.h:42
lldb_private::gpr_x27_arm64
@ gpr_x27_arm64
Definition: lldb-arm64-register-enums.h:45
lldb_private::gpr_sp_arm64
@ gpr_sp_arm64
Definition: lldb-arm64-register-enums.h:49
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::gpr_x11_arm64
@ gpr_x11_arm64
Definition: lldb-arm64-register-enums.h:29
lldb_private::gpr_x22_arm64
@ gpr_x22_arm64
Definition: lldb-arm64-register-enums.h:40
lldb_private::gpr_x4_arm64
@ gpr_x4_arm64
Definition: lldb-arm64-register-enums.h:22
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::gpr_x6_arm64
@ gpr_x6_arm64
Definition: lldb-arm64-register-enums.h:24
lldb_private::gpr_fp_arm64
@ gpr_fp_arm64
Definition: lldb-arm64-register-enums.h:47
lldb_private::gpr_x23_arm64
@ gpr_x23_arm64
Definition: lldb-arm64-register-enums.h:41
lldb
Definition: SBAddress.h:15
RegisterContextFreeBSDKernel_arm64::ReadFPR
bool ReadFPR() override
Definition: RegisterContextFreeBSDKernel_arm64.cpp:28
RegisterContextPOSIX_arm64
Definition: RegisterContextPOSIX_arm64.h:17
lldb_private::gpr_x3_arm64
@ gpr_x3_arm64
Definition: lldb-arm64-register-enums.h:21
lldb-arm64-register-enums.h