diff --git a/lldb/include/lldb/API/SBCompileUnit.h b/lldb/include/lldb/API/SBCompileUnit.h index e6aba8286c06..95af3d4722ce 100644 --- a/lldb/include/lldb/API/SBCompileUnit.h +++ b/lldb/include/lldb/API/SBCompileUnit.h @@ -59,6 +59,24 @@ public: uint32_t FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full); + + //------------------------------------------------------------------ + /// Get all types matching \a type_mask from debug info in this + /// compile unit. + /// + /// @param[in] type_mask + /// A bitfield that consists of one or more bits logically OR'ed + /// together from the lldb::TypeClass enumeration. This allows + /// you to request only structure types, or only class, struct + /// and union types. Passing in lldb::eTypeClassAny will return + /// all types found in the debug information for this compile + /// unit. + /// + /// @return + /// A list of types in this compile unit that match \a type_mask + //------------------------------------------------------------------ + lldb::SBTypeList + GetTypes (uint32_t type_mask = lldb::eTypeClassAny); bool operator == (const lldb::SBCompileUnit &rhs) const; diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index c75c4a151d32..53d2d711d8b6 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -199,7 +199,24 @@ public: lldb::SBType GetBasicType(lldb::BasicType type); - + + //------------------------------------------------------------------ + /// Get all types matching \a type_mask from debug info in this + /// module. + /// + /// @param[in] type_mask + /// A bitfield that consists of one or more bits logically OR'ed + /// together from the lldb::TypeClass enumeration. This allows + /// you to request only structure types, or only class, struct + /// and union types. Passing in lldb::eTypeClassAny will return + /// all types found in the debug information for this module. + /// + /// @return + /// A list of types in this module that match \a type_mask + //------------------------------------------------------------------ + lldb::SBTypeList + GetTypes (uint32_t type_mask = lldb::eTypeClassAny); + //------------------------------------------------------------------ /// Get the module version numbers. /// diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index 701ba7bc8a25..78c8f8d3ab4c 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -235,6 +235,8 @@ public: private: std::unique_ptr m_opaque_ap; + friend class SBModule; + friend class SBCompileUnit; }; diff --git a/lldb/include/lldb/Core/MappedHash.h b/lldb/include/lldb/Core/MappedHash.h index dd4999a0d2f5..80d249d4cc9e 100644 --- a/lldb/include/lldb/Core/MappedHash.h +++ b/lldb/include/lldb/Core/MappedHash.h @@ -486,6 +486,10 @@ public: virtual const char * GetStringForKeyType (KeyType key) const = 0; + + virtual bool + ReadHashData (uint32_t hash_data_offset, + HashData &hash_data) const = 0; // This method must be implemented in any subclasses and it must try to // read one "Pair" at the offset pointed to by the "hash_data_offset_ptr" @@ -514,6 +518,27 @@ public: return m_header; } + + void + ForEach (std::function const &callback) const + { + const size_t num_hash_offsets = m_header.hashes_count; + for (size_t i=0; i const &callback) const; + + void + ForEach (std::function const &callback); + bool RemoveTypeWithUID (lldb::user_id_t uid); diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index cfc68f19732a..3b3ff087b665 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -610,7 +610,7 @@ namespace lldb { eTypeClassOther = (1u << 31), // Define a mask that can be used for any type when finding types eTypeClassAny = (0xffffffffu) - }TypeClass; + } TypeClass; typedef enum TemplateArgumentKind { diff --git a/lldb/scripts/Python/interface/SBCompileUnit.i b/lldb/scripts/Python/interface/SBCompileUnit.i index 3bfaf70b997a..a7e76cb1183d 100644 --- a/lldb/scripts/Python/interface/SBCompileUnit.i +++ b/lldb/scripts/Python/interface/SBCompileUnit.i @@ -86,6 +86,26 @@ public: uint32_t FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full); + %feature("docstring", " + //------------------------------------------------------------------ + /// Get all types matching \a type_mask from debug info in this + /// compile unit. + /// + /// @param[in] type_mask + /// A bitfield that consists of one or more bits logically OR'ed + /// together from the lldb::TypeClass enumeration. This allows + /// you to request only structure types, or only class, struct + /// and union types. Passing in lldb::eTypeClassAny will return + /// all types found in the debug information for this compile + /// unit. + /// + /// @return + /// A list of types in this compile unit that match \a type_mask + //------------------------------------------------------------------ + ") GetTypes; + lldb::SBTypeList + GetTypes (uint32_t type_mask = lldb::eTypeClassAny); + bool GetDescription (lldb::SBStream &description); diff --git a/lldb/scripts/Python/interface/SBModule.i b/lldb/scripts/Python/interface/SBModule.i index cb970d6af367..aa2571c1090a 100644 --- a/lldb/scripts/Python/interface/SBModule.i +++ b/lldb/scripts/Python/interface/SBModule.i @@ -225,6 +225,25 @@ public: lldb::SBType GetBasicType(lldb::BasicType type); + %feature("docstring", " + //------------------------------------------------------------------ + /// Get all types matching \a type_mask from debug info in this + /// module. + /// + /// @param[in] type_mask + /// A bitfield that consists of one or more bits logically OR'ed + /// together from the lldb::TypeClass enumeration. This allows + /// you to request only structure types, or only class, struct + /// and union types. Passing in lldb::eTypeClassAny will return + /// all types found in the debug information for this module. + /// + /// @return + /// A list of types in this module that match \a type_mask + //------------------------------------------------------------------ + ") GetTypes; + lldb::SBTypeList + GetTypes (uint32_t type_mask = lldb::eTypeClassAny); + %feature("docstring", " //------------------------------------------------------------------ /// Find global and static variables by name. diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp index f3a8417d7203..9f7487746a85 100644 --- a/lldb/source/API/SBCompileUnit.cpp +++ b/lldb/source/API/SBCompileUnit.cpp @@ -10,10 +10,13 @@ #include "lldb/API/SBCompileUnit.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBStream.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/LineTable.h" -#include "lldb/Core/Log.h" +#include "lldb/Symbol/SymbolVendor.h" +#include "lldb/Symbol/Type.h" using namespace lldb; using namespace lldb_private; @@ -148,12 +151,39 @@ SBCompileUnit::GetNumSupportFiles () const { if (m_opaque_ptr) { - FileSpecList& support_files = m_opaque_ptr->GetSupportFiles (); - return support_files.GetSize(); + FileSpecList& support_files = m_opaque_ptr->GetSupportFiles (); + return support_files.GetSize(); } return 0; } + + +lldb::SBTypeList +SBCompileUnit::GetTypes (uint32_t type_mask) +{ + SBTypeList sb_type_list; + + if (m_opaque_ptr) + { + ModuleSP module_sp (m_opaque_ptr->GetModule()); + if (module_sp) + { + SymbolVendor* vendor = module_sp->GetSymbolVendor(); + if (vendor) + { + TypeList type_list; + vendor->GetTypes (m_opaque_ptr, type_mask, type_list); + sb_type_list.m_opaque_ap->Append(type_list); + } + } + } + return sb_type_list; +} + + + + SBFileSpec SBCompileUnit::GetSupportFileAtIndex (uint32_t idx) const { @@ -162,9 +192,9 @@ SBCompileUnit::GetSupportFileAtIndex (uint32_t idx) const SBFileSpec sb_file_spec; if (m_opaque_ptr) { - FileSpecList &support_files = m_opaque_ptr->GetSupportFiles (); - FileSpec file_spec = support_files.GetFileSpecAtIndex(idx); - sb_file_spec.SetFileSpec(file_spec); + FileSpecList &support_files = m_opaque_ptr->GetSupportFiles (); + FileSpec file_spec = support_files.GetFileSpecAtIndex(idx); + sb_file_spec.SetFileSpec(file_spec); } if (log) diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 3938fa8846d0..47540b6f5114 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -561,6 +561,24 @@ SBModule::FindTypes (const char *type) return retval; } +lldb::SBTypeList +SBModule::GetTypes (uint32_t type_mask) +{ + SBTypeList sb_type_list; + + ModuleSP module_sp (GetSP ()); + if (module_sp) + { + SymbolVendor* vendor = module_sp->GetSymbolVendor(); + if (vendor) + { + TypeList type_list; + vendor->GetTypes (NULL, type_mask, type_list); + sb_type_list.m_opaque_ap->Append(type_list); + } + } + return sb_type_list; +} SBSection SBModule::FindSection (const char *sect_name) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h index 4b8a1fd8a300..c31cbaf3ca20 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -607,9 +607,30 @@ struct DWARFMappedHash return m_string_table.PeekCStr (key); } + virtual bool + ReadHashData (uint32_t hash_data_offset, + HashData &hash_data) const + { + lldb::offset_t offset = hash_data_offset; + offset += 4; // Skip string table offset that contains offset of hash name in .debug_str + const uint32_t count = m_data.GetU32 (&offset); + if (count > 0) + { + hash_data.resize(count); + for (uint32_t i=0; iPrintf("%p: {0x%8.8x} \"%s\"\n", cstr, m_map.GetValueAtIndexUnchecked(i), cstr); } } + +void +NameToDIE::ForEach (std::function const &callback) const +{ + const uint32_t size = m_map.GetSize(); + for (uint32_t i=0; i + #include "lldb/lldb-defines.h" class SymbolFileDWARF; @@ -51,6 +54,9 @@ public: uint32_t cu_end_offset, DIEArray &info_array) const; + void + ForEach (std::function const &callback) const; + protected: lldb_private::UniqueCStringMap m_map; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 392d2c93c3d0..624d45d62620 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -235,6 +235,187 @@ SymbolFileDWARF::GetTypeList () return m_obj_file->GetModule()->GetTypeList(); } +void +SymbolFileDWARF::GetTypes (DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + dw_offset_t min_die_offset, + dw_offset_t max_die_offset, + uint32_t type_mask, + TypeSet &type_set) +{ + if (cu) + { + if (die) + { + const dw_offset_t die_offset = die->GetOffset(); + + if (die_offset >= max_die_offset) + return; + + if (die_offset >= min_die_offset) + { + const dw_tag_t tag = die->Tag(); + + bool add_type = false; + + switch (tag) + { + case DW_TAG_array_type: add_type = (type_mask & eTypeClassArray ) != 0; break; + case DW_TAG_unspecified_type: + case DW_TAG_base_type: add_type = (type_mask & eTypeClassBuiltin ) != 0; break; + case DW_TAG_class_type: add_type = (type_mask & eTypeClassClass ) != 0; break; + case DW_TAG_structure_type: add_type = (type_mask & eTypeClassStruct ) != 0; break; + case DW_TAG_union_type: add_type = (type_mask & eTypeClassUnion ) != 0; break; + case DW_TAG_enumeration_type: add_type = (type_mask & eTypeClassEnumeration ) != 0; break; + case DW_TAG_subroutine_type: + case DW_TAG_subprogram: + case DW_TAG_inlined_subroutine: add_type = (type_mask & eTypeClassFunction ) != 0; break; + case DW_TAG_pointer_type: add_type = (type_mask & eTypeClassPointer ) != 0; break; + case DW_TAG_rvalue_reference_type: + case DW_TAG_reference_type: add_type = (type_mask & eTypeClassReference ) != 0; break; + case DW_TAG_typedef: add_type = (type_mask & eTypeClassTypedef ) != 0; break; + case DW_TAG_ptr_to_member_type: add_type = (type_mask & eTypeClassMemberPointer ) != 0; break; + } + + if (add_type) + { + const bool assert_not_being_parsed = true; + Type *type = ResolveTypeUID (cu, die, assert_not_being_parsed); + if (type) + { + if (type_set.find(type) == type_set.end()) + type_set.insert(type); + } + } + } + + for (const DWARFDebugInfoEntry *child_die = die->GetFirstChild(); + child_die != NULL; + child_die = child_die->GetSibling()) + { + GetTypes (cu, child_die, min_die_offset, max_die_offset, type_mask, type_set); + } + } + } +} + +size_t +SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope, + uint32_t type_mask, + TypeList &type_list) + +{ + TypeSet type_set; + + CompileUnit *comp_unit = NULL; + DWARFCompileUnit* dwarf_cu = NULL; + if (sc_scope) + comp_unit = sc_scope->CalculateSymbolContextCompileUnit(); + + if (comp_unit) + { + dwarf_cu = GetDWARFCompileUnit(comp_unit); + if (dwarf_cu == 0) + return 0; + GetTypes (dwarf_cu, + dwarf_cu->DIE(), + dwarf_cu->GetOffset(), + dwarf_cu->GetNextCompileUnitOffset(), + type_mask, + type_set); + } + else + { + DWARFDebugInfo* info = DebugInfo(); + if (info) + { + const size_t num_cus = info->GetNumCompileUnits(); + for (size_t cu_idx=0; cu_idxGetCompileUnitAtIndex(cu_idx); + if (dwarf_cu) + { + GetTypes (dwarf_cu, + dwarf_cu->DIE(), + 0, + UINT32_MAX, + type_mask, + type_set); + } + } + } + } +// if (m_using_apple_tables) +// { +// DWARFMappedHash::MemoryTable *apple_types = m_apple_types_ap.get(); +// if (apple_types) +// { +// apple_types->ForEach([this, &type_set, apple_types, type_mask](const DWARFMappedHash::DIEInfoArray &die_info_array) -> bool { +// +// for (auto die_info: die_info_array) +// { +// bool add_type = TagMatchesTypeMask (type_mask, 0); +// if (!add_type) +// { +// dw_tag_t tag = die_info.tag; +// if (tag == 0) +// { +// const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtr(die_info.offset, NULL); +// tag = die->Tag(); +// } +// add_type = TagMatchesTypeMask (type_mask, tag); +// } +// if (add_type) +// { +// Type *type = ResolveTypeUID(die_info.offset); +// +// if (type_set.find(type) == type_set.end()) +// type_set.insert(type); +// } +// } +// return true; // Keep iterating +// }); +// } +// } +// else +// { +// if (!m_indexed) +// Index (); +// +// m_type_index.ForEach([this, &type_set, type_mask](const char *name, uint32_t die_offset) -> bool { +// +// bool add_type = TagMatchesTypeMask (type_mask, 0); +// +// if (!add_type) +// { +// const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtr(die_offset, NULL); +// if (die) +// { +// const dw_tag_t tag = die->Tag(); +// add_type = TagMatchesTypeMask (type_mask, tag); +// } +// } +// +// if (add_type) +// { +// Type *type = ResolveTypeUID(die_offset); +// +// if (type_set.find(type) == type_set.end()) +// type_set.insert(type); +// } +// return true; // Keep iterating +// }); +// } + + size_t num_types_added = 0; + for (Type *type : type_set) + { + type_list.Insert (type->shared_from_this()); + ++num_types_added; + } + return num_types_added; +} + //---------------------------------------------------------------------- // Gets the first parent that is a lexical block, function or inlined diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 87f86b80bbb2..0370bc3f5950 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -14,6 +14,7 @@ // C++ Includes #include #include +#include #include // Other libraries and framework includes @@ -121,6 +122,10 @@ public: virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types); virtual lldb_private::TypeList * GetTypeList (); + virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope, + uint32_t type_mask, + lldb_private::TypeList &type_list); + virtual lldb_private::ClangASTContext & GetClangASTContext (); @@ -545,6 +550,16 @@ protected: bool FixupAddress (lldb_private::Address &addr); + typedef std::set TypeSet; + + void + GetTypes (DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + dw_offset_t min_die_offset, + dw_offset_t max_die_offset, + uint32_t type_mask, + TypeSet &type_set); + lldb::ModuleWP m_debug_map_module_wp; SymbolFileDWARFDebugMap * m_debug_map_symfile; clang::TranslationUnitDecl * m_clang_tu_decl; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 61f95f355cf3..8816b3ea9252 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1120,6 +1120,43 @@ SymbolFileDWARFDebugMap::FindFunctions (const RegularExpression& regex, bool inc return sc_list.GetSize() - initial_size; } +size_t +SymbolFileDWARFDebugMap::GetTypes (SymbolContextScope *sc_scope, + uint32_t type_mask, + TypeList &type_list) +{ + Timer scoped_timer (__PRETTY_FUNCTION__, + "SymbolFileDWARFDebugMap::GetTypes (type_mask = 0x%8.8x)", + type_mask); + + + uint32_t initial_size = type_list.GetSize(); + SymbolFileDWARF *oso_dwarf = NULL; + if (sc_scope) + { + SymbolContext sc; + sc_scope->CalculateSymbolContext(&sc); + + CompileUnitInfo *cu_info = GetCompUnitInfo (sc); + if (cu_info) + { + oso_dwarf = GetSymbolFileByCompUnitInfo (cu_info); + if (oso_dwarf) + oso_dwarf->GetTypes (sc_scope, type_mask, type_list); + } + } + else + { + uint32_t oso_idx = 0; + while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL) + { + oso_dwarf->GetTypes (sc_scope, type_mask, type_list); + } + } + return type_list.GetSize() - initial_size; +} + + TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 07f8e415c788..9db2a93f63a6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -85,9 +85,12 @@ public: virtual uint32_t FindFunctions (const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list); virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types); virtual lldb_private::ClangNamespaceDecl - FindNamespace (const lldb_private::SymbolContext& sc, - const lldb_private::ConstString &name, - const lldb_private::ClangNamespaceDecl *parent_namespace_decl); + FindNamespace (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name, + const lldb_private::ClangNamespaceDecl *parent_namespace_decl); + virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope, + uint32_t type_mask, + lldb_private::TypeList &type_list); //------------------------------------------------------------------ diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index 46460fe79d53..28078693b350 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -60,6 +60,12 @@ SymbolFileSymtab::CreateInstance (ObjectFile* obj_file) return new SymbolFileSymtab(obj_file); } +size_t +SymbolFileSymtab::GetTypes (SymbolContextScope *sc_scope, uint32_t type_mask, lldb_private::TypeList &type_list) +{ + return 0; +} + SymbolFileSymtab::SymbolFileSymtab(ObjectFile* obj_file) : SymbolFile(obj_file), m_source_indexes(), diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h index ede3447ee997..99f0eb16c607 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h @@ -102,8 +102,10 @@ public: virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc,const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types); -// virtual uint32_t -// FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::TypeList& types); + virtual size_t + GetTypes (lldb_private::SymbolContextScope *sc_scope, + uint32_t type_mask, + lldb_private::TypeList &type_list); virtual lldb_private::ClangNamespaceDecl FindNamespace (const lldb_private::SymbolContext& sc, diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp index c39261903fa7..7b49ab22feda 100644 --- a/lldb/source/Symbol/SymbolVendor.cpp +++ b/lldb/source/Symbol/SymbolVendor.cpp @@ -352,6 +352,21 @@ SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const return 0; } +size_t +SymbolVendor::GetTypes (SymbolContextScope *sc_scope, + uint32_t type_mask, + lldb_private::TypeList &type_list) +{ + ModuleSP module_sp(GetModule()); + if (module_sp) + { + lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + if (m_sym_file_ap.get()) + return m_sym_file_ap->GetTypes (sc_scope, type_mask, type_list); + } + return 0; +} + ClangNamespaceDecl SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *parent_namespace_decl) { diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index 4d540c8dd1bf..0646a40b5b43 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -33,6 +33,33 @@ using namespace lldb; using namespace lldb_private; +class TypeAppendVisitor +{ +public: + TypeAppendVisitor(TypeListImpl &type_list) : + m_type_list(type_list) + { + } + + bool + operator() (const lldb::TypeSP& type) + { + m_type_list.Append(TypeImplSP(new TypeImpl(type))); + return true; + } + +private: + TypeListImpl &m_type_list; +}; + +void +TypeListImpl::Append (const lldb_private::TypeList &type_list) +{ + TypeAppendVisitor cb(*this); + type_list.ForEach(cb); +} + + Type * SymbolFileType::GetType () { diff --git a/lldb/source/Symbol/TypeList.cpp b/lldb/source/Symbol/TypeList.cpp index 7c1d969b84ed..df0723e48f2b 100644 --- a/lldb/source/Symbol/TypeList.cpp +++ b/lldb/source/Symbol/TypeList.cpp @@ -135,6 +135,27 @@ TypeList::GetTypeAtIndex(uint32_t idx) return TypeSP(); } +void +TypeList::ForEach (std::function const &callback) const +{ + for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) + { + if (!callback(pos->second)) + break; + } +} + +void +TypeList::ForEach (std::function const &callback) +{ + for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) + { + if (!callback(pos->second)) + break; + } +} + + bool TypeList::RemoveTypeWithUID (user_id_t uid) {