LLDB  mainline
RegisterContextHistory.cpp
Go to the documentation of this file.
1 //===-- RegisterContextHistory.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 "RegisterContextHistory.h"
32 
33 using namespace lldb;
34 using namespace lldb_private;
35 
36 RegisterContextHistory::RegisterContextHistory(Thread &thread,
37  uint32_t concrete_frame_idx,
38  uint32_t address_byte_size,
39  addr_t pc_value)
40  : RegisterContext(thread, concrete_frame_idx), m_pc_value(pc_value) {
41  m_reg_set0.name = "General Purpose Registers";
42  m_reg_set0.short_name = "GPR";
43  m_reg_set0.num_registers = 1;
44  m_reg_set0.registers = new uint32_t(0);
45 
46  m_pc_reg_info.name = "pc";
47  m_pc_reg_info.alt_name = "pc";
48  m_pc_reg_info.byte_offset = 0;
49  m_pc_reg_info.byte_size = address_byte_size;
50  m_pc_reg_info.encoding = eEncodingUint;
52  m_pc_reg_info.invalidate_regs = nullptr;
53  m_pc_reg_info.value_regs = nullptr;
59 }
60 
62  delete m_reg_set0.registers;
63  delete m_pc_reg_info.invalidate_regs;
64  delete m_pc_reg_info.value_regs;
65 }
66 
68 
70 
71 const lldb_private::RegisterInfo *
73  if (reg)
74  return nullptr;
75  return &m_pc_reg_info;
76 }
77 
79 
80 const lldb_private::RegisterSet *
82  if (reg_set)
83  return nullptr;
84  return &m_reg_set0;
85 }
86 
88  const lldb_private::RegisterInfo *reg_info,
90  if (!reg_info)
91  return false;
92  uint32_t reg_number = reg_info->kinds[eRegisterKindGeneric];
93  if (reg_number == LLDB_REGNUM_GENERIC_PC) {
94  value.SetUInt(m_pc_value, reg_info->byte_size);
95  return true;
96  }
97  return false;
98 }
99 
101  const lldb_private::RegisterInfo *reg_info,
102  const lldb_private::RegisterValue &value) {
103  return false;
104 }
105 
107  lldb::DataBufferSP &data_sp) {
108  return false;
109 }
110 
112  const lldb::DataBufferSP &data_sp) {
113  return false;
114 }
115 
117  lldb::RegisterKind kind, uint32_t num) {
118  if (kind == eRegisterKindGeneric && num == LLDB_REGNUM_GENERIC_PC)
119  return 0;
120  return LLDB_INVALID_REGNUM;
121 }
lldb_private::RegisterContextHistory::WriteAllRegisterValues
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
Definition: RegisterContextHistory.cpp:111
lldb::eFormatPointer
@ eFormatPointer
Definition: lldb-enumerations.h:178
lldb_private::RegisterContextHistory::GetRegisterCount
size_t GetRegisterCount() override
Definition: RegisterContextHistory.cpp:69
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:91
lldb_private::RegisterContextHistory::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: RegisterContextHistory.cpp:116
lldb_private::RegisterContextHistory::~RegisterContextHistory
~RegisterContextHistory() override
Definition: RegisterContextHistory.cpp:61
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::RegisterContextHistory::GetRegisterInfoAtIndex
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
Definition: RegisterContextHistory.cpp:72
Module.h
RegisterValue.h
StackFrame.h
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
ABI.h
lldb_private::RegisterContextHistory::m_pc_reg_info
lldb_private::RegisterInfo m_pc_reg_info
Definition: RegisterContextHistory.h:57
lldb_private::RegisterContextHistory::WriteRegister
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
Definition: RegisterContextHistory.cpp:100
Process.h
Target.h
lldb_private::RegisterContextHistory::GetRegisterSetCount
size_t GetRegisterSetCount() override
Definition: RegisterContextHistory.cpp:78
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_private::RegisterContextHistory::InvalidateAllRegisters
void InvalidateAllRegisters() override
Definition: RegisterContextHistory.cpp:67
lldb::eEncodingUint
@ eEncodingUint
unsigned integer
Definition: lldb-enumerations.h:148
lldb_private::RegisterContextHistory::m_reg_set0
lldb_private::RegisterSet m_reg_set0
Definition: RegisterContextHistory.h:56
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
uint32_t
lldb_private::RegisterValue::SetUInt
bool SetUInt(uint64_t uint, uint32_t byte_size)
Definition: RegisterValue.cpp:734
Function.h
DWARFExpression.h
SymbolContext.h
lldb_private::RegisterContextHistory::m_pc_value
lldb::addr_t m_pc_value
Definition: RegisterContextHistory.h:59
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
LLDB_REGNUM_GENERIC_PC
#define LLDB_REGNUM_GENERIC_PC
Definition: lldb-defines.h:63
lldb_private::RegisterContextHistory::GetRegisterSet
const lldb_private::RegisterSet * GetRegisterSet(size_t reg_set) override
Definition: RegisterContextHistory.cpp:81
DynamicLoader.h
AddressRange.h
lldb
Definition: SBAddress.h:15
Value.h
RegisterContextHistory.h
ExecutionContext.h
DataBufferHeap.h
lldb_private::RegisterContextHistory::ReadRegister
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
Definition: RegisterContextHistory.cpp:87
lldb_private::RegisterContextHistory::ReadAllRegisterValues
bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override
Definition: RegisterContextHistory.cpp:106