]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextHistory.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / RegisterContextHistory.cpp
1 //===-- RegisterContextHistory.cpp ---------------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #include "lldb/Core/Address.h"
12 #include "lldb/Core/AddressRange.h"
13 #include "lldb/Core/Module.h"
14 #include "lldb/Core/Value.h"
15 #include "lldb/Expression/DWARFExpression.h"
16 #include "lldb/Symbol/FuncUnwinders.h"
17 #include "lldb/Symbol/Function.h"
18 #include "lldb/Symbol/ObjectFile.h"
19 #include "lldb/Symbol/Symbol.h"
20 #include "lldb/Symbol/SymbolContext.h"
21 #include "lldb/Target/ABI.h"
22 #include "lldb/Target/DynamicLoader.h"
23 #include "lldb/Target/ExecutionContext.h"
24 #include "lldb/Target/Process.h"
25 #include "lldb/Target/StackFrame.h"
26 #include "lldb/Target/Target.h"
27 #include "lldb/Target/Thread.h"
28 #include "lldb/Utility/DataBufferHeap.h"
29 #include "lldb/Utility/Log.h"
30 #include "lldb/Utility/RegisterValue.h"
31 #include "lldb/lldb-private.h"
32
33 #include "RegisterContextHistory.h"
34
35 using namespace lldb;
36 using namespace lldb_private;
37
38 RegisterContextHistory::RegisterContextHistory(Thread &thread,
39                                                uint32_t concrete_frame_idx,
40                                                uint32_t address_byte_size,
41                                                addr_t pc_value)
42     : RegisterContext(thread, concrete_frame_idx), m_pc_value(pc_value) {
43   m_reg_set0.name = "General Purpose Registers";
44   m_reg_set0.short_name = "GPR";
45   m_reg_set0.num_registers = 1;
46   m_reg_set0.registers = new uint32_t(0);
47
48   m_pc_reg_info.name = "pc";
49   m_pc_reg_info.alt_name = "pc";
50   m_pc_reg_info.byte_offset = 0;
51   m_pc_reg_info.byte_size = address_byte_size;
52   m_pc_reg_info.encoding = eEncodingUint;
53   m_pc_reg_info.format = eFormatPointer;
54   m_pc_reg_info.invalidate_regs = NULL;
55   m_pc_reg_info.value_regs = NULL;
56   m_pc_reg_info.kinds[eRegisterKindEHFrame] = LLDB_INVALID_REGNUM;
57   m_pc_reg_info.kinds[eRegisterKindDWARF] = LLDB_INVALID_REGNUM;
58   m_pc_reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
59   m_pc_reg_info.kinds[eRegisterKindProcessPlugin] = LLDB_INVALID_REGNUM;
60   m_pc_reg_info.kinds[eRegisterKindLLDB] = LLDB_INVALID_REGNUM;
61 }
62
63 RegisterContextHistory::~RegisterContextHistory() {
64   delete m_reg_set0.registers;
65   delete m_pc_reg_info.invalidate_regs;
66   delete m_pc_reg_info.value_regs;
67 }
68
69 void RegisterContextHistory::InvalidateAllRegisters() {}
70
71 size_t RegisterContextHistory::GetRegisterCount() { return 1; }
72
73 const lldb_private::RegisterInfo *
74 RegisterContextHistory::GetRegisterInfoAtIndex(size_t reg) {
75   if (reg)
76     return NULL;
77   return &m_pc_reg_info;
78 }
79
80 size_t RegisterContextHistory::GetRegisterSetCount() { return 1; }
81
82 const lldb_private::RegisterSet *
83 RegisterContextHistory::GetRegisterSet(size_t reg_set) {
84   if (reg_set)
85     return NULL;
86   return &m_reg_set0;
87 }
88
89 bool RegisterContextHistory::ReadRegister(
90     const lldb_private::RegisterInfo *reg_info,
91     lldb_private::RegisterValue &value) {
92   if (!reg_info)
93     return false;
94   uint32_t reg_number = reg_info->kinds[eRegisterKindGeneric];
95   if (reg_number == LLDB_REGNUM_GENERIC_PC) {
96     value.SetUInt(m_pc_value, reg_info->byte_size);
97     return true;
98   }
99   return false;
100 }
101
102 bool RegisterContextHistory::WriteRegister(
103     const lldb_private::RegisterInfo *reg_info,
104     const lldb_private::RegisterValue &value) {
105   return false;
106 }
107
108 bool RegisterContextHistory::ReadAllRegisterValues(
109     lldb::DataBufferSP &data_sp) {
110   return false;
111 }
112
113 bool RegisterContextHistory::WriteAllRegisterValues(
114     const lldb::DataBufferSP &data_sp) {
115   return false;
116 }
117
118 uint32_t RegisterContextHistory::ConvertRegisterKindToRegisterNumber(
119     lldb::RegisterKind kind, uint32_t num) {
120   if (kind == eRegisterKindGeneric && num == LLDB_REGNUM_GENERIC_PC)
121     return 0;
122   return LLDB_INVALID_REGNUM;
123 }