Index: lit/SymbolFile/PDB/enums-layout.test =================================================================== --- lit/SymbolFile/PDB/enums-layout.test +++ lit/SymbolFile/PDB/enums-layout.test @@ -1,44 +1,45 @@ REQUIRES: system-windows, msvc RUN: %build --compiler=msvc --arch=32 --nodefaultlib --output=%T/SimpleTypesTest.cpp.enums.exe %S/Inputs/SimpleTypesTest.cpp -RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_CONST %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_EMPTY %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_UCHAR %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_CLASS %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_STRUCT %s ; FIXME: PDB does not have information about scoped enumeration (Enum class) so the ; compiler type used is the same as the one for unscoped enumeration. -CHECK: Module [[CU:.*]] -CHECK-DAG: {{^[0-9A-F]+}}: SymbolVendor ([[CU]]) -CHECK: Type{{.*}} , name = "Enum", size = 4, decl = simpletypestest.cpp:19, compiler_type = {{.*}} enum Enum { -CHECK-NEXT: RED, -CHECK-NEXT: GREEN, -CHECK-NEXT: BLUE -CHECK-NEXT:} - -CHECK: Type{{.*}} , name = "EnumConst", size = 4, decl = simpletypestest.cpp:22, compiler_type = {{.*}} enum EnumConst { -CHECK-NEXT: LOW, -CHECK-NEXT: NORMAL, -CHECK-NEXT: HIGH -CHECK-NEXT:} - -CHECK: Type{{.*}} , name = "EnumEmpty", size = 4, decl = simpletypestest.cpp:25, compiler_type = {{.*}} enum EnumEmpty { -CHECK-NEXT:} - -CHECK: Type{{.*}} , name = "EnumUChar", size = 1, decl = simpletypestest.cpp:28, compiler_type = {{.*}} enum EnumUChar { -CHECK-NEXT: ON, -CHECK-NEXT: OFF, -CHECK-NEXT: AUTO -CHECK-NEXT:} +ENUM: Type{{.*}} , name = "Enum", size = 4, decl = simpletypestest.cpp:19, compiler_type = {{.*}} enum Enum { +ENUM_NEXT: RED, +ENUM_NEXT: GREEN, +ENUM_NEXT: BLUE +ENUM_NEXT:} + +ENUM_CONST: Type{{.*}} , name = "EnumConst", size = 4, decl = simpletypestest.cpp:22, compiler_type = {{.*}} enum EnumConst { +ENUM_CONST-NEXT: LOW, +ENUM_CONST-NEXT: NORMAL, +ENUM_CONST-NEXT: HIGH +ENUM_CONST-NEXT:} + +ENUM_EMPTY: Type{{.*}} , name = "EnumEmpty", size = 4, decl = simpletypestest.cpp:25, compiler_type = {{.*}} enum EnumEmpty { +ENUM_EMPTY-NEXT:} + +ENUM_UCHAR: Type{{.*}} , name = "EnumUChar", size = 1, decl = simpletypestest.cpp:28, compiler_type = {{.*}} enum EnumUChar { +ENUM_UCHAR-NEXT: ON, +ENUM_UCHAR-NEXT: OFF, +ENUM_UCHAR-NEXT: AUTO +ENUM_UCHAR-NEXT:} ; Note that `enum EnumClass` is tested instead of `enum class EnumClass` -CHECK: Type{{.*}} , name = "EnumClass", size = 4, decl = simpletypestest.cpp:32, compiler_type = {{.*}} enum EnumClass { -CHECK-NEXT: YES, -CHECK-NEXT: NO, -CHECK-NEXT: DEFAULT -CHECK-NEXT:} - -CHECK: Type{{.*}} , name = "EnumStruct", size = 4, decl = simpletypestest.cpp:35, compiler_type = {{.*}} enum EnumStruct { -CHECK-NEXT: red, -CHECK-NEXT: blue, -CHECK-NEXT: black -CHECK-NEXT:} - -CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\SimpleTypesTest.cpp' +ENUM_CLASS: Type{{.*}} , name = "EnumClass", size = 4, decl = simpletypestest.cpp:32, compiler_type = {{.*}} enum EnumClass { +ENUM_CLASS-NEXT: YES, +ENUM_CLASS-NEXT: NO, +ENUM_CLASS-NEXT: DEFAULT +ENUM_CLASS-NEXT:} + +ENUM_STRUCT: Type{{.*}} , name = "EnumStruct", size = 4, decl = simpletypestest.cpp:35, compiler_type = {{.*}} enum EnumStruct { +ENUM_STRUCT-NEXT: red, +ENUM_STRUCT-NEXT: blue, +ENUM_STRUCT-NEXT: black +ENUM_STRUCT-NEXT:} Index: lit/SymbolFile/PDB/type-quals.test =================================================================== --- lit/SymbolFile/PDB/type-quals.test +++ lit/SymbolFile/PDB/type-quals.test @@ -5,35 +5,35 @@ CHECK: Module [[MOD:.*]] CHECK-DAG: {{^[0-9A-F]+}}: SymbolVendor ([[MOD]]) -CHECK: Type{{.*}} , name = "const int", size = 4, compiler_type = {{.*}} const int -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int * -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int **const -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const * -CHECK: Type{{.*}} , name = "Func1", {{.*}}, compiler_type = {{.*}} void (const int *, const int *, const int **const, const int *const *) - -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} volatile int * -CHECK: Type{{.*}} , name = "Func2", {{.*}}, compiler_type = {{.*}} void (volatile int *, volatile int *) - -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int * -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int *& -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int & -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int & -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int && -CHECK: Type{{.*}} , name = "Func3", {{.*}}, compiler_type = {{.*}} void (int *&, int &, const int &, int &&) +CHECK-DAG: Type{{.*}} , name = "const int", size = 4, compiler_type = {{.*}} const int +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int **const +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const * +CHECK-DAG: Type{{.*}} , name = "Func1", {{.*}}, compiler_type = {{.*}} void (const int *, const int *, const int **const, const int *const *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} volatile int * +CHECK-DAG: Type{{.*}} , name = "Func2", {{.*}}, compiler_type = {{.*}} void (volatile int *, volatile int *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *& +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int && +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int & +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int & +CHECK-DAG: Type{{.*}} , name = "Func3", {{.*}}, compiler_type = {{.*}} void (int *&, int &, const int &, int &&) // FIXME: __unaligned is not supported. -CHECK: Type{{.*}} , name = "Func4", {{.*}}, compiler_type = {{.*}} void (int *, int *) +CHECK-DAG: Type{{.*}} , name = "Func4", {{.*}}, compiler_type = {{.*}} void (int *, int *) -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int *__restrict -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int &__restrict -CHECK: Type{{.*}} , name = "Func5", {{.*}}, compiler_type = {{.*}} void (int, int *__restrict, int &__restrict) +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *__restrict +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int &__restrict +CHECK-DAG: Type{{.*}} , name = "Func5", {{.*}}, compiler_type = {{.*}} void (int, int *__restrict, int &__restrict) -CHECK: Type{{.*}} , name = "Func6", {{.*}}, compiler_type = {{.*}} void (const volatile int *__restrict) +CHECK-DAG: Type{{.*}} , name = "Func6", {{.*}}, compiler_type = {{.*}} void (const volatile int *__restrict) -CHECK: Type{{.*}} , size = 400, compiler_type = {{.*}} volatile int *[100] -CHECK: Type{{.*}} , size = 4000, compiler_type = {{.*}} volatile int *[10][100] +CHECK-DAG: Type{{.*}} , size = 400, compiler_type = {{.*}} volatile int *[100] +CHECK-DAG: Type{{.*}} , size = 4000, compiler_type = {{.*}} volatile int *[10][100] -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} long *__restrict +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} long *__restrict CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\TypeQualsTest.cpp' Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.h =================================================================== --- source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -20,6 +20,8 @@ #include "llvm/DebugInfo/PDB/PDB.h" #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" +class PDBASTParser; + class SymbolFilePDB : public lldb_private::SymbolFile { public: //------------------------------------------------------------------ @@ -224,6 +226,8 @@ void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland &pdb_compiland, uint32_t &index); + PDBASTParser *GetPDBAstParser(); + std::unique_ptr GetPDBCompilandByUID(uint32_t uid); Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp =================================================================== --- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -314,6 +314,16 @@ func_type_uid, mangled, func_type, func_range); sc.comp_unit->AddFunction(func_sp); + + TypeSystem *type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + if (!type_system) + return nullptr; + ClangASTContext *clang_type_system = + llvm::dyn_cast_or_null(type_system); + if (!clang_type_system) + return nullptr; + clang_type_system->GetPDBParser()->GetDeclForSymbol(pdb_func); + return func_sp.get(); } @@ -1035,6 +1045,9 @@ if (variable_list) variable_list->AddVariableIfUnique(var_sp); ++num_added; + PDBASTParser *ast = GetPDBAstParser(); + if (ast) + ast->GetDeclForSymbol(*pdb_data); } } } @@ -1623,6 +1636,16 @@ return type_system; } +PDBASTParser *SymbolFilePDB::GetPDBAstParser() { + auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + auto clang_type_system = llvm::dyn_cast_or_null(type_system); + if (!clang_type_system) + return nullptr; + + return clang_type_system->GetPDBParser(); +} + + lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace( const lldb_private::SymbolContext &sc, const lldb_private::ConstString &name, Index: tools/lldb-test/lldb-test.cpp =================================================================== --- tools/lldb-test/lldb-test.cpp +++ tools/lldb-test/lldb-test.cpp @@ -518,6 +518,7 @@ Error opts::symbols::dumpAST(lldb_private::Module &Module) { SymbolVendor &plugin = *Module.GetSymbolVendor(); + Module.ParseAllDebugSymbols(); auto symfile = plugin.GetSymbolFile(); if (!symfile) @@ -536,9 +537,6 @@ if (!tu) return make_string_error("Can't retrieve translation unit declaration."); - symfile->ParseDeclsForContext(CompilerDeclContext( - clang_ast_ctx, static_cast(tu))); - tu->print(outs()); return Error::success();