blob: 7f3543c3b23229f2914b7041507059a1792ec823 [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"
Michael Sartainbf43d1a2013-07-03 16:35:41 +000017#include "lldb/Symbol/Function.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000018#include "lldb/Target/Process.h"
Greg Claytonf5e56de2010-09-14 23:36:40 +000019#include "lldb/Target/Target.h"
Michael Sartaina7499c92013-07-01 19:45:50 +000020#include "lldb/Symbol/SymbolVendor.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000021
22using namespace lldb;
23using namespace lldb_private;
24
25
26Symbol::Symbol() :
Stephen Wilson71c21d12011-04-11 19:41:40 +000027 SymbolContextScope (),
Greg Clayton81c22f62011-10-19 18:09:39 +000028 m_uid (UINT32_MAX),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029 m_type_data (0),
30 m_type_data_resolved (false),
31 m_is_synthetic (false),
32 m_is_debug (false),
33 m_is_external (false),
34 m_size_is_sibling (false),
35 m_size_is_synthesized (false),
Greg Clayton3046e662013-07-10 01:23:25 +000036 m_size_is_valid (false),
Greg Clayton3d51b9f2012-11-27 01:52:16 +000037 m_demangled_is_synthesized (false),
Greg Clayton01575f82011-11-22 21:20:33 +000038 m_type (eSymbolTypeInvalid),
Greg Claytond8c3d4b2013-06-19 21:50:28 +000039 m_mangled (),
40 m_addr_range (),
41 m_flags ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +000042{
43}
44
45Symbol::Symbol
46(
Greg Clayton81c22f62011-10-19 18:09:39 +000047 uint32_t symID,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000048 const char *name,
49 bool name_is_mangled,
50 SymbolType type,
51 bool external,
52 bool is_debug,
53 bool is_trampoline,
54 bool is_artificial,
Greg Claytone72dfb32012-02-24 01:59:29 +000055 const lldb::SectionSP &section_sp,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000056 addr_t offset,
Greg Claytonc7bece562013-01-25 18:06:21 +000057 addr_t size,
Greg Clayton9594f4c2013-04-13 23:17:23 +000058 bool size_is_valid,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000059 uint32_t flags
60) :
Stephen Wilson71c21d12011-04-11 19:41:40 +000061 SymbolContextScope (),
Greg Clayton81c22f62011-10-19 18:09:39 +000062 m_uid (symID),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000063 m_type_data (0),
64 m_type_data_resolved (false),
65 m_is_synthetic (is_artificial),
66 m_is_debug (is_debug),
67 m_is_external (external),
68 m_size_is_sibling (false),
69 m_size_is_synthesized (false),
Greg Clayton3046e662013-07-10 01:23:25 +000070 m_size_is_valid (size_is_valid || size > 0),
Greg Clayton3d51b9f2012-11-27 01:52:16 +000071 m_demangled_is_synthesized (false),
Greg Clayton01575f82011-11-22 21:20:33 +000072 m_type (type),
Greg Claytond8c3d4b2013-06-19 21:50:28 +000073 m_mangled (ConstString(name), name_is_mangled),
74 m_addr_range (section_sp, offset, size),
75 m_flags (flags)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000076{
77}
78
79Symbol::Symbol
80(
Greg Clayton81c22f62011-10-19 18:09:39 +000081 uint32_t symID,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000082 const char *name,
83 bool name_is_mangled,
84 SymbolType type,
85 bool external,
86 bool is_debug,
87 bool is_trampoline,
88 bool is_artificial,
89 const AddressRange &range,
Greg Clayton9594f4c2013-04-13 23:17:23 +000090 bool size_is_valid,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000091 uint32_t flags
92) :
Stephen Wilson71c21d12011-04-11 19:41:40 +000093 SymbolContextScope (),
Greg Clayton81c22f62011-10-19 18:09:39 +000094 m_uid (symID),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000095 m_type_data (0),
96 m_type_data_resolved (false),
97 m_is_synthetic (is_artificial),
98 m_is_debug (is_debug),
99 m_is_external (external),
100 m_size_is_sibling (false),
101 m_size_is_synthesized (false),
Greg Clayton3046e662013-07-10 01:23:25 +0000102 m_size_is_valid (size_is_valid || range.GetByteSize() > 0),
Greg Clayton3d51b9f2012-11-27 01:52:16 +0000103 m_demangled_is_synthesized (false),
Greg Clayton01575f82011-11-22 21:20:33 +0000104 m_type (type),
Greg Claytond8c3d4b2013-06-19 21:50:28 +0000105 m_mangled (ConstString(name), name_is_mangled),
106 m_addr_range (range),
107 m_flags (flags)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000108{
109}
110
111Symbol::Symbol(const Symbol& rhs):
Stephen Wilson71c21d12011-04-11 19:41:40 +0000112 SymbolContextScope (rhs),
Greg Clayton81c22f62011-10-19 18:09:39 +0000113 m_uid (rhs.m_uid),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000114 m_type_data (rhs.m_type_data),
115 m_type_data_resolved (rhs.m_type_data_resolved),
116 m_is_synthetic (rhs.m_is_synthetic),
117 m_is_debug (rhs.m_is_debug),
118 m_is_external (rhs.m_is_external),
119 m_size_is_sibling (rhs.m_size_is_sibling),
120 m_size_is_synthesized (false),
Greg Clayton3046e662013-07-10 01:23:25 +0000121 m_size_is_valid (rhs.m_size_is_valid),
Greg Clayton3d51b9f2012-11-27 01:52:16 +0000122 m_demangled_is_synthesized (rhs.m_demangled_is_synthesized),
Greg Clayton01575f82011-11-22 21:20:33 +0000123 m_type (rhs.m_type),
Greg Claytond8c3d4b2013-06-19 21:50:28 +0000124 m_mangled (rhs.m_mangled),
125 m_addr_range (rhs.m_addr_range),
126 m_flags (rhs.m_flags)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000127{
128}
129
130const Symbol&
131Symbol::operator= (const Symbol& rhs)
132{
133 if (this != &rhs)
134 {
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000135 SymbolContextScope::operator= (rhs);
Greg Clayton81c22f62011-10-19 18:09:39 +0000136 m_uid = rhs.m_uid;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000137 m_type_data = rhs.m_type_data;
138 m_type_data_resolved = rhs.m_type_data_resolved;
139 m_is_synthetic = rhs.m_is_synthetic;
140 m_is_debug = rhs.m_is_debug;
141 m_is_external = rhs.m_is_external;
142 m_size_is_sibling = rhs.m_size_is_sibling;
143 m_size_is_synthesized = rhs.m_size_is_sibling;
Greg Clayton3046e662013-07-10 01:23:25 +0000144 m_size_is_valid = rhs.m_size_is_valid;
Greg Clayton3d51b9f2012-11-27 01:52:16 +0000145 m_demangled_is_synthesized = rhs.m_demangled_is_synthesized;
Greg Clayton01575f82011-11-22 21:20:33 +0000146 m_type = rhs.m_type;
Greg Claytond8c3d4b2013-06-19 21:50:28 +0000147 m_mangled = rhs.m_mangled;
Greg Clayton01575f82011-11-22 21:20:33 +0000148 m_addr_range = rhs.m_addr_range;
Greg Claytond8c3d4b2013-06-19 21:50:28 +0000149 m_flags = rhs.m_flags;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000150 }
151 return *this;
152}
153
Greg Clayton81c22f62011-10-19 18:09:39 +0000154void
155Symbol::Clear()
156{
157 m_uid = UINT32_MAX;
158 m_mangled.Clear();
Greg Clayton81c22f62011-10-19 18:09:39 +0000159 m_type_data = 0;
160 m_type_data_resolved = false;
161 m_is_synthetic = false;
162 m_is_debug = false;
163 m_is_external = false;
164 m_size_is_sibling = false;
165 m_size_is_synthesized = false;
Greg Clayton3046e662013-07-10 01:23:25 +0000166 m_size_is_valid = false;
Greg Clayton3d51b9f2012-11-27 01:52:16 +0000167 m_demangled_is_synthesized = false;
Greg Clayton01575f82011-11-22 21:20:33 +0000168 m_type = eSymbolTypeInvalid;
Greg Clayton81c22f62011-10-19 18:09:39 +0000169 m_flags = 0;
Greg Clayton01575f82011-11-22 21:20:33 +0000170 m_addr_range.Clear();
Greg Clayton81c22f62011-10-19 18:09:39 +0000171}
172
Greg Claytone7612132012-03-07 21:03:09 +0000173bool
174Symbol::ValueIsAddress() const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000175{
Greg Claytone7612132012-03-07 21:03:09 +0000176 return m_addr_range.GetBaseAddress().GetSection().get() != NULL;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000177}
178
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000179uint32_t
180Symbol::GetSiblingIndex() const
181{
182 return m_size_is_sibling ? m_addr_range.GetByteSize() : 0;
183}
184
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000185bool
186Symbol::IsTrampoline () const
187{
188 return m_type == eSymbolTypeTrampoline;
189}
190
Matt Kopec00049b82013-02-27 20:13:38 +0000191bool
192Symbol::IsIndirect () const
193{
194 return m_type == eSymbolTypeResolver;
195}
196
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000197void
Greg Claytonf5e56de2010-09-14 23:36:40 +0000198Symbol::GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const
Greg Clayton0c5cd902010-06-28 21:30:43 +0000199{
Greg Claytonc4a8a762012-05-15 18:43:44 +0000200 s->Printf("id = {0x%8.8x}", m_uid);
Greg Claytond9dc52d2011-09-24 05:04:40 +0000201
Greg Claytone72dfb32012-02-24 01:59:29 +0000202 if (m_addr_range.GetBaseAddress().GetSection())
Greg Clayton0c5cd902010-06-28 21:30:43 +0000203 {
Greg Clayton8f89a7b2012-03-07 23:30:39 +0000204 if (ValueIsAddress())
Greg Clayton0c5cd902010-06-28 21:30:43 +0000205 {
Greg Clayton8f89a7b2012-03-07 23:30:39 +0000206 const lldb::addr_t byte_size = GetByteSize();
207 if (byte_size > 0)
Greg Claytonc9800662010-09-10 01:30:46 +0000208 {
209 s->PutCString (", range = ");
Greg Claytonf5e56de2010-09-14 23:36:40 +0000210 m_addr_range.Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
Greg Claytonc9800662010-09-10 01:30:46 +0000211 }
212 else
213 {
214 s->PutCString (", address = ");
Greg Claytonf5e56de2010-09-14 23:36:40 +0000215 m_addr_range.GetBaseAddress().Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
Greg Claytonc9800662010-09-10 01:30:46 +0000216 }
Greg Clayton0c5cd902010-06-28 21:30:43 +0000217 }
218 else
Daniel Malead01b2952012-11-29 21:49:15 +0000219 s->Printf (", value = 0x%16.16" PRIx64, m_addr_range.GetBaseAddress().GetOffset());
Greg Claytond9dc52d2011-09-24 05:04:40 +0000220 }
221 else
222 {
223 if (m_size_is_sibling)
Daniel Malead01b2952012-11-29 21:49:15 +0000224 s->Printf (", sibling = %5" PRIu64, m_addr_range.GetBaseAddress().GetOffset());
Greg Claytond9dc52d2011-09-24 05:04:40 +0000225 else
Daniel Malead01b2952012-11-29 21:49:15 +0000226 s->Printf (", value = 0x%16.16" PRIx64, m_addr_range.GetBaseAddress().GetOffset());
Greg Clayton0c5cd902010-06-28 21:30:43 +0000227 }
Greg Clayton6b2bd932012-02-01 08:09:32 +0000228 if (m_mangled.GetDemangledName())
229 s->Printf(", name=\"%s\"", m_mangled.GetDemangledName().AsCString());
230 if (m_mangled.GetMangledName())
231 s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
232
Greg Clayton0c5cd902010-06-28 21:30:43 +0000233}
234
235void
Greg Claytonf5e56de2010-09-14 23:36:40 +0000236Symbol::Dump(Stream *s, Target *target, uint32_t index) const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000237{
238// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
239// s->Indent();
240// s->Printf("Symbol[%5u] %6u %c%c %-12s ",
241 s->Printf("[%5u] %6u %c%c%c %-12s ",
242 index,
243 GetID(),
244 m_is_debug ? 'D' : ' ',
245 m_is_synthetic ? 'S' : ' ',
246 m_is_external ? 'X' : ' ',
247 GetTypeAsString());
248
Greg Claytone7612132012-03-07 21:03:09 +0000249 // Make sure the size of the symbol is up to date before dumping
250 GetByteSize();
251
252 if (ValueIsAddress())
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000253 {
254 if (!m_addr_range.GetBaseAddress().Dump(s, NULL, Address::DumpStyleFileAddress))
255 s->Printf("%*s", 18, "");
256
257 s->PutChar(' ');
258
Greg Claytonf5e56de2010-09-14 23:36:40 +0000259 if (!m_addr_range.GetBaseAddress().Dump(s, target, Address::DumpStyleLoadAddress))
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000260 s->Printf("%*s", 18, "");
261
262 const char *format = m_size_is_sibling ?
263 " Sibling -> [%5llu] 0x%8.8x %s\n":
Daniel Malead01b2952012-11-29 21:49:15 +0000264 " 0x%16.16" PRIx64 " 0x%8.8x %s\n";
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000265 s->Printf( format,
Greg Clayton8f89a7b2012-03-07 23:30:39 +0000266 GetByteSize(),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000267 m_flags,
268 m_mangled.GetName().AsCString(""));
269 }
270 else
271 {
272 const char *format = m_size_is_sibling ?
Daniel Malead01b2952012-11-29 21:49:15 +0000273 "0x%16.16" PRIx64 " Sibling -> [%5llu] 0x%8.8x %s\n":
274 "0x%16.16" PRIx64 " 0x%16.16" PRIx64 " 0x%8.8x %s\n";
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000275 s->Printf( format,
276 m_addr_range.GetBaseAddress().GetOffset(),
Greg Clayton8f89a7b2012-03-07 23:30:39 +0000277 GetByteSize(),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000278 m_flags,
279 m_mangled.GetName().AsCString(""));
280 }
281}
282
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000283uint32_t
284Symbol::GetPrologueByteSize ()
285{
Matt Kopec00049b82013-02-27 20:13:38 +0000286 if (m_type == eSymbolTypeCode || m_type == eSymbolTypeResolver)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000287 {
288 if (!m_type_data_resolved)
289 {
290 m_type_data_resolved = true;
Michael Sartainbf43d1a2013-07-03 16:35:41 +0000291
292 const Address &base_address = m_addr_range.GetBaseAddress();
293 Function *function = base_address.CalculateSymbolContextFunction();
294 if (function)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000295 {
Michael Sartainbf43d1a2013-07-03 16:35:41 +0000296 // Functions have line entries which can also potentially have end of prologue information.
297 // So if this symbol points to a function, use the prologue information from there.
298 m_type_data = function->GetPrologueByteSize();
299 }
300 else
301 {
302 ModuleSP module_sp (base_address.GetModule());
303 SymbolContext sc;
304 if (module_sp)
Michael Sartaina7499c92013-07-01 19:45:50 +0000305 {
Michael Sartainbf43d1a2013-07-03 16:35:41 +0000306 uint32_t resolved_flags = module_sp->ResolveSymbolContextForAddress (base_address,
307 eSymbolContextLineEntry,
308 sc);
309 if (resolved_flags & eSymbolContextLineEntry)
Michael Sartaina7499c92013-07-01 19:45:50 +0000310 {
Michael Sartainbf43d1a2013-07-03 16:35:41 +0000311 // Default to the end of the first line entry.
312 m_type_data = sc.line_entry.range.GetByteSize();
Michael Sartaina7499c92013-07-01 19:45:50 +0000313
Michael Sartainbf43d1a2013-07-03 16:35:41 +0000314 // Set address for next line.
315 Address addr (base_address);
316 addr.Slide (m_type_data);
317
318 // Check the first few instructions and look for one that has a line number that is
319 // different than the first entry. This is also done in Function::GetPrologueByteSize().
320 uint16_t total_offset = m_type_data;
321 for (int idx = 0; idx < 6; ++idx)
Michael Sartaina7499c92013-07-01 19:45:50 +0000322 {
Michael Sartainbf43d1a2013-07-03 16:35:41 +0000323 SymbolContext sc_temp;
324 resolved_flags = module_sp->ResolveSymbolContextForAddress (addr, eSymbolContextLineEntry, sc_temp);
325 // Make sure we got line number information...
326 if (!(resolved_flags & eSymbolContextLineEntry))
327 break;
328
329 // If this line number is different than our first one, use it and we're done.
330 if (sc_temp.line_entry.line != sc.line_entry.line)
331 {
332 m_type_data = total_offset;
333 break;
334 }
335
336 // Slide addr up to the next line address.
337 addr.Slide (sc_temp.line_entry.range.GetByteSize());
338 total_offset += sc_temp.line_entry.range.GetByteSize();
339 // If we've gone too far, bail out.
340 if (total_offset >= m_addr_range.GetByteSize())
341 break;
Michael Sartaina7499c92013-07-01 19:45:50 +0000342 }
343
Michael Sartainbf43d1a2013-07-03 16:35:41 +0000344 // Sanity check - this may be a function in the middle of code that has debug information, but
345 // not for this symbol. So the line entries surrounding us won't lie inside our function.
346 // In that case, the line entry will be bigger than we are, so we do that quick check and
347 // if that is true, we just return 0.
348 if (m_type_data >= m_addr_range.GetByteSize())
349 m_type_data = 0;
Michael Sartaina7499c92013-07-01 19:45:50 +0000350 }
Michael Sartainbf43d1a2013-07-03 16:35:41 +0000351 else
352 {
353 // TODO: expose something in Process to figure out the
354 // size of a function prologue.
Michael Sartaina7499c92013-07-01 19:45:50 +0000355 m_type_data = 0;
Michael Sartainbf43d1a2013-07-03 16:35:41 +0000356 }
Michael Sartaina7499c92013-07-01 19:45:50 +0000357 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000358 }
359 }
360 return m_type_data;
361 }
362 return 0;
363}
364
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000365bool
366Symbol::Compare(const ConstString& name, SymbolType type) const
367{
Jim Inghamc30ee562011-10-29 00:54:12 +0000368 if (type == eSymbolTypeAny || m_type == type)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000369 return m_mangled.GetMangledName() == name || m_mangled.GetDemangledName() == name;
370 return false;
371}
372
373#define ENUM_TO_CSTRING(x) case eSymbolType##x: return #x;
374
375const char *
376Symbol::GetTypeAsString() const
377{
378 switch (m_type)
379 {
380 ENUM_TO_CSTRING(Invalid);
381 ENUM_TO_CSTRING(Absolute);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000382 ENUM_TO_CSTRING(Code);
383 ENUM_TO_CSTRING(Data);
384 ENUM_TO_CSTRING(Trampoline);
385 ENUM_TO_CSTRING(Runtime);
386 ENUM_TO_CSTRING(Exception);
387 ENUM_TO_CSTRING(SourceFile);
388 ENUM_TO_CSTRING(HeaderFile);
389 ENUM_TO_CSTRING(ObjectFile);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000390 ENUM_TO_CSTRING(CommonBlock);
391 ENUM_TO_CSTRING(Block);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000392 ENUM_TO_CSTRING(Local);
393 ENUM_TO_CSTRING(Param);
394 ENUM_TO_CSTRING(Variable);
395 ENUM_TO_CSTRING(VariableType);
396 ENUM_TO_CSTRING(LineEntry);
397 ENUM_TO_CSTRING(LineHeader);
398 ENUM_TO_CSTRING(ScopeBegin);
399 ENUM_TO_CSTRING(ScopeEnd);
400 ENUM_TO_CSTRING(Additional);
401 ENUM_TO_CSTRING(Compiler);
402 ENUM_TO_CSTRING(Instrumentation);
403 ENUM_TO_CSTRING(Undefined);
Greg Clayton456809c2011-12-03 02:30:59 +0000404 ENUM_TO_CSTRING(ObjCClass);
405 ENUM_TO_CSTRING(ObjCMetaClass);
406 ENUM_TO_CSTRING(ObjCIVar);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000407 default:
408 break;
409 }
410 return "<unknown SymbolType>";
411}
412
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000413void
414Symbol::CalculateSymbolContext (SymbolContext *sc)
415{
416 // Symbols can reconstruct the symbol and the module in the symbol context
417 sc->symbol = this;
Greg Claytone7612132012-03-07 21:03:09 +0000418 if (ValueIsAddress())
419 sc->module_sp = GetAddress().GetModule();
Greg Claytone1cd1be2012-01-29 20:56:30 +0000420 else
421 sc->module_sp.reset();
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000422}
423
Greg Claytone72dfb32012-02-24 01:59:29 +0000424ModuleSP
Greg Clayton7e9b1fd2011-08-12 21:40:01 +0000425Symbol::CalculateSymbolContextModule ()
426{
Greg Claytone7612132012-03-07 21:03:09 +0000427 if (ValueIsAddress())
428 return GetAddress().GetModule();
Greg Claytone72dfb32012-02-24 01:59:29 +0000429 return ModuleSP();
Greg Clayton7e9b1fd2011-08-12 21:40:01 +0000430}
431
432Symbol *
433Symbol::CalculateSymbolContextSymbol ()
434{
435 return this;
436}
437
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000438void
439Symbol::DumpSymbolContext (Stream *s)
440{
441 bool dumped_module = false;
Greg Claytone7612132012-03-07 21:03:09 +0000442 if (ValueIsAddress())
443 {
444 ModuleSP module_sp (GetAddress().GetModule());
Greg Claytone72dfb32012-02-24 01:59:29 +0000445 if (module_sp)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000446 {
447 dumped_module = true;
Greg Claytone72dfb32012-02-24 01:59:29 +0000448 module_sp->DumpSymbolContext(s);
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000449 }
450 }
451 if (dumped_module)
452 s->PutCString(", ");
453
454 s->Printf("Symbol{0x%8.8x}", GetID());
455}
456
Greg Claytonda171f12012-03-02 03:01:16 +0000457lldb::addr_t
458Symbol::GetByteSize () const
459{
Greg Clayton3046e662013-07-10 01:23:25 +0000460 return m_addr_range.GetByteSize();
Greg Claytonda171f12012-03-02 03:01:16 +0000461}
462