1 //===-- RegisterContextDummy.cpp ---------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10
11 #include "lldb/lldb-private.h"
12 #include "lldb/Core/Address.h"
13 #include "lldb/Core/AddressRange.h"
14 #include "lldb/Core/DataBufferHeap.h"
15 #include "lldb/Core/Log.h"
16 #include "lldb/Core/Module.h"
17 #include "lldb/Core/RegisterValue.h"
18 #include "lldb/Core/Value.h"
19 #include "lldb/Expression/DWARFExpression.h"
20 #include "lldb/Symbol/FuncUnwinders.h"
21 #include "lldb/Symbol/Function.h"
22 #include "lldb/Symbol/ObjectFile.h"
23 #include "lldb/Symbol/SymbolContext.h"
24 #include "lldb/Symbol/Symbol.h"
25 #include "lldb/Target/ABI.h"
26 #include "lldb/Target/ExecutionContext.h"
27 #include "lldb/Target/Process.h"
28 #include "lldb/Target/StackFrame.h"
29 #include "lldb/Target/Target.h"
30 #include "lldb/Target/Thread.h"
31 #include "lldb/Target/DynamicLoader.h"
32
33 #include "RegisterContextDummy.h"
34
35 using namespace lldb;
36 using namespace lldb_private;
37
RegisterContextDummy(Thread & thread,uint32_t concrete_frame_idx,uint32_t address_byte_size)38 RegisterContextDummy::RegisterContextDummy (Thread &thread, uint32_t concrete_frame_idx, uint32_t address_byte_size) :
39 RegisterContext (thread, concrete_frame_idx)
40 {
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;
51 m_pc_reg_info.format = eFormatPointer;
52 m_pc_reg_info.invalidate_regs = NULL;
53 m_pc_reg_info.value_regs = NULL;
54 m_pc_reg_info.kinds[eRegisterKindGCC] = LLDB_INVALID_REGNUM;
55 m_pc_reg_info.kinds[eRegisterKindDWARF] = LLDB_INVALID_REGNUM;
56 m_pc_reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
57 m_pc_reg_info.kinds[eRegisterKindGDB] = LLDB_INVALID_REGNUM;
58 m_pc_reg_info.kinds[eRegisterKindLLDB] = LLDB_INVALID_REGNUM;
59 }
60
~RegisterContextDummy()61 RegisterContextDummy::~RegisterContextDummy ()
62 {
63 delete m_reg_set0.registers;
64 delete m_pc_reg_info.invalidate_regs;
65 delete m_pc_reg_info.value_regs;
66 }
67
68 void
InvalidateAllRegisters()69 RegisterContextDummy::InvalidateAllRegisters () {}
70
71 size_t
GetRegisterCount()72 RegisterContextDummy::GetRegisterCount ()
73 {
74 return 1;
75 }
76
77 const lldb_private::RegisterInfo *
GetRegisterInfoAtIndex(size_t reg)78 RegisterContextDummy::GetRegisterInfoAtIndex (size_t reg)
79 {
80 if (reg)
81 return NULL;
82 return &m_pc_reg_info;
83 }
84
85 size_t
GetRegisterSetCount()86 RegisterContextDummy::GetRegisterSetCount ()
87 {
88 return 1;
89 }
90
91 const lldb_private::RegisterSet *
GetRegisterSet(size_t reg_set)92 RegisterContextDummy::GetRegisterSet (size_t reg_set)
93 {
94 if (reg_set)
95 return NULL;
96 return &m_reg_set0;
97 }
98
99 bool
ReadRegister(const lldb_private::RegisterInfo * reg_info,lldb_private::RegisterValue & value)100 RegisterContextDummy::ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value)
101 {
102 if (!reg_info)
103 return false;
104 uint32_t reg_number = reg_info->kinds[eRegisterKindGeneric];
105 if (reg_number == LLDB_REGNUM_GENERIC_PC)
106 {
107 value.SetUInt(LLDB_INVALID_ADDRESS, reg_info->byte_size);
108 return true;
109 }
110 return false;
111 }
112
113 bool
WriteRegister(const lldb_private::RegisterInfo * reg_info,const lldb_private::RegisterValue & value)114 RegisterContextDummy::WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value)
115 {
116 return false;
117 }
118
119 bool
ReadAllRegisterValues(lldb::DataBufferSP & data_sp)120 RegisterContextDummy::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
121 {
122 return false;
123 }
124
125 bool
WriteAllRegisterValues(const lldb::DataBufferSP & data_sp)126 RegisterContextDummy::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
127 {
128 return false;
129 }
130
131 uint32_t
ConvertRegisterKindToRegisterNumber(uint32_t kind,uint32_t num)132 RegisterContextDummy::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num)
133 {
134 if (kind == eRegisterKindGeneric && num == LLDB_REGNUM_GENERIC_PC)
135 return 0;
136 return LLDB_INVALID_REGNUM;
137 }
138