1 //===-- SymbolContext.cpp ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Symbol/SymbolContext.h"
12 #include "lldb/Core/Log.h"
13 #include "lldb/Core/Module.h"
14 #include "lldb/Core/ModuleSpec.h"
15 #include "lldb/Host/Host.h"
16 #include "lldb/Interpreter/Args.h"
17 #include "lldb/Symbol/Block.h"
18 #include "lldb/Symbol/ClangASTContext.h"
19 #include "lldb/Symbol/CompileUnit.h"
20 #include "lldb/Symbol/ObjectFile.h"
21 #include "lldb/Symbol/Symbol.h"
22 #include "lldb/Symbol/SymbolFile.h"
23 #include "lldb/Symbol/SymbolVendor.h"
24 #include "lldb/Target/Target.h"
27 using namespace lldb_private;
29 SymbolContext::SymbolContext() :
40 SymbolContext::SymbolContext(const ModuleSP& m, CompileUnit *cu, Function *f, Block *b, LineEntry *le, Symbol *s) :
53 SymbolContext::SymbolContext(const TargetSP &t, const ModuleSP& m, CompileUnit *cu, Function *f, Block *b, LineEntry *le, Symbol *s) :
66 SymbolContext::SymbolContext(const SymbolContext& rhs) :
67 target_sp (rhs.target_sp),
68 module_sp (rhs.module_sp),
69 comp_unit (rhs.comp_unit),
70 function (rhs.function),
72 line_entry (rhs.line_entry),
78 SymbolContext::SymbolContext (SymbolContextScope *sc_scope) :
87 sc_scope->CalculateSymbolContext (this);
90 SymbolContext::~SymbolContext ()
95 SymbolContext::operator= (const SymbolContext& rhs)
99 target_sp = rhs.target_sp;
100 module_sp = rhs.module_sp;
101 comp_unit = rhs.comp_unit;
102 function = rhs.function;
104 line_entry = rhs.line_entry;
111 SymbolContext::Clear(bool clear_target)
124 SymbolContext::DumpStopContext
127 ExecutionContextScope *exe_scope,
131 bool show_inlined_frames
134 bool dumped_something = false;
135 if (show_module && module_sp)
138 *s << module_sp->GetFileSpec();
140 *s << module_sp->GetFileSpec().GetFilename();
142 dumped_something = true;
145 if (function != NULL)
147 SymbolContext inline_parent_sc;
148 Address inline_parent_addr;
149 if (function->GetMangled().GetName())
151 dumped_something = true;
152 function->GetMangled().GetName().Dump(s);
157 const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset();
160 dumped_something = true;
161 s->Printf(" + %" PRIu64, function_offset);
165 if (GetParentOfInlinedScope (addr, inline_parent_sc, inline_parent_addr))
167 dumped_something = true;
168 Block *inlined_block = block->GetContainingInlinedBlock();
169 const InlineFunctionInfo* inlined_block_info = inlined_block->GetInlinedFunctionInfo();
170 s->Printf (" [inlined] %s", inlined_block_info->GetName().GetCString());
172 lldb_private::AddressRange block_range;
173 if (inlined_block->GetRangeContainingAddress(addr, block_range))
175 const addr_t inlined_function_offset = addr.GetOffset() - block_range.GetBaseAddress().GetOffset();
176 if (inlined_function_offset)
178 s->Printf(" + %" PRIu64, inlined_function_offset);
181 const Declaration &call_site = inlined_block_info->GetCallSite();
182 if (call_site.IsValid())
184 s->PutCString(" at ");
185 call_site.DumpStopContext (s, show_fullpaths);
187 if (show_inlined_frames)
191 return inline_parent_sc.DumpStopContext (s, exe_scope, inline_parent_addr, show_fullpaths, show_module, show_inlined_frames);
196 if (line_entry.IsValid())
198 dumped_something = true;
199 s->PutCString(" at ");
200 if (line_entry.DumpStopContext(s, show_fullpaths))
201 dumped_something = true;
205 else if (symbol != NULL)
207 if (symbol->GetMangled().GetName())
209 dumped_something = true;
210 if (symbol->GetType() == eSymbolTypeTrampoline)
211 s->PutCString("symbol stub for: ");
212 symbol->GetMangled().GetName().Dump(s);
215 if (addr.IsValid() && symbol->ValueIsAddress())
217 const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddress().GetOffset();
220 dumped_something = true;
221 s->Printf(" + %" PRIu64, symbol_offset);
225 else if (addr.IsValid())
227 addr.Dump(s, exe_scope, Address::DumpStyleModuleWithFileAddress);
228 dumped_something = true;
230 return dumped_something;
234 SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) const
238 s->Indent(" Module: file = \"");
239 module_sp->GetFileSpec().Dump(s);
241 if (module_sp->GetArchitecture().IsValid())
242 s->Printf (", arch = \"%s\"", module_sp->GetArchitecture().GetArchitectureName());
246 if (comp_unit != NULL)
248 s->Indent("CompileUnit: ");
249 comp_unit->GetDescription (s, level);
253 if (function != NULL)
255 s->Indent(" Function: ");
256 function->GetDescription (s, level, target);
259 Type *func_type = function->GetType();
262 s->Indent(" FuncType: ");
263 func_type->GetDescription (s, level, false);
270 std::vector<Block *> blocks;
271 blocks.push_back (block);
272 Block *parent_block = block->GetParent();
276 blocks.push_back (parent_block);
277 parent_block = parent_block->GetParent();
279 std::vector<Block *>::reverse_iterator pos;
280 std::vector<Block *>::reverse_iterator begin = blocks.rbegin();
281 std::vector<Block *>::reverse_iterator end = blocks.rend();
282 for (pos = begin; pos != end; ++pos)
285 s->Indent(" Blocks: ");
288 (*pos)->GetDescription(s, function, level, target);
293 if (line_entry.IsValid())
295 s->Indent(" LineEntry: ");
296 line_entry.GetDescription (s, level, comp_unit, target, false);
302 s->Indent(" Symbol: ");
303 symbol->GetDescription(s, level, target);
309 SymbolContext::GetResolvedMask () const
311 uint32_t resolved_mask = 0;
312 if (target_sp) resolved_mask |= eSymbolContextTarget;
313 if (module_sp) resolved_mask |= eSymbolContextModule;
314 if (comp_unit) resolved_mask |= eSymbolContextCompUnit;
315 if (function) resolved_mask |= eSymbolContextFunction;
316 if (block) resolved_mask |= eSymbolContextBlock;
317 if (line_entry.IsValid()) resolved_mask |= eSymbolContextLineEntry;
318 if (symbol) resolved_mask |= eSymbolContextSymbol;
319 return resolved_mask;
323 SymbolContext::Dump(Stream *s, Target *target) const
325 *s << (void *)this << ": ";
327 s->PutCString("SymbolContext");
332 *s << "Module = " << (void *)module_sp.get() << ' ';
334 module_sp->GetFileSpec().Dump(s);
337 *s << "CompileUnit = " << (void *)comp_unit;
338 if (comp_unit != NULL)
339 *s << " {0x" << comp_unit->GetID() << "} " << *(static_cast<FileSpec*> (comp_unit));
342 *s << "Function = " << (void *)function;
343 if (function != NULL)
345 *s << " {0x" << function->GetID() << "} " << function->GetType()->GetName() << ", address-range = ";
346 function->GetAddressRange().Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
349 Type* func_type = function->GetType();
353 func_type->Dump (s, false);
358 *s << "Block = " << (void *)block;
360 *s << " {0x" << block->GetID() << '}';
361 // Dump the block and pass it a negative depth to we print all the parent blocks
363 // block->Dump(s, function->GetFileAddress(), INT_MIN);
366 *s << "LineEntry = ";
367 line_entry.Dump (s, target, true, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress, true);
370 *s << "Symbol = " << (void *)symbol;
371 if (symbol != NULL && symbol->GetMangled())
372 *s << ' ' << symbol->GetMangled().GetName().AsCString();
379 lldb_private::operator== (const SymbolContext& lhs, const SymbolContext& rhs)
381 return lhs.function == rhs.function
382 && lhs.symbol == rhs.symbol
383 && lhs.module_sp.get() == rhs.module_sp.get()
384 && lhs.comp_unit == rhs.comp_unit
385 && lhs.target_sp.get() == rhs.target_sp.get()
386 && LineEntry::Compare(lhs.line_entry, rhs.line_entry) == 0;
390 lldb_private::operator!= (const SymbolContext& lhs, const SymbolContext& rhs)
392 return lhs.function != rhs.function
393 || lhs.symbol != rhs.symbol
394 || lhs.module_sp.get() != rhs.module_sp.get()
395 || lhs.comp_unit != rhs.comp_unit
396 || lhs.target_sp.get() != rhs.target_sp.get()
397 || LineEntry::Compare(lhs.line_entry, rhs.line_entry) != 0;
401 SymbolContext::GetAddressRange (uint32_t scope,
403 bool use_inline_block_range,
404 AddressRange &range) const
406 if ((scope & eSymbolContextLineEntry) && line_entry.IsValid())
408 range = line_entry.range;
412 if ((scope & eSymbolContextBlock) && (block != NULL))
414 if (use_inline_block_range)
416 Block *inline_block = block->GetContainingInlinedBlock();
418 return inline_block->GetRangeAtIndex (range_idx, range);
422 return block->GetRangeAtIndex (range_idx, range);
426 if ((scope & eSymbolContextFunction) && (function != NULL))
430 range = function->GetAddressRange();
435 if ((scope & eSymbolContextSymbol) && (symbol != NULL))
439 if (symbol->ValueIsAddress())
441 range.GetBaseAddress() = symbol->GetAddress();
442 range.SetByteSize (symbol->GetByteSize());
452 SymbolContext::GetParentOfInlinedScope (const Address &curr_frame_pc,
453 SymbolContext &next_frame_sc,
454 Address &next_frame_pc) const
456 next_frame_sc.Clear(false);
457 next_frame_pc.Clear();
461 //const addr_t curr_frame_file_addr = curr_frame_pc.GetFileAddress();
463 // In order to get the parent of an inlined function we first need to
464 // see if we are in an inlined block as "this->block" could be an
465 // inlined block, or a parent of "block" could be. So lets check if
466 // this block or one of this blocks parents is an inlined function.
467 Block *curr_inlined_block = block->GetContainingInlinedBlock();
468 if (curr_inlined_block)
470 // "this->block" is contained in an inline function block, so to
471 // get the scope above the inlined block, we get the parent of the
472 // inlined block itself
473 Block *next_frame_block = curr_inlined_block->GetParent();
474 // Now calculate the symbol context of the containing block
475 next_frame_block->CalculateSymbolContext (&next_frame_sc);
477 // If we get here we weren't able to find the return line entry using the nesting of the blocks and
478 // the line table. So just use the call site info from our inlined block.
481 if (curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range))
483 // To see there this new frame block it, we need to look at the
484 // call site information from
485 const InlineFunctionInfo* curr_inlined_block_inlined_info = curr_inlined_block->GetInlinedFunctionInfo();
486 next_frame_pc = range.GetBaseAddress();
487 next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc;
488 next_frame_sc.line_entry.file = curr_inlined_block_inlined_info->GetCallSite().GetFile();
489 next_frame_sc.line_entry.line = curr_inlined_block_inlined_info->GetCallSite().GetLine();
490 next_frame_sc.line_entry.column = curr_inlined_block_inlined_info->GetCallSite().GetColumn();
495 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYMBOLS));
499 log->Printf ("warning: inlined block 0x%8.8" PRIx64 " doesn't have a range that contains file address 0x%" PRIx64,
500 curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress());
502 #ifdef LLDB_CONFIGURATION_DEBUG
505 ObjectFile *objfile = NULL;
508 SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
511 SymbolFile *symbol_file = symbol_vendor->GetSymbolFile();
513 objfile = symbol_file->GetObjectFile();
518 Host::SystemLog (Host::eSystemLogWarning,
519 "warning: inlined block 0x%8.8" PRIx64 " doesn't have a range that contains file address 0x%" PRIx64 " in %s\n",
520 curr_inlined_block->GetID(),
521 curr_frame_pc.GetFileAddress(),
522 objfile->GetFileSpec().GetPath().c_str());
526 Host::SystemLog (Host::eSystemLogWarning,
527 "warning: inlined block 0x%8.8" PRIx64 " doesn't have a range that contains file address 0x%" PRIx64 "\n",
528 curr_inlined_block->GetID(),
529 curr_frame_pc.GetFileAddress());
541 SymbolContext::GetFunctionBlock ()
547 // If this symbol context has a block, check to see if this block
548 // is itself, or is contained within a block with inlined function
549 // information. If so, then the inlined block is the block that
550 // defines the function.
551 Block *inlined_block = block->GetContainingInlinedBlock();
553 return inlined_block;
555 // The block in this symbol context is not inside an inlined
556 // block, so the block that defines the function is the function's
557 // top level block, which is returned below.
560 // There is no block information in this symbol context, so we must
561 // assume that the block that is desired is the top level block of
562 // the function itself.
563 return &function->GetBlock(true);
569 SymbolContext::GetFunctionMethodInfo (lldb::LanguageType &language,
570 bool &is_instance_method,
571 ConstString &language_object_name)
575 Block *function_block = GetFunctionBlock ();
578 clang::DeclContext *decl_context = function_block->GetClangDeclContext();
582 return ClangASTContext::GetClassMethodInfoForDeclContext (decl_context,
585 language_object_name);
588 language = eLanguageTypeUnknown;
589 is_instance_method = false;
590 language_object_name.Clear();
595 SymbolContext::GetFunctionName (Mangled::NamePreference preference) const
601 Block *inlined_block = block->GetContainingInlinedBlock();
605 const InlineFunctionInfo *inline_info = inlined_block->GetInlinedFunctionInfo();
607 return inline_info->GetName();
610 return function->GetMangled().GetName(preference);
612 else if (symbol && symbol->ValueIsAddress())
614 return symbol->GetMangled().GetName(preference);
618 // No function, return an empty string.
619 return ConstString();
624 SymbolContext::GetFunctionStartLineEntry () const
626 LineEntry line_entry;
630 Block *inlined_block = block->GetContainingInlinedBlock();
633 if (inlined_block->GetStartAddress (start_addr))
635 if (start_addr.CalculateSymbolContextLineEntry (line_entry))
644 if (function->GetAddressRange().GetBaseAddress().CalculateSymbolContextLineEntry(line_entry))
650 //----------------------------------------------------------------------
652 // SymbolContextSpecifier
654 //----------------------------------------------------------------------
656 SymbolContextSpecifier::SymbolContextSpecifier (const TargetSP &target_sp) :
657 m_target_sp (target_sp),
665 m_address_range_ap (),
666 m_type (eNothingSpecified)
670 SymbolContextSpecifier::~SymbolContextSpecifier()
675 SymbolContextSpecifier::AddLineSpecification (uint32_t line_no, SpecificationType type)
677 bool return_value = true;
680 case eNothingSpecified:
683 case eLineStartSpecified:
684 m_start_line = line_no;
685 m_type |= eLineStartSpecified;
687 case eLineEndSpecified:
688 m_end_line = line_no;
689 m_type |= eLineEndSpecified;
692 return_value = false;
699 SymbolContextSpecifier::AddSpecification (const char *spec_string, SpecificationType type)
701 bool return_value = true;
704 case eNothingSpecified:
707 case eModuleSpecified:
709 // See if we can find the Module, if so stick it in the SymbolContext.
710 FileSpec module_file_spec(spec_string, false);
711 ModuleSpec module_spec (module_file_spec);
712 lldb::ModuleSP module_sp (m_target_sp->GetImages().FindFirstModule (module_spec));
713 m_type |= eModuleSpecified;
715 m_module_sp = module_sp;
717 m_module_spec.assign (spec_string);
721 // CompUnits can't necessarily be resolved here, since an inlined function might show up in
722 // a number of CompUnits. Instead we just convert to a FileSpec and store it away.
723 m_file_spec_ap.reset (new FileSpec (spec_string, false));
724 m_type |= eFileSpecified;
726 case eLineStartSpecified:
727 m_start_line = Args::StringToSInt32(spec_string, 0, 0, &return_value);
729 m_type |= eLineStartSpecified;
731 case eLineEndSpecified:
732 m_end_line = Args::StringToSInt32(spec_string, 0, 0, &return_value);
734 m_type |= eLineEndSpecified;
736 case eFunctionSpecified:
737 m_function_spec.assign(spec_string);
738 m_type |= eFunctionSpecified;
740 case eClassOrNamespaceSpecified:
742 m_class_name.assign (spec_string);
743 m_type = eClassOrNamespaceSpecified;
745 case eAddressRangeSpecified:
746 // Not specified yet...
754 SymbolContextSpecifier::Clear()
756 m_module_spec.clear();
757 m_file_spec_ap.reset();
758 m_function_spec.clear();
759 m_class_name.clear();
762 m_address_range_ap.reset();
764 m_type = eNothingSpecified;
768 SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc)
770 if (m_type == eNothingSpecified)
773 if (m_target_sp.get() != sc.target_sp.get())
776 if (m_type & eModuleSpecified)
780 if (m_module_sp.get() != NULL)
782 if (m_module_sp.get() != sc.module_sp.get())
787 FileSpec module_file_spec (m_module_spec.c_str(), false);
788 if (!FileSpec::Equal (module_file_spec, sc.module_sp->GetFileSpec(), false))
793 if (m_type & eFileSpecified)
795 if (m_file_spec_ap.get())
797 // If we don't have a block or a comp_unit, then we aren't going to match a source file.
798 if (sc.block == NULL && sc.comp_unit == NULL)
801 // Check if the block is present, and if so is it inlined:
802 bool was_inlined = false;
803 if (sc.block != NULL)
805 const InlineFunctionInfo *inline_info = sc.block->GetInlinedFunctionInfo();
806 if (inline_info != NULL)
809 if (!FileSpec::Equal (inline_info->GetDeclaration().GetFile(), *(m_file_spec_ap.get()), false))
814 // Next check the comp unit, but only if the SymbolContext was not inlined.
815 if (!was_inlined && sc.comp_unit != NULL)
817 if (!FileSpec::Equal (*(sc.comp_unit), *(m_file_spec_ap.get()), false))
822 if (m_type & eLineStartSpecified
823 || m_type & eLineEndSpecified)
825 if (sc.line_entry.line < m_start_line || sc.line_entry.line > m_end_line)
829 if (m_type & eFunctionSpecified)
831 // First check the current block, and if it is inlined, get the inlined function name:
832 bool was_inlined = false;
833 ConstString func_name(m_function_spec.c_str());
835 if (sc.block != NULL)
837 const InlineFunctionInfo *inline_info = sc.block->GetInlinedFunctionInfo();
838 if (inline_info != NULL)
841 const Mangled &name = inline_info->GetMangled();
842 if (!name.NameMatches (func_name))
846 // If it wasn't inlined, check the name in the function or symbol:
849 if (sc.function != NULL)
851 if (!sc.function->GetMangled().NameMatches(func_name))
854 else if (sc.symbol != NULL)
856 if (!sc.symbol->GetMangled().NameMatches(func_name))
868 SymbolContextSpecifier::AddressMatches(lldb::addr_t addr)
870 if (m_type & eAddressRangeSpecified)
876 Address match_address (addr, NULL);
878 m_target_sp->GetImages().ResolveSymbolContextForAddress(match_address, eSymbolContextEverything, sc);
879 return SymbolContextMatches(sc);
885 SymbolContextSpecifier::GetDescription (Stream *s, lldb::DescriptionLevel level) const
887 char path_str[PATH_MAX + 1];
889 if (m_type == eNothingSpecified)
891 s->Printf ("Nothing specified.\n");
894 if (m_type == eModuleSpecified)
899 m_module_sp->GetFileSpec().GetPath (path_str, PATH_MAX);
900 s->Printf ("Module: %s\n", path_str);
903 s->Printf ("Module: %s\n", m_module_spec.c_str());
906 if (m_type == eFileSpecified && m_file_spec_ap.get() != NULL)
908 m_file_spec_ap->GetPath (path_str, PATH_MAX);
910 s->Printf ("File: %s", path_str);
911 if (m_type == eLineStartSpecified)
913 s->Printf (" from line %zu", m_start_line);
914 if (m_type == eLineEndSpecified)
915 s->Printf ("to line %zu", m_end_line);
917 s->Printf ("to end");
919 else if (m_type == eLineEndSpecified)
921 s->Printf (" from start to line %zu", m_end_line);
926 if (m_type == eLineStartSpecified)
929 s->Printf ("From line %zu", m_start_line);
930 if (m_type == eLineEndSpecified)
931 s->Printf ("to line %zu", m_end_line);
933 s->Printf ("to end");
936 else if (m_type == eLineEndSpecified)
938 s->Printf ("From start to line %zu.\n", m_end_line);
941 if (m_type == eFunctionSpecified)
944 s->Printf ("Function: %s.\n", m_function_spec.c_str());
947 if (m_type == eClassOrNamespaceSpecified)
950 s->Printf ("Class name: %s.\n", m_class_name.c_str());
953 if (m_type == eAddressRangeSpecified && m_address_range_ap.get() != NULL)
956 s->PutCString ("Address range: ");
957 m_address_range_ap->Dump (s, m_target_sp.get(), Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
958 s->PutCString ("\n");
962 //----------------------------------------------------------------------
966 //----------------------------------------------------------------------
969 SymbolContextList::SymbolContextList() :
974 SymbolContextList::~SymbolContextList()
979 SymbolContextList::Append(const SymbolContext& sc)
981 m_symbol_contexts.push_back(sc);
985 SymbolContextList::Append (const SymbolContextList& sc_list)
987 collection::const_iterator pos, end = sc_list.m_symbol_contexts.end();
988 for (pos = sc_list.m_symbol_contexts.begin(); pos != end; ++pos)
989 m_symbol_contexts.push_back (*pos);
994 SymbolContextList::AppendIfUnique (const SymbolContextList& sc_list, bool merge_symbol_into_function)
996 uint32_t unique_sc_add_count = 0;
997 collection::const_iterator pos, end = sc_list.m_symbol_contexts.end();
998 for (pos = sc_list.m_symbol_contexts.begin(); pos != end; ++pos)
1000 if (AppendIfUnique (*pos, merge_symbol_into_function))
1001 ++unique_sc_add_count;
1003 return unique_sc_add_count;
1007 SymbolContextList::AppendIfUnique (const SymbolContext& sc, bool merge_symbol_into_function)
1009 collection::iterator pos, end = m_symbol_contexts.end();
1010 for (pos = m_symbol_contexts.begin(); pos != end; ++pos)
1015 if (merge_symbol_into_function
1016 && sc.symbol != NULL
1017 && sc.comp_unit == NULL
1018 && sc.function == NULL
1020 && sc.line_entry.IsValid() == false)
1022 if (sc.symbol->ValueIsAddress())
1024 for (pos = m_symbol_contexts.begin(); pos != end; ++pos)
1026 // Don't merge symbols into inlined function symbol contexts
1027 if (pos->block && pos->block->GetContainingInlinedBlock())
1032 if (pos->function->GetAddressRange().GetBaseAddress() == sc.symbol->GetAddress())
1034 // Do we already have a function with this symbol?
1035 if (pos->symbol == sc.symbol)
1037 if (pos->symbol == NULL)
1039 pos->symbol = sc.symbol;
1047 m_symbol_contexts.push_back(sc);
1052 SymbolContextList::MergeSymbolContextIntoFunctionContext (const SymbolContext& symbol_sc,
1056 if (symbol_sc.symbol != NULL
1057 && symbol_sc.comp_unit == NULL
1058 && symbol_sc.function == NULL
1059 && symbol_sc.block == NULL
1060 && symbol_sc.line_entry.IsValid() == false)
1062 if (symbol_sc.symbol->ValueIsAddress())
1064 const size_t end = std::min<size_t>(m_symbol_contexts.size(), stop_idx);
1065 for (size_t i=start_idx; i<end; ++i)
1067 const SymbolContext &function_sc = m_symbol_contexts[i];
1068 // Don't merge symbols into inlined function symbol contexts
1069 if (function_sc.block && function_sc.block->GetContainingInlinedBlock())
1072 if (function_sc.function)
1074 if (function_sc.function->GetAddressRange().GetBaseAddress() == symbol_sc.symbol->GetAddress())
1076 // Do we already have a function with this symbol?
1077 if (function_sc.symbol == symbol_sc.symbol)
1078 return true; // Already have a symbol context with this symbol, return true
1080 if (function_sc.symbol == NULL)
1082 // We successfully merged this symbol into an existing symbol context
1083 m_symbol_contexts[i].symbol = symbol_sc.symbol;
1095 SymbolContextList::Clear()
1097 m_symbol_contexts.clear();
1101 SymbolContextList::Dump(Stream *s, Target *target) const
1104 *s << (void *)this << ": ";
1106 s->PutCString("SymbolContextList");
1110 collection::const_iterator pos, end = m_symbol_contexts.end();
1111 for (pos = m_symbol_contexts.begin(); pos != end; ++pos)
1113 //pos->Dump(s, target);
1114 pos->GetDescription(s, eDescriptionLevelVerbose, target);
1120 SymbolContextList::GetContextAtIndex(size_t idx, SymbolContext& sc) const
1122 if (idx < m_symbol_contexts.size())
1124 sc = m_symbol_contexts[idx];
1131 SymbolContextList::GetLastContext(SymbolContext& sc) const
1133 if (!m_symbol_contexts.empty())
1135 sc = m_symbol_contexts.back();
1142 SymbolContextList::RemoveContextAtIndex (size_t idx)
1144 if (idx < m_symbol_contexts.size())
1146 m_symbol_contexts.erase(m_symbol_contexts.begin() + idx);
1153 SymbolContextList::GetSize() const
1155 return m_symbol_contexts.size();
1159 SymbolContextList::NumLineEntriesWithLine (uint32_t line) const
1161 uint32_t match_count = 0;
1162 const size_t size = m_symbol_contexts.size();
1163 for (size_t idx = 0; idx<size; ++idx)
1165 if (m_symbol_contexts[idx].line_entry.line == line)
1172 SymbolContextList::GetDescription(Stream *s,
1173 lldb::DescriptionLevel level,
1174 Target *target) const
1176 const size_t size = m_symbol_contexts.size();
1177 for (size_t idx = 0; idx<size; ++idx)
1178 m_symbol_contexts[idx].GetDescription (s, level, target);
1182 lldb_private::operator== (const SymbolContextList& lhs, const SymbolContextList& rhs)
1184 const uint32_t size = lhs.GetSize();
1185 if (size != rhs.GetSize())
1188 SymbolContext lhs_sc;
1189 SymbolContext rhs_sc;
1190 for (uint32_t i=0; i<size; ++i)
1192 lhs.GetContextAtIndex(i, lhs_sc);
1193 rhs.GetContextAtIndex(i, rhs_sc);
1194 if (lhs_sc != rhs_sc)
1201 lldb_private::operator!= (const SymbolContextList& lhs, const SymbolContextList& rhs)
1203 return !(lhs == rhs);