1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
73
74
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
131
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
162
163
164
165
166
167
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
//===-- Symbol.h ------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Symbol_h_
#define liblldb_Symbol_h_
#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/UserID.h"
#include "lldb/Symbol/SymbolContextScope.h"
namespace lldb_private {
class Symbol :
public SymbolContextScope
{
public:
// ObjectFile readers can classify their symbol table entries and searches can be made
// on specific types where the symbol values will have drastically different meanings
// and sorting requirements.
Symbol();
Symbol (uint32_t symID,
const char *name,
bool name_is_mangled,
lldb::SymbolType type,
bool external,
bool is_debug,
bool is_trampoline,
bool is_artificial,
const lldb::SectionSP §ion_sp,
lldb::addr_t value,
lldb::addr_t size,
bool size_is_valid,
uint32_t flags);
Symbol (uint32_t symID,
const char *name,
bool name_is_mangled,
lldb::SymbolType type,
bool external,
bool is_debug,
bool is_trampoline,
bool is_artificial,
const AddressRange &range,
bool size_is_valid,
uint32_t flags);
Symbol (const Symbol& rhs);
const Symbol&
operator= (const Symbol& rhs);
void
Clear();
bool
Compare (const ConstString& name, lldb::SymbolType type) const;
void
Dump (Stream *s, Target *target, uint32_t index) const;
bool
ValueIsAddress() const;
//------------------------------------------------------------------
// Access the address value. Do NOT hand out the AddressRange as an
// object as the byte size of the address range may not be filled in
// and it should be accessed via GetByteSize().
//------------------------------------------------------------------
Address &
GetAddress()
{
return m_addr_range.GetBaseAddress();
}
//------------------------------------------------------------------
// Access the address value. Do NOT hand out the AddressRange as an
// object as the byte size of the address range may not be filled in
// and it should be accessed via GetByteSize().
//------------------------------------------------------------------
const Address &
GetAddress() const
{
return m_addr_range.GetBaseAddress();
}
const ConstString &
GetName () const
{
return m_mangled.GetName();
}
uint32_t
GetID() const
{
return m_uid;
}
void
SetID(uint32_t uid)
{
m_uid = uid;
}
Mangled&
GetMangled ()
{
return m_mangled;
}
const Mangled&
GetMangled () const
{
return m_mangled;
}
ConstString
GetReExportedSymbolName() const;
FileSpec
GetReExportedSymbolSharedLibrary () const;
bool
SetReExportedSymbolName(const ConstString &name);
bool
SetReExportedSymbolSharedLibrary (const FileSpec &fspec);
Symbol *
ResolveReExportedSymbol (Target &target);
uint32_t
GetSiblingIndex () const;
lldb::SymbolType
GetType () const
{
return (lldb::SymbolType)m_type;
}
void
SetType (lldb::SymbolType type)
{
m_type = (lldb::SymbolType)type;
}
const char *
GetTypeAsString () const;
uint32_t
GetFlags () const
{
return m_flags;
}
void
SetFlags (uint32_t flags)
{
m_flags = flags;
}
void
GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const;
bool
IsSynthetic () const
{
return m_is_synthetic;
}
void
SetIsSynthetic (bool b)
{
m_is_synthetic = b;
}
bool
GetSizeIsSynthesized() const
{
return m_size_is_synthesized;
}
void
SetSizeIsSynthesized(bool b)
{
m_size_is_synthesized = b;
}
bool
IsDebug () const
{
return m_is_debug;
}
void
SetDebug (bool b)
{
m_is_debug = b;
}
bool
IsExternal () const
{
return m_is_external;
}
void
SetExternal (bool b)
{
m_is_external = b;
}
bool
IsTrampoline () const;
bool
IsIndirect () const;
bool
GetByteSizeIsValid () const
{
return m_size_is_valid;
}
lldb::addr_t
GetByteSize () const;
void
SetByteSize (lldb::addr_t size)
{
m_size_is_valid = size > 0;
m_addr_range.SetByteSize(size);
}
bool
GetSizeIsSibling () const
{
return m_size_is_sibling;
}
void
SetSizeIsSibling (bool b)
{
m_size_is_sibling = b;
}
// If m_type is "Code" or "Function" then this will return the prologue size
// in bytes, else it will return zero.
uint32_t
GetPrologueByteSize ();
bool
GetDemangledNameIsSynthesized() const
{
return m_demangled_is_synthesized;
}
void
SetDemangledNameIsSynthesized(bool b)
{
m_demangled_is_synthesized = b;
}
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
/// @see SymbolContextScope
//------------------------------------------------------------------
virtual void
CalculateSymbolContext (SymbolContext *sc);
virtual lldb::ModuleSP
CalculateSymbolContextModule ();
virtual Symbol *
CalculateSymbolContextSymbol ();
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
/// @see SymbolContextScope
//------------------------------------------------------------------
virtual void
DumpSymbolContext (Stream *s);
lldb::DisassemblerSP
GetInstructions (const ExecutionContext &exe_ctx,
const char *flavor,
bool prefer_file_cache);
bool
GetDisassembly (const ExecutionContext &exe_ctx,
const char *flavor,
bool prefer_file_cache,
Stream &strm);
protected:
uint32_t m_uid; // User ID (usually the original symbol table index)
uint16_t m_type_data; // data specific to m_type
uint16_t m_type_data_resolved:1, // True if the data in m_type_data has already been calculated
m_is_synthetic:1, // non-zero if this symbol is not actually in the symbol table, but synthesized from other info in the object file.
m_is_debug:1, // non-zero if this symbol is debug information in a symbol
m_is_external:1, // non-zero if this symbol is globally visible
m_size_is_sibling:1, // m_size contains the index of this symbol's sibling
m_size_is_synthesized:1,// non-zero if this symbol's size was calculated using a delta between this symbol and the next
m_size_is_valid:1,
m_demangled_is_synthesized:1, // The demangled name was created should not be used for expressions or other lookups
m_type:8;
Mangled m_mangled; // uniqued symbol name/mangled name pair
AddressRange m_addr_range; // Contains the value, or the section offset address when the value is an address in a section, and the size (if any)
uint32_t m_flags; // A copy of the flags from the original symbol table, the ObjectFile plug-in can interpret these
};
} // namespace lldb_private
#endif // liblldb_Symbol_h_
|