Never mind, top of tree LLDB is working correctly. I ran our Apple built LLDB that had a different version of this -gmodule fix for an Apple specific version we did and it shows the same issue so I was led to believe this existed for a while now, but it is definitely due to the -gmodule patch.
Greg > On Dec 2, 2015, at 11:26 AM, Greg Clayton via lldb-commits > <lldb-commits@lists.llvm.org> wrote: > > So I was able to repro this with the following code: > > #include <stdio.h> > #include <stdint.h> > > namespace a > { > struct S > { > int s; > int ss; > }; > } > > int main (int argc, char const *argv[], char const *envp[]) > { > a::S s = { 11, 22 }; > puts("stop here"); // evaluate expression: expression struct S { int a; > S(int _a) : a(_a){} }; S(12) > return 0; > } > > > Then do: > > lldb a.out > (lldb) b /stop here/ > (lldb) r > (lldb) expression struct S { int a; S(int _a) : a(_a){} }; S(12) > (S) $0 = (s = 12, ss = 0) > > Can you verify that this fails even with your LLDB that has my change backed > out on linux? If you can reproduce this, then my change didn't cause it, and > we need to fix the TestDataFormatterSynthVal.py test case and I will file a > bug on our expression parser to get this fixed. > > Greg > > >> On Dec 2, 2015, at 11:20 AM, Tamas Berghammer <tbergham...@google.com> wrote: >> >> The source code is the inferior for TestDataFormatterSynthVal >> (https://github.com/llvm-mirror/lldb/blob/fc6c6b9f1aa893b7fd1bd04ae9f05ff3f82d63c2/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp) >> what doesn't refer to anything in the std namespace and have no using >> directives either. >> >> On Wed, Dec 2, 2015 at 7:01 PM Greg Clayton <gclay...@apple.com> wrote: >> So the question is why is "S" being found in "std" when we are essentially >> looking for "::S"?? Do we have a "using namespace std;" in the source? We >> recently added support for using all of the using directives in the user >> code so it might be doing a "using namespace std;" into the expression due >> to the source file having it... >> >>> On Dec 2, 2015, at 3:52 AM, Tamas Berghammer <tbergham...@google.com> wrote: >>> >>> Hi Greg, >>> >>> I reverted this CL as it regressed TestDataFormatterSynthVal.py on the >>> Linux buildbot. >>> >>> The problem is that when we evaluate the "expression struct S { myInt >>> theInt{12}; }; S()" command then the return type is displayed as "std::S" >>> instead of displaying it as the type defined on the command line. >>> >>> The definition for the conflicting type ("target modul lookup -t S -A"): >>> /usr/lib/x86_64-linux-gnu/libstdc++.so.6: >>> id = {0x0021550c}, name = "std::S", byte-size = 8, decl = >>> string-inst.cc:43, compiler_type = "typedef std::S" >>> typedef 'std::S': id = {0x00213434}, name = "basic_string<char, >>> std::char_traits<char>, std::allocator<char> >", qualified = >>> "std::basic_string<char, std::char_traits<char>, std::allocator<char> >", >>> byte-size = 8, decl = basic_string.h:112, compiler_type = "class >>> basic_string { >>> <Members omitted, I can send it to you if you need them> >>> } >>> >>> If I change the name of the type we define in the expression to something >>> not conflicting with a type name in the std namespace then it works fine >>> but it should work even in case of conflicting types as they are leave in >>> different namespaces and it also worked before your change. >>> >>> Currently I don't fully understand your change but please let me know if I >>> can help you to figure out why the test is failing on Linux. >>> >>> Thanks, >>> Tamas >>> >>> On Wed, Dec 2, 2015 at 12:46 AM Greg Clayton via lldb-commits >>> <lldb-commits@lists.llvm.org> wrote: >>> Author: gclayton >>> Date: Tue Dec 1 18:43:32 2015 >>> New Revision: 254476 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=254476&view=rev >>> Log: >>> Added support for -gmodule debugging when debug info is left in the .o >>> files on Darwin. >>> >>> This is done by finding the types that are forward declarations that come >>> from a module, and loading that module's debug info in a separate >>> lldb_private::Module, and copying the type over into the current module >>> using a ClangASTImporter object. ClangASTImporter objects are already used >>> to copy types from on clang::ASTContext to another for expressions so the >>> type copying code has been around for a while. >>> >>> A new FindTypes variant was added to SymbolVendor and SymbolFile: >>> >>> size_t >>> SymbolVendor::FindTypes (const std::vector<CompilerContext> &context, bool >>> append, TypeMap& types); >>> >>> size_t >>> SymbolVendor::FindTypes (const std::vector<CompilerContext> &context, bool >>> append, TypeMap& types); >>> >>> The CompilerContext is a way to represent the exact context of a type and >>> pass it through an agnostic API boundary so that we can find that exact >>> context elsewhere in another file. This was required here because we can >>> have a module that has submodules, both of which have a "foo" type. >>> >>> I am not able to add tests for this yet as we currently don't build our >>> C/C++/ObjC binaries with the clang binary that we build. There are some >>> driver issues where it can't find the header files for the C and C++ >>> standard library which makes compiling these tests hard. We can't also >>> guarantee that if we are building with clang that it supporst the exact >>> format of -gmodule debugging that we are trying to test. We have had other >>> versions of clang that had a different implementation of -gmodule debugging >>> that we are no longer supporting, so we can't enable tests if we are >>> building with clang without compiling something and looking at the >>> structure of the DWARF that was generated to ensure that it is the format >>> we can actually use. >>> >>> >>> Modified: >>> lldb/trunk/include/lldb/Symbol/ClangASTContext.h >>> lldb/trunk/include/lldb/Symbol/ClangASTImporter.h >>> lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h >>> lldb/trunk/include/lldb/Symbol/SymbolFile.h >>> lldb/trunk/include/lldb/Symbol/SymbolVendor.h >>> lldb/trunk/include/lldb/Symbol/Type.h >>> lldb/trunk/include/lldb/lldb-forward.h >>> lldb/trunk/include/lldb/lldb-private-enumerations.h >>> >>> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py >>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h >>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp >>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h >>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp >>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h >>> lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp >>> lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h >>> lldb/trunk/source/Symbol/ClangASTContext.cpp >>> lldb/trunk/source/Symbol/ClangASTImporter.cpp >>> lldb/trunk/source/Symbol/ClangExternalASTSourceCallbacks.cpp >>> lldb/trunk/source/Symbol/SymbolFile.cpp >>> lldb/trunk/source/Symbol/SymbolVendor.cpp >>> lldb/trunk/source/Symbol/Type.cpp >>> >>> Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) >>> +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Dec 1 18:43:32 >>> 2015 >>> @@ -1006,10 +1006,18 @@ public: >>> lldb::AccessType access, >>> bool is_artificial); >>> >>> - bool >>> + static bool >>> SetHasExternalStorage (lldb::opaque_compiler_type_t type, bool >>> has_extern); >>> >>> - >>> + >>> + static bool >>> + CanImport (const CompilerType &type, lldb_private::ClangASTImporter >>> &importer); >>> + >>> + static bool >>> + Import (const CompilerType &type, lldb_private::ClangASTImporter >>> &importer); >>> + >>> + static bool >>> + GetHasExternalStorage (const CompilerType &type); >>> //------------------------------------------------------------------ >>> // Tag Declarations >>> //------------------------------------------------------------------ >>> @@ -1092,13 +1100,19 @@ public: >>> >>> void >>> DumpTypeDescription (lldb::opaque_compiler_type_t type, Stream *s) >>> override; >>> - >>> + >>> + static void >>> + DumpTypeName (const CompilerType &type); >>> + >>> static clang::EnumDecl * >>> GetAsEnumDecl (const CompilerType& type); >>> >>> static clang::RecordDecl * >>> GetAsRecordDecl (const CompilerType& type); >>> - >>> + >>> + static clang::TagDecl * >>> + GetAsTagDecl (const CompilerType& type); >>> + >>> clang::CXXRecordDecl * >>> GetAsCXXRecordDecl (lldb::opaque_compiler_type_t type); >>> >>> @@ -1109,9 +1123,12 @@ public: >>> GetQualType (const CompilerType& type) >>> { >>> // Make sure we have a clang type before making a clang::QualType >>> - ClangASTContext *ast = >>> llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem()); >>> - if (ast) >>> - return >>> clang::QualType::getFromOpaquePtr(type.GetOpaqueQualType()); >>> + if (type.GetOpaqueQualType()) >>> + { >>> + ClangASTContext *ast = >>> llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem()); >>> + if (ast) >>> + return >>> clang::QualType::getFromOpaquePtr(type.GetOpaqueQualType()); >>> + } >>> return clang::QualType(); >>> } >>> >>> >>> Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) >>> +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Tue Dec 1 18:43:32 >>> 2015 >>> @@ -107,7 +107,11 @@ public: >>> CopyType (clang::ASTContext *dst_ctx, >>> clang::ASTContext *src_ctx, >>> lldb::opaque_compiler_type_t type); >>> - >>> + >>> + CompilerType >>> + CopyType (ClangASTContext &dst, >>> + const CompilerType &src_type); >>> + >>> clang::Decl * >>> CopyDecl (clang::ASTContext *dst_ctx, >>> clang::ASTContext *src_ctx, >>> @@ -134,7 +138,10 @@ public: >>> >>> bool >>> CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl); >>> - >>> + >>> + bool >>> + CompleteAndFetchChildren (clang::QualType type); >>> + >>> bool >>> RequireCompleteType (clang::QualType type); >>> >>> >>> Modified: lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h >>> (original) >>> +++ lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h Tue >>> Dec 1 18:43:32 2015 >>> @@ -97,6 +97,11 @@ public: >>> { >>> } >>> >>> + void >>> + FindExternalLexicalDecls(const clang::DeclContext *DC, >>> + llvm::function_ref<bool(clang::Decl::Kind)> >>> IsKindWeWant, >>> + llvm::SmallVectorImpl<clang::Decl *> &Result) >>> override; >>> + >>> bool FindExternalVisibleDeclsByName(const clang::DeclContext *decl_ctx, >>> clang::DeclarationName decl_name) override; >>> >>> void CompleteType(clang::TagDecl *tag_decl) override; >>> >>> Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original) >>> +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Tue Dec 1 18:43:32 2015 >>> @@ -15,7 +15,6 @@ >>> #include "lldb/Symbol/CompilerType.h" >>> #include "lldb/Symbol/CompilerDecl.h" >>> #include "lldb/Symbol/CompilerDeclContext.h" >>> - >>> #include "lldb/Symbol/Type.h" >>> >>> namespace lldb_private { >>> @@ -142,6 +141,8 @@ public: >>> virtual uint32_t FindFunctions (const ConstString &name, const >>> CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool >>> include_inlines, bool append, SymbolContextList& sc_list); >>> virtual uint32_t FindFunctions (const RegularExpression& regex, >>> bool include_inlines, bool append, SymbolContextList& sc_list); >>> virtual uint32_t FindTypes (const SymbolContext& sc, const >>> ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, >>> uint32_t max_matches, TypeMap& types); >>> + virtual size_t FindTypes (const std::vector<CompilerContext> >>> &context, bool append, TypeMap& types); >>> + >>> // virtual uint32_t FindTypes (const SymbolContext& sc, const >>> RegularExpression& regex, bool append, uint32_t max_matches, TypeList& >>> types) = 0; >>> virtual TypeList * GetTypeList (); >>> virtual size_t GetTypes (lldb_private::SymbolContextScope >>> *sc_scope, >>> >>> Modified: lldb/trunk/include/lldb/Symbol/SymbolVendor.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolVendor.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/Symbol/SymbolVendor.h (original) >>> +++ lldb/trunk/include/lldb/Symbol/SymbolVendor.h Tue Dec 1 18:43:32 2015 >>> @@ -128,6 +128,9 @@ public: >>> size_t max_matches, >>> TypeMap& types); >>> >>> + virtual size_t >>> + FindTypes (const std::vector<CompilerContext> &context, bool append, >>> TypeMap& types); >>> + >>> virtual CompilerDeclContext >>> FindNamespace (const SymbolContext& sc, >>> const ConstString &name, >>> >>> Modified: lldb/trunk/include/lldb/Symbol/Type.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/Symbol/Type.h (original) >>> +++ lldb/trunk/include/lldb/Symbol/Type.h Tue Dec 1 18:43:32 2015 >>> @@ -24,6 +24,31 @@ >>> >>> namespace lldb_private { >>> >>> +//---------------------------------------------------------------------- >>> +// CompilerContext allows an array of these items to be passed to >>> +// perform detailed lookups in SymbolVendor and SymbolFile functions. >>> +//---------------------------------------------------------------------- >>> +struct CompilerContext >>> +{ >>> + CompilerContext (CompilerContextKind t, const ConstString &n) : >>> + type(t), >>> + name(n) >>> + { >>> + } >>> + >>> + bool >>> + operator == (const CompilerContext &rhs) const >>> + { >>> + return type == rhs.type && name == rhs.name; >>> + } >>> + >>> + void >>> + Dump () const; >>> + >>> + CompilerContextKind type; >>> + ConstString name; >>> +}; >>> + >>> class SymbolFileType : >>> public std::enable_shared_from_this<SymbolFileType>, >>> public UserID >>> @@ -35,6 +60,9 @@ class SymbolFileType : >>> { >>> } >>> >>> + SymbolFileType (SymbolFile &symbol_file, const lldb::TypeSP >>> &type_sp); >>> + >>> + >>> ~SymbolFileType () >>> { >>> } >>> >>> Modified: lldb/trunk/include/lldb/lldb-forward.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/lldb-forward.h (original) >>> +++ lldb/trunk/include/lldb/lldb-forward.h Tue Dec 1 18:43:32 2015 >>> @@ -62,6 +62,7 @@ class CommandObject; >>> class CommandReturnObject; >>> class Communication; >>> class CompactUnwindInfo; >>> +struct CompilerContext; >>> class CompilerDecl; >>> class CompilerDeclContext; >>> class CompilerType; >>> >>> Modified: lldb/trunk/include/lldb/lldb-private-enumerations.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-enumerations.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/lldb-private-enumerations.h (original) >>> +++ lldb/trunk/include/lldb/lldb-private-enumerations.h Tue Dec 1 18:43:32 >>> 2015 >>> @@ -241,6 +241,25 @@ enum class TypeValidatorResult : bool { >>> Success = true, >>> Failure = false >>> }; >>> + >>> +//---------------------------------------------------------------------- >>> +// Enumerations that can be used to specify scopes types when looking up >>> +// types. >>> +//---------------------------------------------------------------------- >>> +enum class CompilerContextKind >>> +{ >>> + Invalid = 0, >>> + TranslationUnit, >>> + Module, >>> + Namespace, >>> + Class, >>> + Structure, >>> + Union, >>> + Function, >>> + Variable, >>> + Enumeration, >>> + Typedef >>> +}; >>> >>> } // namespace lldb_private >>> >>> >>> Modified: >>> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- >>> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py >>> (original) >>> +++ >>> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py >>> Tue Dec 1 18:43:32 2015 >>> @@ -14,11 +14,11 @@ class TestCppIncompleteTypes(TestBase): >>> >>> value_f = frame.EvaluateExpression("f") >>> self.assertTrue(value_f.IsValid(), "'expr f' results in a valid >>> SBValue object") >>> - self.assertFalse(value_f.GetError().Success(), "'expr f' results >>> in an error, but LLDB does not crash") >>> + self.assertTrue(value_f.GetError().Success(), "'expr f' is >>> successful") >>> >>> value_a = frame.EvaluateExpression("a") >>> self.assertTrue(value_a.IsValid(), "'expr a' results in a valid >>> SBValue object") >>> - self.assertFalse(value_a.GetError().Success(), "'expr a' results >>> in an error, but LLDB does not crash") >>> + self.assertTrue(value_a.GetError().Success(), "'expr a' is >>> successful") >>> >>> @skipIfGcc >>> @skipIfWindows # Clang on Windows asserts in external record layout in >>> this case. >>> >>> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h (original) >>> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h Tue Dec 1 >>> 18:43:32 2015 >>> @@ -33,6 +33,18 @@ public: >>> const DWARFDIE &die) = 0; >>> >>> virtual bool >>> + CanCompleteType (const lldb_private::CompilerType &compiler_type) >>> + { >>> + return false; >>> + } >>> + >>> + virtual bool >>> + CompleteType (const lldb_private::CompilerType &compiler_type) >>> + { >>> + return false; >>> + } >>> + >>> + virtual bool >>> CompleteTypeFromDWARF (const DWARFDIE &die, >>> lldb_private::Type *type, >>> lldb_private::CompilerType &compiler_type) = 0; >>> >>> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp >>> (original) >>> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Tue >>> Dec 1 18:43:32 2015 >>> @@ -24,11 +24,14 @@ >>> #include "lldb/Core/StreamString.h" >>> #include "lldb/Core/Value.h" >>> #include "lldb/Host/Host.h" >>> +#include "lldb/Symbol/ClangASTImporter.h" >>> #include "lldb/Symbol/ClangExternalASTSourceCommon.h" >>> #include "lldb/Symbol/CompileUnit.h" >>> #include "lldb/Symbol/Function.h" >>> #include "lldb/Symbol/ObjectFile.h" >>> +#include "lldb/Symbol/SymbolVendor.h" >>> #include "lldb/Symbol/TypeList.h" >>> +#include "lldb/Symbol/TypeMap.h" >>> #include "lldb/Target/Language.h" >>> #include "Plugins/Language/ObjC/ObjCLanguage.h" >>> >>> @@ -114,6 +117,78 @@ struct BitfieldInfo >>> } >>> }; >>> >>> + >>> +ClangASTImporter & >>> +DWARFASTParserClang::GetClangASTImporter() >>> +{ >>> + if (!m_clang_ast_importer_ap) >>> + { >>> + m_clang_ast_importer_ap.reset (new ClangASTImporter); >>> + } >>> + return *m_clang_ast_importer_ap; >>> +} >>> + >>> + >>> +TypeSP >>> +DWARFASTParserClang::ParseTypeFromDWO (const DWARFDIE &die, Log *log) >>> +{ >>> + ModuleSP dwo_module_sp = die.GetContainingDWOModule(); >>> + if (dwo_module_sp) >>> + { >>> + // This type comes from an external DWO module >>> + std::vector<CompilerContext> dwo_context; >>> + die.GetDWOContext(dwo_context); >>> + TypeMap dwo_types; >>> + if (dwo_module_sp->GetSymbolVendor()->FindTypes(dwo_context, true, >>> dwo_types)) >>> + { >>> + const size_t num_dwo_types = dwo_types.GetSize(); >>> + if (num_dwo_types == 1) >>> + { >>> + // We found a real definition for this type elsewhere >>> + // so lets use it and cache the fact that we found >>> + // a complete type for this die >>> + TypeSP dwo_type_sp = dwo_types.GetTypeAtIndex(0); >>> + if (dwo_type_sp) >>> + { >>> + lldb_private::CompilerType dwo_type = >>> dwo_type_sp->GetForwardCompilerType(); >>> + >>> + lldb_private::CompilerType type = >>> GetClangASTImporter().CopyType (m_ast, dwo_type); >>> + >>> + //printf ("copied_qual_type: ast = %p, clang_type = >>> %p, name = '%s'\n", m_ast, copied_qual_type.getAsOpaquePtr(), >>> external_type->GetName().GetCString()); >>> + if (type) >>> + { >>> + SymbolFileDWARF *dwarf = die.GetDWARF(); >>> + TypeSP type_sp (new Type (die.GetID(), >>> + dwarf, >>> + dwo_type_sp->GetName(), >>> + >>> dwo_type_sp->GetByteSize(), >>> + NULL, >>> + LLDB_INVALID_UID, >>> + Type::eEncodingInvalid, >>> + >>> &dwo_type_sp->GetDeclaration(), >>> + type, >>> + >>> Type::eResolveStateForward)); >>> + >>> + dwarf->GetTypeList()->Insert(type_sp); >>> + dwarf->GetDIEToType()[die.GetDIE()] = >>> type_sp.get(); >>> + clang::TagDecl *tag_decl = >>> ClangASTContext::GetAsTagDecl(type); >>> + if (tag_decl) >>> + LinkDeclContextToDIE(tag_decl, die); >>> + else >>> + { >>> + clang::DeclContext *defn_decl_ctx = >>> GetCachedClangDeclContextForDIE(die); >>> + if (defn_decl_ctx) >>> + LinkDeclContextToDIE(defn_decl_ctx, die); >>> + } >>> + return type_sp; >>> + } >>> + } >>> + } >>> + } >>> + } >>> + return TypeSP(); >>> +} >>> + >>> TypeSP >>> DWARFASTParserClang::ParseTypeFromDWARF (const SymbolContext& sc, >>> const DWARFDIE &die, >>> @@ -487,15 +562,15 @@ DWARFASTParserClang::ParseTypeFromDWARF >>> if >>> (dwarf->GetUniqueDWARFASTTypeMap().Find(type_name_const_str, die, decl, >>> >>> byte_size_valid ? byte_size : -1, >>> >>> *unique_ast_entry_ap)) >>> - { >>> - type_sp = unique_ast_entry_ap->m_type_sp; >>> - if (type_sp) >>> { >>> - dwarf->GetDIEToType()[die.GetDIE()] = >>> type_sp.get(); >>> - return type_sp; >>> + type_sp = unique_ast_entry_ap->m_type_sp; >>> + if (type_sp) >>> + { >>> + dwarf->GetDIEToType()[die.GetDIE()] = >>> type_sp.get(); >>> + return type_sp; >>> + } >>> } >>> } >>> - } >>> } >>> >>> DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", >>> die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr); >>> @@ -600,6 +675,11 @@ DWARFASTParserClang::ParseTypeFromDWARF >>> >>> type_name_cstr); >>> } >>> >>> + // See if the type comes from a DWO module and if >>> so, track down that type. >>> + type_sp = ParseTypeFromDWO(die, log); >>> + if (type_sp) >>> + return type_sp; >>> + >>> DWARFDeclContext die_decl_ctx; >>> die.GetDWARFDeclContext(die_decl_ctx); >>> >>> @@ -833,7 +913,7 @@ DWARFASTParserClang::ParseTypeFromDWARF >>> case DW_AT_type: >>> encoding_form = form_value; break; >>> case DW_AT_byte_size: byte_size = >>> form_value.Unsigned(); break; >>> case DW_AT_accessibility: break; >>> //accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; >>> - case DW_AT_declaration: break; >>> //is_forward_declaration = form_value.Boolean(); break; >>> + case DW_AT_declaration: >>> is_forward_declaration = form_value.Boolean(); break; >>> case DW_AT_allocated: >>> case DW_AT_associated: >>> case DW_AT_bit_stride: >>> @@ -850,6 +930,54 @@ DWARFASTParserClang::ParseTypeFromDWARF >>> } >>> } >>> >>> + if (is_forward_declaration) >>> + { >>> + type_sp = ParseTypeFromDWO(die, log); >>> + if (type_sp) >>> + return type_sp; >>> + >>> + DWARFDeclContext die_decl_ctx; >>> + die.GetDWARFDeclContext(die_decl_ctx); >>> + >>> + type_sp = >>> dwarf->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx); >>> + >>> + if (!type_sp) >>> + { >>> + SymbolFileDWARFDebugMap *debug_map_symfile >>> = dwarf->GetDebugMapSymfile(); >>> + if (debug_map_symfile) >>> + { >>> + // We weren't able to find a full >>> declaration in >>> + // this DWARF, see if we have a >>> declaration anywhere >>> + // else... >>> + type_sp = >>> debug_map_symfile->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx); >>> + } >>> + } >>> + >>> + if (type_sp) >>> + { >>> + if (log) >>> + { >>> + >>> dwarf->GetObjectFile()->GetModule()->LogMessage (log, >>> + >>> "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward >>> declaration, complete type is 0x%8.8" PRIx64, >>> + >>> static_cast<void*>(this), >>> + >>> die.GetOffset(), >>> + >>> DW_TAG_value_to_name(tag), >>> + >>> type_name_cstr, >>> + >>> type_sp->GetID()); >>> + } >>> + >>> + // We found a real definition for this >>> type elsewhere >>> + // so lets use it and cache the fact that >>> we found >>> + // a complete type for this die >>> + dwarf->GetDIEToType()[die.GetDIE()] = >>> type_sp.get(); >>> + clang::DeclContext *defn_decl_ctx = >>> GetCachedClangDeclContextForDIE( >>> + >>> >>> dwarf->DebugInfo()->GetDIE(DIERef(type_sp->GetID()))); >>> + if (defn_decl_ctx) >>> + LinkDeclContextToDIE(defn_decl_ctx, >>> die); >>> + return type_sp; >>> + } >>> + >>> + } >>> DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", >>> die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr); >>> >>> CompilerType enumerator_clang_type; >>> @@ -1130,7 +1258,7 @@ DWARFASTParserClang::ParseTypeFromDWARF >>> if (class_type) >>> { >>> bool alternate_defn = false; >>> - if (class_type->GetID() != >>> decl_ctx_die.GetID()) >>> + if (class_type->GetID() != >>> decl_ctx_die.GetID() || decl_ctx_die.GetContainingDWOModuleDIE()) >>> { >>> alternate_defn = true; >>> >>> @@ -1798,6 +1926,33 @@ DWARFASTParserClang::ParseTemplateParame >>> } >>> >>> bool >>> +DWARFASTParserClang::CanCompleteType (const lldb_private::CompilerType >>> &compiler_type) >>> +{ >>> + if (m_clang_ast_importer_ap) >>> + return ClangASTContext::CanImport(compiler_type, >>> GetClangASTImporter()); >>> + else >>> + return false; >>> +} >>> + >>> +bool >>> +DWARFASTParserClang::CompleteType (const lldb_private::CompilerType >>> &compiler_type) >>> +{ >>> + if (CanCompleteType(compiler_type)) >>> + { >>> + if (ClangASTContext::Import(compiler_type, GetClangASTImporter())) >>> + { >>> + >>> ClangASTContext::CompleteTagDeclarationDefinition(compiler_type); >>> + return true; >>> + } >>> + else >>> + { >>> + ClangASTContext::SetHasExternalStorage >>> (compiler_type.GetOpaqueQualType(), false); >>> + } >>> + } >>> + return false; >>> +} >>> + >>> +bool >>> DWARFASTParserClang::CompleteTypeFromDWARF (const DWARFDIE &die, >>> lldb_private::Type *type, >>> CompilerType &clang_type) >>> @@ -1868,25 +2023,17 @@ DWARFASTParserClang::CompleteTypeFromDWA >>> DWARFDIECollection member_function_dies; >>> >>> DelayedPropertyList delayed_properties; >>> - if (!ParseChildMembers (sc, >>> - die, >>> - clang_type, >>> - class_language, >>> - base_classes, >>> - member_accessibilities, >>> - member_function_dies, >>> - delayed_properties, >>> - default_accessibility, >>> - is_a_class, >>> - layout_info)) >>> - { >>> - auto module = dwarf->GetObjectFile()->GetModule(); >>> - module->ReportError (":: Class %s has members with >>> incomplete type.", die.GetName()); >>> - if (die.GetCU()->GetProducer() == >>> DWARFCompileUnit::eProducerClang) >>> - module->ReportError(":: Try compiling the >>> source file with -fno-limit-debug-info."); >>> - >>> - return false; >>> - } >>> + ParseChildMembers (sc, >>> + die, >>> + clang_type, >>> + class_language, >>> + base_classes, >>> + member_accessibilities, >>> + member_function_dies, >>> + delayed_properties, >>> + default_accessibility, >>> + is_a_class, >>> + layout_info); >>> >>> // Now parse any methods if there were any... >>> size_t num_functions = member_function_dies.Size(); >>> @@ -1977,7 +2124,14 @@ DWARFASTParserClang::CompleteTypeFromDWA >>> if (die.GetCU()->GetProducer() == >>> DWARFCompileUnit::eProducerClang) >>> module->ReportError (":: Try >>> compiling the source file with -fno-limit-debug-info."); >>> >>> - return false; >>> + // We have no choice other than to >>> pretend that the base class >>> + // is complete. If we don't do this, >>> clang will crash when we >>> + // call setBases() inside of >>> "clang_type.SetBaseClassesForClassType()" >>> + // below. Since we provide layout >>> assistance, all ivars in this >>> + // class and other classes will be >>> fine, this is the best we can do >>> + // short of crashing. >>> + >>> ClangASTContext::StartTagDeclarationDefinition (base_class_type); >>> + >>> ClangASTContext::CompleteTagDeclarationDefinition (base_class_type); >>> } >>> } >>> } >>> @@ -2420,7 +2574,6 @@ DWARFASTParserClang::ParseChildMembers ( >>> if (!parent_die) >>> return 0; >>> >>> - uint32_t incomplete_member_info_count = 0; >>> uint32_t member_idx = 0; >>> BitfieldInfo last_field_info; >>> >>> @@ -2754,8 +2907,8 @@ DWARFASTParserClang::ParseChildMembers ( >>> } >>> >>> CompilerType member_clang_type = >>> member_type->GetLayoutCompilerType (); >>> - if (!member_clang_type.IsCompleteType() && >>> !member_clang_type.GetCompleteType()) >>> - incomplete_member_info_count += 1; >>> + if (!member_clang_type.IsCompleteType()) >>> + member_clang_type.GetCompleteType(); >>> >>> { >>> // Older versions of clang emit >>> array[0] and array[1] in the same way (<rdar://problem/12566646>). >>> @@ -2789,6 +2942,30 @@ DWARFASTParserClang::ParseChildMembers ( >>> } >>> } >>> >>> + if >>> (ClangASTContext::IsCXXClassType(member_clang_type) && >>> member_clang_type.GetCompleteType() == false) >>> + { >>> + if (die.GetCU()->GetProducer() == >>> DWARFCompileUnit::eProducerClang) >>> + module_sp->ReportError ("DWARF DIE >>> at 0x%8.8x (class %s) has a member variable 0x%8.8x (%s) whose type is a >>> forward declaration, not a complete definition.\nTry compiling the source >>> file with -fno-limit-debug-info", >>> + >>> parent_die.GetOffset(), >>> + >>> parent_die.GetName(), >>> + >>> die.GetOffset(), >>> + name); >>> + else >>> + module_sp->ReportError ("DWARF DIE >>> at 0x%8.8x (class %s) has a member variable 0x%8.8x (%s) whose type is a >>> forward declaration, not a complete definition.\nPlease file a bug against >>> the compiler and include the preprocessed output for %s", >>> + >>> parent_die.GetOffset(), >>> + >>> parent_die.GetName(), >>> + >>> die.GetOffset(), >>> + name, >>> + >>> sc.comp_unit ? sc.comp_unit->GetPath().c_str() : "the source file"); >>> + // We have no choice other than to >>> pretend that the member class >>> + // is complete. If we don't do this, >>> clang will crash when trying >>> + // to layout the class. Since we >>> provide layout assistance, all >>> + // ivars in this class and other >>> classes will be fine, this is >>> + // the best we can do short of >>> crashing. >>> + >>> ClangASTContext::StartTagDeclarationDefinition(member_clang_type); >>> + >>> ClangASTContext::CompleteTagDeclarationDefinition(member_clang_type); >>> + } >>> + >>> field_decl = >>> ClangASTContext::AddFieldToRecordType (class_clang_type, >>> >>> name, >>> >>> member_clang_type, >>> @@ -2978,7 +3155,7 @@ DWARFASTParserClang::ParseChildMembers ( >>> } >>> } >>> >>> - return incomplete_member_info_count == 0; >>> + return true; >>> } >>> >>> >>> >>> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h >>> (original) >>> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Tue >>> Dec 1 18:43:32 2015 >>> @@ -47,6 +47,12 @@ public: >>> const DWARFDIE &die) override; >>> >>> bool >>> + CanCompleteType (const lldb_private::CompilerType &compiler_type) >>> override; >>> + >>> + bool >>> + CompleteType (const lldb_private::CompilerType &compiler_type) >>> override; >>> + >>> + bool >>> CompleteTypeFromDWARF (const DWARFDIE &die, >>> lldb_private::Type *type, >>> lldb_private::CompilerType &compiler_type) >>> override; >>> @@ -175,6 +181,19 @@ protected: >>> void >>> LinkDeclToDIE (clang::Decl *decl, const DWARFDIE &die); >>> >>> + lldb_private::ClangASTImporter & >>> + GetClangASTImporter(); >>> + >>> + lldb::TypeSP >>> + ParseTypeFromDWO (const DWARFDIE &die, lldb_private::Log *log); >>> + >>> + >>> //---------------------------------------------------------------------- >>> + // Return true if this type is a declaration to a type in an external >>> + // module. >>> + >>> //---------------------------------------------------------------------- >>> + lldb::ModuleSP >>> + GetModuleForType (const DWARFDIE &die); >>> + >>> typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet; >>> typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext >>> *> DIEToDeclContextMap; >>> //typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> >>> DeclContextToDIEMap; >>> @@ -188,6 +207,7 @@ protected: >>> DIEToDeclContextMap m_die_to_decl_ctx; >>> DeclContextToDIEMap m_decl_ctx_to_die; >>> RecordDeclToLayoutMap m_record_decl_to_layout_map; >>> + std::unique_ptr<lldb_private::ClangASTImporter> >>> m_clang_ast_importer_ap; >>> }; >>> >>> #endif // SymbolFileDWARF_DWARFASTParserClang_h_ >>> >>> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (original) >>> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp Tue Dec 1 >>> 18:43:32 2015 >>> @@ -22,8 +22,11 @@ >>> >>> #include "lldb/Core/Module.h" >>> #include "lldb/Symbol/ObjectFile.h" >>> +#include "lldb/Symbol/Type.h" >>> #include "lldb/Symbol/TypeSystem.h" >>> >>> +using namespace lldb_private; >>> + >>> DIERef >>> DWARFDIE::GetDIERef() const >>> { >>> @@ -307,6 +310,51 @@ DWARFDIE::GetDWARFDeclContext (DWARFDecl >>> } >>> } >>> >>> +void >>> +DWARFDIE::GetDWOContext (std::vector<CompilerContext> &context) const >>> +{ >>> + const dw_tag_t tag = Tag(); >>> + if (tag == DW_TAG_compile_unit) >>> + return; >>> + DWARFDIE parent = GetParent(); >>> + if (parent) >>> + parent.GetDWOContext(context); >>> + switch (tag) >>> + { >>> + case DW_TAG_module: >>> + context.push_back(CompilerContext(CompilerContextKind::Module, >>> ConstString(GetName()))); >>> + break; >>> + case DW_TAG_namespace: >>> + >>> context.push_back(CompilerContext(CompilerContextKind::Namespace, >>> ConstString(GetName()))); >>> + break; >>> + case DW_TAG_structure_type: >>> + >>> context.push_back(CompilerContext(CompilerContextKind::Structure, >>> ConstString(GetName()))); >>> + break; >>> + case DW_TAG_union_type: >>> + context.push_back(CompilerContext(CompilerContextKind::Union, >>> ConstString(GetName()))); >>> + break; >>> + case DW_TAG_class_type: >>> + context.push_back(CompilerContext(CompilerContextKind::Class, >>> ConstString(GetName()))); >>> + break; >>> + case DW_TAG_enumeration_type: >>> + >>> context.push_back(CompilerContext(CompilerContextKind::Enumeration, >>> ConstString(GetName()))); >>> + break; >>> + case DW_TAG_subprogram: >>> + >>> context.push_back(CompilerContext(CompilerContextKind::Function, >>> ConstString(GetPubname()))); >>> + break; >>> + case DW_TAG_variable: >>> + >>> context.push_back(CompilerContext(CompilerContextKind::Variable, >>> ConstString(GetPubname()))); >>> + break; >>> + case DW_TAG_typedef: >>> + >>> context.push_back(CompilerContext(CompilerContextKind::Typedef, >>> ConstString(GetName()))); >>> + break; >>> + default: >>> + assert(!"remove this prior to checkin"); >>> + break; >>> + } >>> +} >>> + >>> + >>> >>> DWARFDIE >>> DWARFDIE::GetParentDeclContextDIE () const >>> @@ -371,6 +419,45 @@ DWARFDIE::IsStructOrClass () const >>> return tag == DW_TAG_class_type || tag == DW_TAG_structure_type; >>> } >>> >>> + >>> +DWARFDIE >>> +DWARFDIE::GetContainingDWOModuleDIE () const >>> +{ >>> + if (IsValid()) >>> + { >>> + DWARFDIE top_module_die; >>> + // Now make sure this DIE is scoped in a DW_TAG_module tag and >>> return true if so >>> + for (DWARFDIE parent = GetParent(); parent.IsValid(); parent = >>> parent.GetParent()) >>> + { >>> + const dw_tag_t tag = parent.Tag(); >>> + if (tag == DW_TAG_module) >>> + top_module_die = parent; >>> + else if (tag == DW_TAG_compile_unit) >>> + break; >>> + } >>> + >>> + return top_module_die; >>> + } >>> + return DWARFDIE(); >>> +} >>> + >>> +lldb::ModuleSP >>> +DWARFDIE::GetContainingDWOModule () const >>> +{ >>> + if (IsValid()) >>> + { >>> + DWARFDIE dwo_module_die = GetContainingDWOModuleDIE(); >>> + >>> + if (dwo_module_die) >>> + { >>> + const char *module_name = dwo_module_die.GetName(); >>> + if (module_name) >>> + return GetDWARF()->GetDWOModule >>> (lldb_private::ConstString(module_name)); >>> + } >>> + } >>> + return lldb::ModuleSP(); >>> +} >>> + >>> bool >>> DWARFDIE::HasChildren () const >>> { >>> >>> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h (original) >>> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h Tue Dec 1 >>> 18:43:32 2015 >>> @@ -126,6 +126,12 @@ public: >>> m_die = nullptr; >>> } >>> >>> + lldb::ModuleSP >>> + GetContainingDWOModule () const; >>> + >>> + DWARFDIE >>> + GetContainingDWOModuleDIE () const; >>> + >>> //---------------------------------------------------------------------- >>> // Accessing information about a DIE >>> //---------------------------------------------------------------------- >>> @@ -217,6 +223,9 @@ public: >>> void >>> GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const; >>> >>> + void >>> + GetDWOContext (std::vector<lldb_private::CompilerContext> &context) >>> const; >>> + >>> //---------------------------------------------------------------------- >>> // Getting attribute values from the DIE. >>> // >>> >>> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=254476&r1=254475&r2=254476&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp >>> (original) >>> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Dec >>> 1 18:43:32 2015 >>> @@ -1077,9 +1077,9 @@ SymbolFileDWARF::ParseImportedModules (c >>> if >>> (ClangModulesDeclVendor::LanguageSupportsClangModules(sc.comp_unit->GetLanguage())) >>> { >>> UpdateExternalModuleListIfNeeded(); >>> - for (const std::pair<uint64_t, const ClangModuleInfo> >>> &external_type_module : m_external_type_modules) >>> + for (const auto &pair : m_external_type_modules) >>> { >>> - >>> imported_modules.push_back(external_type_module.second.m_name); >>> + imported_modules.push_back(pair.first); >>> } >>> } >>> } >>> @@ -1515,13 +1515,32 @@ bool >>> SymbolFileDWARF::HasForwardDeclForClangType (const CompilerType >>> &compiler_type) >>> { >>> CompilerType compiler_type_no_qualifiers = >>> ClangASTContext::RemoveFastQualifiers(compiler_type); >>> - return GetForwardDeclClangTypeToDie().count >>> (compiler_type_no_qualifiers.GetOpaqueQualType()); >>> + if (GetForwardDeclClangTypeToDie().count >>> (compiler_type_no_qualifiers.GetOpaqueQualType())) >>> + { >>> + return true; >>> + } >>> + TypeSystem *type_system = compiler_type.GetTypeSystem(); >>> + if (type_system) >>> + { >>> + DWARFASTParser *dwarf_ast = type_system->GetDWARFParser(); >>> + if (dwarf_ast) >>> + return dwarf_ast->CanCompleteType(compiler_type); >>> + } >>> + return false; >>> } >>> >>> >>> bool >>> SymbolFileDWARF::CompleteType (CompilerType &compiler_type) >>> { >>> + TypeSystem *type_system = compiler_type.GetTypeSystem(); >>> + if (type_system) >>> + { >>> + DWARFASTParser *dwarf_ast = type_system->GetDWARFParser(); >>> + if (dwarf_ast && dwarf_ast->CanCompleteType(compiler_type)) >>> + return dwarf_ast->CompleteType(compiler_type); >>> + } >>> + >>> // We have a struct/union/class/enum that needs to be fully resolved. >>> CompilerType compiler_type_no_qualifiers = >>> ClangASTContext::RemoveFastQualifiers(compiler_type); >>> auto die_it = GetForwardDeclClangTypeToDie().find >>> (compiler_type_no_qualifiers.GetOpaqueQualType()); >>> @@ -1641,6 +1660,17 @@ SymbolFileDWARF::GetFunction (const DWAR >>> return false; >>> } >>> >>> +lldb::ModuleSP >>> +SymbolFileDWARF::GetDWOModule (ConstString name) >>> +{ >>> + UpdateExternalModuleListIfNeeded(); >>> + const auto &pos = m_external_type_modules.find(name); >>> + if (pos != m_external_type_modules.end()) >>> + return pos->second; >>> + else >>> + return lldb::ModuleSP(); >>> +} >>> + >>> void >>> SymbolFileDWARF::UpdateExternalModuleListIfNeeded() >>> { >>> @@ -1658,37 +1688,24 @@ SymbolFileDWARF::UpdateExternalModuleLis >>> const DWARFDIE die = dwarf_cu->GetCompileUnitDIEOnly(); >>> if (die && die.HasChildren() == false) >>> { >>> - const uint64_t name_strp = die.GetAttributeValueAsUnsigned >>> (DW_AT_name, UINT64_MAX); >>> - const uint64_t dwo_path_strp = die.GetAttributeValueAsUnsigned >>> (DW_AT_GNU_dwo_name, UINT64_MAX); >>> - >>> - if (name_strp != UINT64_MAX) >>> + const char *name = die.GetAttributeValueAsString(DW_AT_name, >>> nullptr); >>> + >>> + if (name) >>> { >>> - if (m_external_type_modules.find(dwo_path_strp) == >>> m_external_type_modules.end()) >>> + ConstString const_name(name); >>> + if (m_external_type_modules.find(const_name) == >>> m_external_type_modules.end()) >>> { >>> - const char *name = >>> get_debug_str_data().PeekCStr(name_strp); >>> - const char *dwo_path = >>> get_debug_str_data().PeekCStr(dwo_path_strp); >>> - if (name || dwo_path) >>> + ModuleSP module_sp; >>> + const char *dwo_path = >>> die.GetAttributeValueAsString(DW_AT_GNU_dwo_name, nullptr); >>> + if (dwo_path) >>> { >>> - ModuleSP module_sp; >>> - if (dwo_path) >>> - { >>> - ModuleSpec dwo_module_spec; >>> - >>> dwo_module_spec.GetFileSpec().SetFile(dwo_path, false); >>> - dwo_module_spec.GetArchitecture() = >>> m_obj_file->GetModule()->GetArchitecture(); >>> - //printf ("Loading dwo = '%s'\n", dwo_path); >>> - Error error = ModuleList::GetSharedModule >>> (dwo_module_spec, module_sp, NULL, NULL, NULL); >>> - } >>> - >>> - if (dwo_path_strp != LLDB_INVALID_UID) >>> - { >>> - m_external_type_modules[dwo_path_strp] = >>> ClangModuleInfo { ConstString(name), module_sp }; >>> - } >>> - else >>> - { >>> - // This hack should be removed promptly once >>> clang emits both. >>> - m_external_type_modules[name_strp] = >>> ClangModuleInfo { ConstString(name), module_sp }; >>> - } >>> + ModuleSpec dwo_module_spec; >>> + dwo_module_spec.GetFileSpec().SetFile(dwo_path, >>> false); >>> + dwo_module_spec.GetArchitecture() = >>> m_obj_file->GetModule()->GetArchitecture(); >>> + //printf ("Loading dwo = '%s'\n", dwo_path); >>> + Error error = ModuleList::GetSharedModule >>> (dwo_module_spec, module_sp, NULL, NULL, NULL); >>> } >>> + m_external_type_modules[const_name] = module_sp; >>> } >>> } >>> } >>> @@ -2970,6 +2987,104 @@ SymbolFileDWARF::FindTypes (const Symbol >>> } >>> return num_matches; >>> } >>> + else >>> + { >>> + UpdateExternalModuleListIfNeeded(); >>> + >>> + for (const auto &pair : m_external_type_modules) >>> + { >>> + ModuleSP external_module_sp = pair.second; >>> + if (external_module_sp) >>> + { >>> + SymbolVendor *sym_vendor = >>> external_module_sp->GetSymbolVendor(); >>> + if (sym_vendor) >>> + { >>> + const uint32_t num_external_matches = >>> sym_vendor->FindTypes (sc, >>> + >>> name, >>> + >>> parent_decl_ctx, >>> + >>> append, >>> + >>> max_matches, >>> + >>> types); >>> + if (num_external_matches) >>> + return num_external_matches; >>> + } >>> + } >>> + } >>> + } >>> + >>> + return 0; >>> +} >>> + >>> + >>> +size_t >>> +SymbolFileDWARF::FindTypes (const std::vector<CompilerContext> &context, >>> + bool append, >>> + TypeMap& types) >>> +{ >>> + if (!append) >>> + types.Clear(); >>> + >>> + if (context.empty()) >>> + return 0; >>> + >>> + DIEArray die_offsets; >>> + >>> + ConstString name = context.back().name; >>> + >>> + if (m_using_apple_tables) >>> + { >>> + if (m_apple_types_ap.get()) >>> + { >>> + const char *name_cstr = name.GetCString(); >>> + m_apple_types_ap->FindByName (name_cstr, die_offsets); >>> + } >>> + } >>> + else >>> + { >>> + if (!m_indexed) >>> + Index (); >>> + >>> + m_type_index.Find (name, die_offsets); >>> + } >>> + >>> + const size_t num_die_matches = die_offsets.size(); >>> + >>> + if (num_die_matches) >>> + { >>> + size_t num_matches = 0; >>> + DWARFDebugInfo* debug_info = DebugInfo(); >>> + for (size_t i=0; i<num_die_matches; ++i) >>> + { >>> + const DIERef& die_ref = die_offsets[i]; >>> + DWARFDIE die = debug_info->GetDIE (die_ref); >>> + >>> + if (die) >>> + { >>> + > > _______________________________________________ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits