LLDB  mainline
RegisterContextDummy.cpp
Go to the documentation of this file.
1 //===-- RegisterContextDummy.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 
9 #include "lldb/Core/Address.h"
10 #include "lldb/Core/AddressRange.h"
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/Value.h"
15 #include "lldb/Symbol/Function.h"
16 #include "lldb/Symbol/ObjectFile.h"
17 #include "lldb/Symbol/Symbol.h"
19 #include "lldb/Target/ABI.h"
22 #include "lldb/Target/Process.h"
23 #include "lldb/Target/StackFrame.h"
24 #include "lldb/Target/Target.h"
25 #include "lldb/Target/Thread.h"
27 #include "lldb/Utility/Log.h"
29 #include "lldb/lldb-private.h"
30 
31 #include "RegisterContextDummy.h"
32 
33 using namespace lldb;
34 using namespace lldb_private;
35 
36 RegisterContextDummy::RegisterContextDummy(Thread &thread,
37  uint32_t concrete_frame_idx,
38  uint32_t address_byte_size)
39  : RegisterContext(thread, concrete_frame_idx) {
40  m_reg_set0.name = "General Purpose Registers";
41  m_reg_set0.short_name = "GPR";
42  m_reg_set0.num_registers = 1;
43  m_reg_set0.registers = new uint32_t(0);
44 
45  m_pc_reg_info.name = "pc";
46  m_pc_reg_info.alt_name = "pc";
47  m_pc_reg_info.byte_offset = 0;
48  m_pc_reg_info.byte_size = address_byte_size;
49  m_pc_reg_info.encoding = eEncodingUint;
51  m_pc_reg_info.invalidate_regs = nullptr;
52  m_pc_reg_info.value_regs = nullptr;
58 }
59 
61  delete m_reg_set0.registers;
62  delete m_pc_reg_info.invalidate_regs;
63  delete m_pc_reg_info.value_regs;
64 }
65 
67 
69 
70 const lldb_private::RegisterInfo *
72  if (reg)
73  return nullptr;
74  return &m_pc_reg_info;
75 }
76 
78 
79 const lldb_private::RegisterSet *
81  if (reg_set)
82  return nullptr;
83  return &m_reg_set0;
84 }
85 
87  const lldb_private::RegisterInfo *reg_info,
89  if (!reg_info)
90  return false;
91  uint32_t reg_number = reg_info->kinds[eRegisterKindGeneric];
92  if (reg_number == LLDB_REGNUM_GENERIC_PC) {
93  value.SetUInt(LLDB_INVALID_ADDRESS, reg_info->byte_size);
94  return true;
95  }
96  return false;
97 }
98 
100  const lldb_private::RegisterInfo *reg_info,
101  const lldb_private::RegisterValue &value) {
102  return false;
103 }
104 
105 bool RegisterContextDummy::ReadAllRegisterValues(lldb::DataBufferSP &data_sp) {
106  return false;
107 }
108 
110  const lldb::DataBufferSP &data_sp) {
111  return false;
112 }
113 
115  lldb::RegisterKind kind, uint32_t num) {
116  if (kind == eRegisterKindGeneric && num == LLDB_REGNUM_GENERIC_PC)
117  return 0;
118  return LLDB_INVALID_REGNUM;
119 }
lldb::eFormatPointer
@ eFormatPointer
Definition: lldb-enumerations.h:178
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:91
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb::eRegisterKindDWARF
@ eRegisterKindDWARF
the register numbers seen DWARF
Definition: lldb-enumerations.h:229
lldb::eRegisterKindGeneric
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
Definition: lldb-enumerations.h:230
lldb_private::RegisterContextDummy::ReadRegister
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
Definition: RegisterContextDummy.cpp:86
Module.h
lldb_private::RegisterContextDummy::WriteRegister
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
Definition: RegisterContextDummy.cpp:99
RegisterValue.h
StackFrame.h
lldb_private::RegisterContextDummy::GetRegisterSet
const lldb_private::RegisterSet * GetRegisterSet(size_t reg_set) override
Definition: RegisterContextDummy.cpp:80
ABI.h
Process.h
lldb_private::RegisterContextDummy::InvalidateAllRegisters
void InvalidateAllRegisters() override
Definition: RegisterContextDummy.cpp:66
lldb_private::RegisterContextDummy::~RegisterContextDummy
~RegisterContextDummy() override
Definition: RegisterContextDummy.cpp:60
Target.h
lldb::eRegisterKindEHFrame
@ eRegisterKindEHFrame
the register numbers seen in eh_frame
Definition: lldb-enumerations.h:228
lldb::eRegisterKindLLDB
@ eRegisterKindLLDB
lldb's internal register numbers
Definition: lldb-enumerations.h:234
Log.h
lldb::eRegisterKindProcessPlugin
@ eRegisterKindProcessPlugin
num used by the process plugin - e.g.
Definition: lldb-enumerations.h:232
lldb_private::Thread
Definition: Thread.h:60
lldb::eEncodingUint
@ eEncodingUint
unsigned integer
Definition: lldb-enumerations.h:148
RegisterContextDummy.h
lldb_private::RegisterContextDummy::GetRegisterCount
size_t GetRegisterCount() override
Definition: RegisterContextDummy.cpp:68
Thread.h
Address.h
lldb_private::RegisterContext
Definition: RegisterContext.h:17
ObjectFile.h
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
lldb-private.h
Symbol.h
FuncUnwinders.h
lldb_private::RegisterContextDummy::m_pc_reg_info
lldb_private::RegisterInfo m_pc_reg_info
Definition: RegisterContextDummy.h:57
lldb_private::RegisterContextDummy::GetRegisterInfoAtIndex
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
Definition: RegisterContextDummy.cpp:71
uint32_t
lldb_private::RegisterValue::SetUInt
bool SetUInt(uint64_t uint, uint32_t byte_size)
Definition: RegisterValue.cpp:734
lldb_private::RegisterContextDummy::ReadAllRegisterValues
bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override
Definition: RegisterContextDummy.cpp:105
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
Function.h
DWARFExpression.h
SymbolContext.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::RegisterContextDummy::WriteAllRegisterValues
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
Definition: RegisterContextDummy.cpp:109
LLDB_REGNUM_GENERIC_PC
#define LLDB_REGNUM_GENERIC_PC
Definition: lldb-defines.h:63
lldb_private::RegisterContextDummy::ConvertRegisterKindToRegisterNumber
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override
Convert from a given register numbering scheme to the lldb register numbering scheme.
Definition: RegisterContextDummy.cpp:114
lldb_private::RegisterContextDummy::m_reg_set0
lldb_private::RegisterSet m_reg_set0
Definition: RegisterContextDummy.h:56
DynamicLoader.h
AddressRange.h
lldb
Definition: SBAddress.h:15
Value.h
lldb_private::RegisterContextDummy::GetRegisterSetCount
size_t GetRegisterSetCount() override
Definition: RegisterContextDummy.cpp:77
ExecutionContext.h
DataBufferHeap.h