blob: ee447a11c2c0096176057455a44b30835a2cd520 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- Symbol.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#include "lldb/Symbol/Symbol.h"
11
12#include "lldb/Core/Module.h"
13#include "lldb/Core/Section.h"
14#include "lldb/Core/Stream.h"
Greg Clayton1f746072012-08-29 21:13:06 +000015#include "lldb/Symbol/ObjectFile.h"
16#include "lldb/Symbol/Symtab.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000017#include "lldb/Target/Process.h"
Greg Claytonf5e56de2010-09-14 23:36:40 +000018#include "lldb/Target/Target.h"
Michael Sartaina7499c92013-07-01 19:45:50 +000019#include "lldb/Symbol/SymbolVendor.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020
21using namespace lldb;
22using namespace lldb_private;
23
24
25Symbol::Symbol() :
Stephen Wilson71c21d12011-04-11 19:41:40 +000026 SymbolContextScope (),
Greg Clayton81c22f62011-10-19 18:09:39 +000027 m_uid (UINT32_MAX),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000028 m_type_data (0),
29 m_type_data_resolved (false),
30 m_is_synthetic (false),
31 m_is_debug (false),
32 m_is_external (false),
33 m_size_is_sibling (false),
34 m_size_is_synthesized (false),
Greg Claytonda171f12012-03-02 03:01:16 +000035 m_calculated_size (false),
Greg Clayton3d51b9f2012-11-27 01:52:16 +000036 m_demangled_is_synthesized (false),
Greg Clayton01575f82011-11-22 21:20:33 +000037 m_type (eSymbolTypeInvalid),
Greg Claytond8c3d4b2013-06-19 21:50:28 +000038 m_mangled (),
39 m_addr_range (),
40 m_flags ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +000041{
42}
43
44Symbol::Symbol
45(
Greg Clayton81c22f62011-10-19 18:09:39 +000046 uint32_t symID,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000047 const char *name,
48 bool name_is_mangled,
49 SymbolType type,
50 bool external,
51 bool is_debug,
52 bool is_trampoline,
53 bool is_artificial,
Greg Claytone72dfb32012-02-24 01:59:29 +000054 const lldb::SectionSP &section_sp,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000055 addr_t offset,
Greg Claytonc7bece562013-01-25 18:06:21 +000056 addr_t size,
Greg Clayton9594f4c2013-04-13 23:17:23 +000057 bool size_is_valid,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000058 uint32_t flags
59) :
Stephen Wilson71c21d12011-04-11 19:41:40 +000060 SymbolContextScope (),
Greg Clayton81c22f62011-10-19 18:09:39 +000061 m_uid (symID),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000062 m_type_data (0),
63 m_type_data_resolved (false),
64 m_is_synthetic (is_artificial),
65 m_is_debug (is_debug),
66 m_is_external (external),
67 m_size_is_sibling (false),
68 m_size_is_synthesized (false),
Greg Clayton9594f4c2013-04-13 23:17:23 +000069 m_calculated_size (size_is_valid || size > 0),
Greg Clayton3d51b9f2012-11-27 01:52:16 +000070 m_demangled_is_synthesized (false),
Greg Clayton01575f82011-11-22 21:20:33 +000071 m_type (type),
Greg Claytond8c3d4b2013-06-19 21:50:28 +000072 m_mangled (ConstString(name), name_is_mangled),
73 m_addr_range (section_sp, offset, size),
74 m_flags (flags)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000075{
76}
77
78Symbol::Symbol
79(
Greg Clayton81c22f62011-10-19 18:09:39 +000080 uint32_t symID,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000081 const char *name,
82 bool name_is_mangled,
83 SymbolType type,
84 bool external,
85 bool is_debug,
86 bool is_trampoline,
87 bool is_artificial,
88 const AddressRange &range,
Greg Clayton9594f4c2013-04-13 23:17:23 +000089 bool size_is_valid,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000090 uint32_t flags
91) :
Stephen Wilson71c21d12011-04-11 19:41:40 +000092 SymbolContextScope (),
Greg Clayton81c22f62011-10-19 18:09:39 +000093 m_uid (symID),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000094 m_type_data (0),
95 m_type_data_resolved (false),
96 m_is_synthetic (is_artificial),
97 m_is_debug (is_debug),
98 m_is_external (external),
99 m_size_is_sibling (false),
100 m_size_is_synthesized (false),
Greg Clayton9594f4c2013-04-13 23:17:23 +0000101 m_calculated_size (size_is_valid || range.GetByteSize() > 0),
Greg Clayton3d51b9f2012-11-27 01:52:16 +0000102 m_demangled_is_synthesized (false),
Greg Clayton01575f82011-11-22 21:20:33 +0000103 m_type (type),
Greg Claytond8c3d4b2013-06-19 21:50:28 +0000104 m_mangled (ConstString(name), name_is_mangled),
105 m_addr_range (range),
106 m_flags (flags)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000107{
108}
109
110Symbol::Symbol(const Symbol& rhs):
Stephen Wilson71c21d12011-04-11 19:41:40 +0000111 SymbolContextScope (rhs),
Greg Clayton81c22f62011-10-19 18:09:39 +0000112 m_uid (rhs.m_uid),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000113 m_type_data (rhs.m_type_data),
114 m_type_data_resolved (rhs.m_type_data_resolved),
115 m_is_synthetic (rhs.m_is_synthetic),
116 m_is_debug (rhs.m_is_debug),
117 m_is_external (rhs.m_is_external),
118 m_size_is_sibling (rhs.m_size_is_sibling),
119 m_size_is_synthesized (false),
Greg Claytonda171f12012-03-02 03:01:16 +0000120 m_calculated_size (rhs.m_calculated_size),
Greg Clayton3d51b9f2012-11-27 01:52:16 +0000121 m_demangled_is_synthesized (rhs.m_demangled_is_synthesized),
Greg Clayton01575f82011-11-22 21:20:33 +0000122 m_type (rhs.m_type),
Greg Claytond8c3d4b2013-06-19 21:50:28 +0000123 m_mangled (rhs.m_mangled),
124 m_addr_range (rhs.m_addr_range),
125 m_flags (rhs.m_flags)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000126{
127}
128
129const Symbol&
130Symbol::operator= (const Symbol& rhs)
131{
132 if (this != &rhs)
133 {
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000134 SymbolContextScope::operator= (rhs);
Greg Clayton81c22f62011-10-19 18:09:39 +0000135 m_uid = rhs.m_uid;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000136 m_type_data = rhs.m_type_data;
137 m_type_data_resolved = rhs.m_type_data_resolved;
138 m_is_synthetic = rhs.m_is_synthetic;
139 m_is_debug = rhs.m_is_debug;
140 m_is_external = rhs.m_is_external;
141 m_size_is_sibling = rhs.m_size_is_sibling;
142 m_size_is_synthesized = rhs.m_size_is_sibling;
Greg Claytonda171f12012-03-02 03:01:16 +0000143 m_calculated_size = rhs.m_calculated_size;
Greg Clayton3d51b9f2012-11-27 01:52:16 +0000144 m_demangled_is_synthesized = rhs.m_demangled_is_synthesized;
Greg Clayton01575f82011-11-22 21:20:33 +0000145 m_type = rhs.m_type;
Greg Claytond8c3d4b2013-06-19 21:50:28 +0000146 m_mangled = rhs.m_mangled;
Greg Clayton01575f82011-11-22 21:20:33 +0000147 m_addr_range = rhs.m_addr_range;
Greg Claytond8c3d4b2013-06-19 21:50:28 +0000148 m_flags = rhs.m_flags;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000149 }
150 return *this;
151}
152
Greg Clayton81c22f62011-10-19 18:09:39 +0000153void
154Symbol::Clear()
155{
156 m_uid = UINT32_MAX;
157 m_mangled.Clear();
Greg Clayton81c22f62011-10-19 18:09:39 +0000158 m_type_data = 0;
159 m_type_data_resolved = false;
160 m_is_synthetic = false;
161 m_is_debug = false;
162 m_is_external = false;
163 m_size_is_sibling = false;
164 m_size_is_synthesized = false;
Greg Claytonda171f12012-03-02 03:01:16 +0000165 m_calculated_size = false;
Greg Clayton3d51b9f2012-11-27 01:52:16 +0000166 m_demangled_is_synthesized = false;
Greg Clayton01575f82011-11-22 21:20:33 +0000167 m_type = eSymbolTypeInvalid;
Greg Clayton81c22f62011-10-19 18:09:39 +0000168 m_flags = 0;
Greg Clayton01575f82011-11-22 21:20:33 +0000169 m_addr_range.Clear();
Greg Clayton81c22f62011-10-19 18:09:39 +0000170}
171
Greg Claytone7612132012-03-07 21:03:09 +0000172bool
173Symbol::ValueIsAddress() const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000174{
Greg Claytone7612132012-03-07 21:03:09 +0000175 return m_addr_range.GetBaseAddress().GetSection().get() != NULL;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000176}
177
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000178uint32_t
179Symbol::GetSiblingIndex() const
180{
181 return m_size_is_sibling ? m_addr_range.GetByteSize() : 0;
182}
183
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000184bool
185Symbol::IsTrampoline () const
186{
187 return m_type == eSymbolTypeTrampoline;
188}
189
Matt Kopec00049b82013-02-27 20:13:38 +0000190bool
191Symbol::IsIndirect () const
192{
193 return m_type == eSymbolTypeResolver;
194}
195
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000196void
Greg Claytonf5e56de2010-09-14 23:36:40 +0000197Symbol::GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const
Greg Clayton0c5cd902010-06-28 21:30:43 +0000198{
Greg Claytonc4a8a762012-05-15 18:43:44 +0000199 s->Printf("id = {0x%8.8x}", m_uid);
Greg Claytond9dc52d2011-09-24 05:04:40 +0000200
Greg Claytone72dfb32012-02-24 01:59:29 +0000201 if (m_addr_range.GetBaseAddress().GetSection())
Greg Clayton0c5cd902010-06-28 21:30:43 +0000202 {
Greg Clayton8f89a7b2012-03-07 23:30:39 +0000203 if (ValueIsAddress())
Greg Clayton0c5cd902010-06-28 21:30:43 +0000204 {
Greg Clayton8f89a7b2012-03-07 23:30:39 +0000205 const lldb::addr_t byte_size = GetByteSize();
206 if (byte_size > 0)
Greg Claytonc9800662010-09-10 01:30:46 +0000207 {
208 s->PutCString (", range = ");
Greg Claytonf5e56de2010-09-14 23:36:40 +0000209 m_addr_range.Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
Greg Claytonc9800662010-09-10 01:30:46 +0000210 }
211 else
212 {
213 s->PutCString (", address = ");
Greg Claytonf5e56de2010-09-14 23:36:40 +0000214 m_addr_range.GetBaseAddress().Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
Greg Claytonc9800662010-09-10 01:30:46 +0000215 }
Greg Clayton0c5cd902010-06-28 21:30:43 +0000216 }
217 else
Daniel Malead01b2952012-11-29 21:49:15 +0000218 s->Printf (", value = 0x%16.16" PRIx64, m_addr_range.GetBaseAddress().GetOffset());
Greg Claytond9dc52d2011-09-24 05:04:40 +0000219 }
220 else
221 {
222 if (m_size_is_sibling)
Daniel Malead01b2952012-11-29 21:49:15 +0000223 s->Printf (", sibling = %5" PRIu64, m_addr_range.GetBaseAddress().GetOffset());
Greg Claytond9dc52d2011-09-24 05:04:40 +0000224 else
Daniel Malead01b2952012-11-29 21:49:15 +0000225 s->Printf (", value = 0x%16.16" PRIx64, m_addr_range.GetBaseAddress().GetOffset());
Greg Clayton0c5cd902010-06-28 21:30:43 +0000226 }
Greg Clayton6b2bd932012-02-01 08:09:32 +0000227 if (m_mangled.GetDemangledName())
228 s->Printf(", name=\"%s\"", m_mangled.GetDemangledName().AsCString());
229 if (m_mangled.GetMangledName())
230 s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
231
Greg Clayton0c5cd902010-06-28 21:30:43 +0000232}
233
234void
Greg Claytonf5e56de2010-09-14 23:36:40 +0000235Symbol::Dump(Stream *s, Target *target, uint32_t index) const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000236{
237// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
238// s->Indent();
239// s->Printf("Symbol[%5u] %6u %c%c %-12s ",
240 s->Printf("[%5u] %6u %c%c%c %-12s ",
241 index,
242 GetID(),
243 m_is_debug ? 'D' : ' ',
244 m_is_synthetic ? 'S' : ' ',
245 m_is_external ? 'X' : ' ',
246 GetTypeAsString());
247
Greg Claytone7612132012-03-07 21:03:09 +0000248 // Make sure the size of the symbol is up to date before dumping
249 GetByteSize();
250
251 if (ValueIsAddress())
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000252 {
253 if (!m_addr_range.GetBaseAddress().Dump(s, NULL, Address::DumpStyleFileAddress))
254 s->Printf("%*s", 18, "");
255
256 s->PutChar(' ');
257
Greg Claytonf5e56de2010-09-14 23:36:40 +0000258 if (!m_addr_range.GetBaseAddress().Dump(s, target, Address::DumpStyleLoadAddress))
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000259 s->Printf("%*s", 18, "");
260
261 const char *format = m_size_is_sibling ?
262 " Sibling -> [%5llu] 0x%8.8x %s\n":
Daniel Malead01b2952012-11-29 21:49:15 +0000263 " 0x%16.16" PRIx64 " 0x%8.8x %s\n";
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000264 s->Printf( format,
Greg Clayton8f89a7b2012-03-07 23:30:39 +0000265 GetByteSize(),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000266 m_flags,
267 m_mangled.GetName().AsCString(""));
268 }
269 else
270 {
271 const char *format = m_size_is_sibling ?
Daniel Malead01b2952012-11-29 21:49:15 +0000272 "0x%16.16" PRIx64 " Sibling -> [%5llu] 0x%8.8x %s\n":
273 "0x%16.16" PRIx64 " 0x%16.16" PRIx64 " 0x%8.8x %s\n";
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000274 s->Printf( format,
275 m_addr_range.GetBaseAddress().GetOffset(),
Greg Clayton8f89a7b2012-03-07 23:30:39 +0000276 GetByteSize(),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000277 m_flags,
278 m_mangled.GetName().AsCString(""));
279 }
280}
281
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000282uint32_t
283Symbol::GetPrologueByteSize ()
284{
Matt Kopec00049b82013-02-27 20:13:38 +0000285 if (m_type == eSymbolTypeCode || m_type == eSymbolTypeResolver)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000286 {
287 if (!m_type_data_resolved)
288 {
289 m_type_data_resolved = true;
Greg Claytone72dfb32012-02-24 01:59:29 +0000290 ModuleSP module_sp (m_addr_range.GetBaseAddress().GetModule());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000291 SymbolContext sc;
Michael Sartaina7499c92013-07-01 19:45:50 +0000292 if (module_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000293 {
Michael Sartaina7499c92013-07-01 19:45:50 +0000294 uint32_t resolved_flags = module_sp->ResolveSymbolContextForAddress (m_addr_range.GetBaseAddress(),
295 eSymbolContextLineEntry,
296 sc);
297 if (resolved_flags & eSymbolContextLineEntry)
298 {
299 // Default to the end of the first line entry.
300 m_type_data = sc.line_entry.range.GetByteSize();
301
302 // Set address for next line.
303 Address addr (m_addr_range.GetBaseAddress());
304 addr.Slide (m_type_data);
305
306 // Check the first few instructions and look for one that has a line number that is
307 // different than the first entry. This is also done in Function::GetPrologueByteSize().
308 uint16_t total_offset = m_type_data;
309 for (int idx = 0; idx < 6; ++idx)
310 {
311 SymbolContext sc_temp;
312 resolved_flags = module_sp->ResolveSymbolContextForAddress (addr, eSymbolContextLineEntry, sc_temp);
313 // Make sure we got line number information...
314 if (!(resolved_flags & eSymbolContextLineEntry))
315 break;
316
317 // If this line number is different than our first one, use it and we're done.
318 if (sc_temp.line_entry.line != sc.line_entry.line)
319 {
320 m_type_data = total_offset;
321 break;
322 }
323
324 // Slide addr up to the next line address.
325 addr.Slide (sc_temp.line_entry.range.GetByteSize());
326 total_offset += sc_temp.line_entry.range.GetByteSize();
327 // If we've gone too far, bail out.
328 if (total_offset >= m_addr_range.GetByteSize())
329 break;
330 }
331
332 // Sanity check - this may be a function in the middle of code that has debug information, but
333 // not for this symbol. So the line entries surrounding us won't lie inside our function.
334 // In that case, the line entry will be bigger than we are, so we do that quick check and
335 // if that is true, we just return 0.
336 if (m_type_data >= m_addr_range.GetByteSize())
337 m_type_data = 0;
338 }
339 else
340 {
341 // TODO: expose something in Process to figure out the
342 // size of a function prologue.
Jim Inghamc8ff80d2012-07-24 01:31:19 +0000343 m_type_data = 0;
Michael Sartaina7499c92013-07-01 19:45:50 +0000344 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000345 }
346 }
347 return m_type_data;
348 }
349 return 0;
350}
351
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000352bool
353Symbol::Compare(const ConstString& name, SymbolType type) const
354{
Jim Inghamc30ee562011-10-29 00:54:12 +0000355 if (type == eSymbolTypeAny || m_type == type)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000356 return m_mangled.GetMangledName() == name || m_mangled.GetDemangledName() == name;
357 return false;
358}
359
360#define ENUM_TO_CSTRING(x) case eSymbolType##x: return #x;
361
362const char *
363Symbol::GetTypeAsString() const
364{
365 switch (m_type)
366 {
367 ENUM_TO_CSTRING(Invalid);
368 ENUM_TO_CSTRING(Absolute);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000369 ENUM_TO_CSTRING(Code);
370 ENUM_TO_CSTRING(Data);
371 ENUM_TO_CSTRING(Trampoline);
372 ENUM_TO_CSTRING(Runtime);
373 ENUM_TO_CSTRING(Exception);
374 ENUM_TO_CSTRING(SourceFile);
375 ENUM_TO_CSTRING(HeaderFile);
376 ENUM_TO_CSTRING(ObjectFile);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000377 ENUM_TO_CSTRING(CommonBlock);
378 ENUM_TO_CSTRING(Block);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000379 ENUM_TO_CSTRING(Local);
380 ENUM_TO_CSTRING(Param);
381 ENUM_TO_CSTRING(Variable);
382 ENUM_TO_CSTRING(VariableType);
383 ENUM_TO_CSTRING(LineEntry);
384 ENUM_TO_CSTRING(LineHeader);
385 ENUM_TO_CSTRING(ScopeBegin);
386 ENUM_TO_CSTRING(ScopeEnd);
387 ENUM_TO_CSTRING(Additional);
388 ENUM_TO_CSTRING(Compiler);
389 ENUM_TO_CSTRING(Instrumentation);
390 ENUM_TO_CSTRING(Undefined);
Greg Clayton456809c2011-12-03 02:30:59 +0000391 ENUM_TO_CSTRING(ObjCClass);
392 ENUM_TO_CSTRING(ObjCMetaClass);
393 ENUM_TO_CSTRING(ObjCIVar);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000394 default:
395 break;
396 }
397 return "<unknown SymbolType>";
398}
399
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000400
401void
402Symbol::CalculateSymbolContext (SymbolContext *sc)
403{
404 // Symbols can reconstruct the symbol and the module in the symbol context
405 sc->symbol = this;
Greg Claytone7612132012-03-07 21:03:09 +0000406 if (ValueIsAddress())
407 sc->module_sp = GetAddress().GetModule();
Greg Claytone1cd1be2012-01-29 20:56:30 +0000408 else
409 sc->module_sp.reset();
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000410}
411
Greg Claytone72dfb32012-02-24 01:59:29 +0000412ModuleSP
Greg Clayton7e9b1fd2011-08-12 21:40:01 +0000413Symbol::CalculateSymbolContextModule ()
414{
Greg Claytone7612132012-03-07 21:03:09 +0000415 if (ValueIsAddress())
416 return GetAddress().GetModule();
Greg Claytone72dfb32012-02-24 01:59:29 +0000417 return ModuleSP();
Greg Clayton7e9b1fd2011-08-12 21:40:01 +0000418}
419
420Symbol *
421Symbol::CalculateSymbolContextSymbol ()
422{
423 return this;
424}
425
426
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000427void
428Symbol::DumpSymbolContext (Stream *s)
429{
430 bool dumped_module = false;
Greg Claytone7612132012-03-07 21:03:09 +0000431 if (ValueIsAddress())
432 {
433 ModuleSP module_sp (GetAddress().GetModule());
Greg Claytone72dfb32012-02-24 01:59:29 +0000434 if (module_sp)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000435 {
436 dumped_module = true;
Greg Claytone72dfb32012-02-24 01:59:29 +0000437 module_sp->DumpSymbolContext(s);
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000438 }
439 }
440 if (dumped_module)
441 s->PutCString(", ");
442
443 s->Printf("Symbol{0x%8.8x}", GetID());
444}
445
446
Greg Claytonda171f12012-03-02 03:01:16 +0000447lldb::addr_t
448Symbol::GetByteSize () const
449{
450 addr_t byte_size = m_addr_range.GetByteSize();
451 if (byte_size == 0 && !m_calculated_size)
452 {
453 const_cast<Symbol*>(this)->m_calculated_size = true;
Greg Claytone7612132012-03-07 21:03:09 +0000454 if (ValueIsAddress())
Greg Claytonda171f12012-03-02 03:01:16 +0000455 {
Greg Claytone7612132012-03-07 21:03:09 +0000456 ModuleSP module_sp (GetAddress().GetModule());
Greg Claytonda171f12012-03-02 03:01:16 +0000457 if (module_sp)
458 {
Michael Sartaina7499c92013-07-01 19:45:50 +0000459 SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
460 if (sym_vendor)
Greg Claytonda171f12012-03-02 03:01:16 +0000461 {
Michael Sartaina7499c92013-07-01 19:45:50 +0000462 Symtab *symtab = sym_vendor->GetSymtab();
Greg Claytonda171f12012-03-02 03:01:16 +0000463 if (symtab)
464 {
Greg Claytone7612132012-03-07 21:03:09 +0000465 const_cast<Symbol*>(this)->SetByteSize (symtab->CalculateSymbolSize (const_cast<Symbol *>(this)));
Greg Claytonda171f12012-03-02 03:01:16 +0000466 byte_size = m_addr_range.GetByteSize();
467 }
468 }
469 }
470 }
471 }
472 return byte_size;
473}
474