| 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" |
| 13 | #include "lldb/Expression/DWARFExpression.h" |
| 14 | #include "lldb/Symbol/FuncUnwinders.h" |
| 15 | #include "lldb/Symbol/Function.h" |
| 16 | #include "lldb/Symbol/ObjectFile.h" |
| 17 | #include "lldb/Symbol/Symbol.h" |
| 18 | #include "lldb/Symbol/SymbolContext.h" |
| 19 | #include "lldb/Target/ABI.h" |
| 20 | #include "lldb/Target/DynamicLoader.h" |
| 21 | #include "lldb/Target/ExecutionContext.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" |
| 26 | #include "lldb/Utility/DataBufferHeap.h" |
| 27 | #include "lldb/Utility/Log.h" |
| 28 | #include "lldb/Utility/RegisterValue.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; |
| 50 | m_pc_reg_info.format = eFormatPointer; |
| 51 | m_pc_reg_info.invalidate_regs = nullptr; |
| 52 | m_pc_reg_info.value_regs = nullptr; |
| 53 | m_pc_reg_info.kinds[eRegisterKindEHFrame] = LLDB_INVALID_REGNUM; |
| 54 | m_pc_reg_info.kinds[eRegisterKindDWARF] = LLDB_INVALID_REGNUM; |
| 55 | m_pc_reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC; |
| 56 | m_pc_reg_info.kinds[eRegisterKindProcessPlugin] = LLDB_INVALID_REGNUM; |
| 57 | m_pc_reg_info.kinds[eRegisterKindLLDB] = LLDB_INVALID_REGNUM; |
| 58 | } |
| 59 | |
| 60 | RegisterContextDummy::~RegisterContextDummy() { |
| 61 | delete m_reg_set0.registers; |
| 62 | delete m_pc_reg_info.invalidate_regs; |
| 63 | delete m_pc_reg_info.value_regs; |
| 64 | } |
| 65 | |
| 66 | void RegisterContextDummy::InvalidateAllRegisters() {} |
| 67 | |
| 68 | size_t RegisterContextDummy::GetRegisterCount() { return 1; } |
| 69 | |
| 70 | const lldb_private::RegisterInfo * |
| 71 | RegisterContextDummy::GetRegisterInfoAtIndex(size_t reg) { |
| 72 | if (reg) |
| 73 | return nullptr; |
| 74 | return &m_pc_reg_info; |
| 75 | } |
| 76 | |
| 77 | size_t RegisterContextDummy::GetRegisterSetCount() { return 1; } |
| 78 | |
| 79 | const lldb_private::RegisterSet * |
| 80 | RegisterContextDummy::GetRegisterSet(size_t reg_set) { |
| 81 | if (reg_set) |
| 82 | return nullptr; |
| 83 | return &m_reg_set0; |
| 84 | } |
| 85 | |
| 86 | bool RegisterContextDummy::ReadRegister( |
| 87 | const lldb_private::RegisterInfo *reg_info, |
| 88 | lldb_private::RegisterValue &value) { |
| 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, byte_size: reg_info->byte_size); |
| 94 | return true; |
| 95 | } |
| 96 | return false; |
| 97 | } |
| 98 | |
| 99 | bool RegisterContextDummy::WriteRegister( |
| 100 | const lldb_private::RegisterInfo *reg_info, |
| 101 | const lldb_private::RegisterValue &value) { |
| 102 | return false; |
| 103 | } |
| 104 | |
| 105 | bool RegisterContextDummy::ReadAllRegisterValues( |
| 106 | lldb::WritableDataBufferSP &data_sp) { |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | bool RegisterContextDummy::WriteAllRegisterValues( |
| 111 | const lldb::DataBufferSP &data_sp) { |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | uint32_t RegisterContextDummy::ConvertRegisterKindToRegisterNumber( |
| 116 | lldb::RegisterKind kind, uint32_t num) { |
| 117 | if (kind == eRegisterKindGeneric && num == LLDB_REGNUM_GENERIC_PC) |
| 118 | return 0; |
| 119 | return LLDB_INVALID_REGNUM; |
| 120 | } |
| 121 |
