]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextHistory.cpp
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / RegisterContextHistory.cpp
1 //===-- RegisterContextHistory.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 "RegisterContextHistory.h"
34
35 using namespace lldb;
36 using namespace lldb_private;
37
38 RegisterContextHistory::RegisterContextHistory (Thread &thread, uint32_t concrete_frame_idx, uint32_t address_byte_size, addr_t pc_value) :
39 RegisterContext (thread, concrete_frame_idx),
40     m_pc_value (pc_value)
41 {
42     m_reg_set0.name = "General Purpose Registers";
43     m_reg_set0.short_name = "GPR";
44     m_reg_set0.num_registers = 1;
45     m_reg_set0.registers = new uint32_t(0);
46     
47     m_pc_reg_info.name = "pc";
48     m_pc_reg_info.alt_name = "pc";
49     m_pc_reg_info.byte_offset = 0;
50     m_pc_reg_info.byte_size = address_byte_size;
51     m_pc_reg_info.encoding = eEncodingUint;
52     m_pc_reg_info.format = eFormatPointer;
53     m_pc_reg_info.invalidate_regs = NULL;
54     m_pc_reg_info.value_regs = NULL;
55     m_pc_reg_info.kinds[eRegisterKindGCC] = LLDB_INVALID_REGNUM;
56     m_pc_reg_info.kinds[eRegisterKindDWARF] = LLDB_INVALID_REGNUM;
57     m_pc_reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
58     m_pc_reg_info.kinds[eRegisterKindGDB] = LLDB_INVALID_REGNUM;
59     m_pc_reg_info.kinds[eRegisterKindLLDB] = LLDB_INVALID_REGNUM;
60 }
61
62 RegisterContextHistory::~RegisterContextHistory ()
63 {
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
70 RegisterContextHistory::InvalidateAllRegisters () {}
71
72 size_t
73 RegisterContextHistory::GetRegisterCount ()
74 {
75     return 1;
76 }
77
78 const lldb_private::RegisterInfo *
79 RegisterContextHistory::GetRegisterInfoAtIndex (size_t reg)
80 {
81     if (reg)
82         return NULL;
83     return &m_pc_reg_info;
84 }
85
86 size_t
87 RegisterContextHistory::GetRegisterSetCount ()
88 {
89     return 1;
90 }
91
92 const lldb_private::RegisterSet *
93 RegisterContextHistory::GetRegisterSet (size_t reg_set)
94 {
95     if (reg_set)
96         return NULL;
97     return &m_reg_set0;
98 }
99
100 bool
101 RegisterContextHistory::ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value)
102 {
103     if (!reg_info)
104         return false;
105     uint32_t reg_number = reg_info->kinds[eRegisterKindGeneric];
106     if (reg_number == LLDB_REGNUM_GENERIC_PC)
107     {
108         value.SetUInt(m_pc_value, reg_info->byte_size);
109         return true;
110     }
111     return false;
112 }
113
114 bool
115 RegisterContextHistory::WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value)
116 {
117     return false;
118 }
119
120 bool
121 RegisterContextHistory::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
122 {
123     return false;
124 }
125
126 bool
127 RegisterContextHistory::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
128 {
129     return false;
130 }
131
132 uint32_t
133 RegisterContextHistory::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num)
134 {
135     if (kind == eRegisterKindGeneric && num == LLDB_REGNUM_GENERIC_PC)
136         return 0;
137     return LLDB_INVALID_REGNUM;
138 }