"llvm/lib/Target/git@repo.hca.bsc.es:rferrer/llvm-epi-0.8.git" did not exist on "e698c90ee9ef18e3fb521db6759f257d117278b2"
Newer
Older
//===-- IRInterpreter.cpp ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/DataEncoder.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Expression/ClangExpressionDeclMap.h"
#include "lldb/Expression/ClangExpressionVariable.h"
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "lldb/Expression/IRForTarget.h"
#include "lldb/Expression/IRInterpreter.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetData.h"
#include <map>
using namespace llvm;
IRInterpreter::IRInterpreter(lldb_private::ClangExpressionDeclMap &decl_map,
lldb_private::Stream *error_stream) :
m_decl_map(decl_map),
m_error_stream(error_stream)
{
}
IRInterpreter::~IRInterpreter()
{
}
static std::string
PrintValue(const Value *value, bool truncate = false)
{
std::string s;
raw_string_ostream rso(s);
value->print(rso);
rso.flush();
if (truncate)
s.resize(s.length() - 1);
size_t offset;
while ((offset = s.find('\n')) != s.npos)
s.erase(offset, 1);
while (s[0] == ' ' || s[0] == '\t')
s.erase(0, 1);
return s;
}
static std::string
PrintType(const Type *type, bool truncate = false)
{
std::string s;
raw_string_ostream rso(s);
type->print(rso);
rso.flush();
if (truncate)
s.resize(s.length() - 1);
return s;
}
typedef STD_SHARED_PTR(lldb_private::DataEncoder) DataEncoderSP;
typedef STD_SHARED_PTR(lldb_private::DataExtractor) DataExtractorSP;
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
class Memory
{
public:
typedef uint32_t index_t;
struct Allocation
{
// m_virtual_address is always the address of the variable in the virtual memory
// space provided by Memory.
//
// m_origin is always non-NULL and describes the source of the data (possibly
// m_data if this allocation is the authoritative source).
//
// Possible value configurations:
//
// Allocation type getValueType() getContextType() m_origin->GetScalar() m_data
// =========================================================================================================================
// FileAddress eValueTypeFileAddress eContextTypeInvalid A location in a binary NULL
// image
//
// LoadAddress eValueTypeLoadAddress eContextTypeInvalid A location in the target's NULL
// virtual memory
//
// Alloca eValueTypeHostAddress eContextTypeInvalid == m_data->GetBytes() Deleted at end of
// execution
//
// PersistentVar eValueTypeHostAddress eContextTypeClangType A persistent variable's NULL
// location in LLDB's memory
//
// Register [ignored] eContextTypeRegister [ignored] Flushed to the register
// at the end of execution
lldb::addr_t m_virtual_address;
size_t m_extent;
lldb_private::Value m_origin;
lldb::DataBufferSP m_data;
Allocation (lldb::addr_t virtual_address,
size_t extent,
lldb::DataBufferSP data) :
m_virtual_address(virtual_address),
m_extent(extent),
m_data(data)
{
}
Allocation (const Allocation &allocation) :
m_virtual_address(allocation.m_virtual_address),
m_extent(allocation.m_extent),
m_origin(allocation.m_origin),
m_data(allocation.m_data)
{
}
};
typedef STD_SHARED_PTR(Allocation) AllocationSP;
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
struct Region
{
AllocationSP m_allocation;
uint64_t m_base;
uint64_t m_extent;
Region () :
m_allocation(),
m_base(0),
m_extent(0)
{
}
Region (AllocationSP allocation, uint64_t base, uint64_t extent) :
m_allocation(allocation),
m_base(base),
m_extent(extent)
{
}
Region (const Region ®ion) :
m_allocation(region.m_allocation),
m_base(region.m_base),
m_extent(region.m_extent)
{
}
bool IsValid ()
{
Jim Ingham
committed
return (bool) m_allocation;
}
bool IsInvalid ()
{
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
}
};
typedef std::vector <AllocationSP> MemoryMap;
private:
lldb::addr_t m_addr_base;
lldb::addr_t m_addr_max;
MemoryMap m_memory;
lldb::ByteOrder m_byte_order;
lldb::addr_t m_addr_byte_size;
TargetData &m_target_data;
lldb_private::ClangExpressionDeclMap &m_decl_map;
MemoryMap::iterator LookupInternal (lldb::addr_t addr)
{
for (MemoryMap::iterator i = m_memory.begin(), e = m_memory.end();
i != e;
++i)
{
if ((*i)->m_virtual_address <= addr &&
(*i)->m_virtual_address + (*i)->m_extent > addr)
return i;
}
return m_memory.end();
}
public:
Memory (TargetData &target_data,
lldb_private::ClangExpressionDeclMap &decl_map,
lldb::addr_t alloc_start,
Loading
Loading full blame...