diff options
author | Alexandre Ganea <alexandre.ganea@ubisoft.com> | 2018-07-31 19:15:50 +0000 |
---|---|---|
committer | Alexandre Ganea <alexandre.ganea@ubisoft.com> | 2018-07-31 19:15:50 +0000 |
commit | a7336f29220616427920dabdd5535a6abebcb3ba (patch) | |
tree | a52b29918031cda9eb93d15b414a2bf76e114bda | |
parent | 0a67b1c905ba2f675174e711899d150b445f6835 (diff) |
[CodeView] Minimal support for S_UNAMESPACE records
Differential Revision: https://reviews.llvm.org/D50007
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338417 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/DebugInfo/CodeView/CodeViewSymbols.def | 2 | ||||
-rw-r--r-- | include/llvm/DebugInfo/CodeView/SymbolRecord.h | 13 | ||||
-rw-r--r-- | lib/DebugInfo/CodeView/RecordName.cpp | 3 | ||||
-rw-r--r-- | lib/DebugInfo/CodeView/SymbolDumper.cpp | 6 | ||||
-rw-r--r-- | lib/DebugInfo/CodeView/SymbolRecordMapping.cpp | 8 | ||||
-rw-r--r-- | lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp | 3 | ||||
-rw-r--r-- | lib/ObjectYAML/CodeViewYAMLSymbols.cpp | 4 | ||||
-rw-r--r-- | test/DebugInfo/PDB/using-namespace.test | 51 | ||||
-rw-r--r-- | tools/llvm-pdbutil/MinimalSymbolDumper.cpp | 6 | ||||
-rw-r--r-- | unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp | 9 |
10 files changed, 102 insertions, 3 deletions
diff --git a/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def b/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def index 41c53807679..b5f1cc0198d 100644 --- a/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def +++ b/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def @@ -143,7 +143,6 @@ CV_SYMBOL(S_MANSLOT , 0x1120) CV_SYMBOL(S_MANMANYREG , 0x1121) CV_SYMBOL(S_MANREGREL , 0x1122) CV_SYMBOL(S_MANMANYREG2 , 0x1123) -CV_SYMBOL(S_UNAMESPACE , 0x1124) CV_SYMBOL(S_DATAREF , 0x1126) CV_SYMBOL(S_ANNOTATIONREF , 0x1128) CV_SYMBOL(S_TOKENREF , 0x1129) @@ -255,6 +254,7 @@ SYMBOL_RECORD_ALIAS(S_GMANDATA , 0x111d, ManagedGlobalData, DataSym) SYMBOL_RECORD(S_LTHREAD32 , 0x1112, ThreadLocalDataSym) SYMBOL_RECORD_ALIAS(S_GTHREAD32 , 0x1113, GlobalTLS, ThreadLocalDataSym) +SYMBOL_RECORD(S_UNAMESPACE , 0x1124, UsingNamespaceSym) #undef CV_SYMBOL #undef SYMBOL_RECORD diff --git a/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/include/llvm/DebugInfo/CodeView/SymbolRecord.h index cf267f23967..93306824012 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolRecord.h +++ b/include/llvm/DebugInfo/CodeView/SymbolRecord.h @@ -942,6 +942,19 @@ public: uint32_t RecordOffset; }; +// S_UNAMESPACE +class UsingNamespaceSym : public SymbolRecord { +public: + explicit UsingNamespaceSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit UsingNamespaceSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::RegRelativeSym), + RecordOffset(RecordOffset) {} + + StringRef Name; + + uint32_t RecordOffset; +}; + // S_ANNOTATION using CVSymbol = CVRecord<SymbolKind>; diff --git a/lib/DebugInfo/CodeView/RecordName.cpp b/lib/DebugInfo/CodeView/RecordName.cpp index e50c43a1d48..d868ae237a4 100644 --- a/lib/DebugInfo/CodeView/RecordName.cpp +++ b/lib/DebugInfo/CodeView/RecordName.cpp @@ -307,6 +307,9 @@ static int getSymbolNameOffset(CVSymbol Sym) { // See BPRelativeSym case SymbolKind::S_BPREL32: return 8; + // See UsingNamespaceSym + case SymbolKind::S_UNAMESPACE: + return 0; default: return -1; } diff --git a/lib/DebugInfo/CodeView/SymbolDumper.cpp b/lib/DebugInfo/CodeView/SymbolDumper.cpp index af249adc977..f8bf961f22a 100644 --- a/lib/DebugInfo/CodeView/SymbolDumper.cpp +++ b/lib/DebugInfo/CodeView/SymbolDumper.cpp @@ -611,6 +611,12 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) { return Error::success(); } +Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, + UsingNamespaceSym &UN) { + W.printString("Namespace", UN.Name); + return Error::success(); +} + Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) { W.printNumber("Length", CVR.length()); return Error::success(); diff --git a/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp b/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp index 923837a45d9..e77c8e8f02f 100644 --- a/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp +++ b/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp @@ -463,3 +463,11 @@ Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) { return Error::success(); } + +Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, + UsingNamespaceSym &UN) { + + error(IO.mapStringZ(UN.Name)); + + return Error::success(); +} diff --git a/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp b/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp index 95082d4a8e0..839ab6f0a70 100644 --- a/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp +++ b/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp @@ -428,7 +428,7 @@ static bool discoverTypeIndices(ArrayRef<uint8_t> Content, SymbolKind Kind, case SymbolKind::S_DEFRANGE_SUBFIELD: break; - // No type refernces. + // No type references. case SymbolKind::S_LABEL32: case SymbolKind::S_OBJNAME: case SymbolKind::S_COMPILE: @@ -439,6 +439,7 @@ static bool discoverTypeIndices(ArrayRef<uint8_t> Content, SymbolKind Kind, case SymbolKind::S_FRAMEPROC: case SymbolKind::S_THUNK32: case SymbolKind::S_FRAMECOOKIE: + case SymbolKind::S_UNAMESPACE: break; // Scope ending symbols. case SymbolKind::S_END: diff --git a/lib/ObjectYAML/CodeViewYAMLSymbols.cpp b/lib/ObjectYAML/CodeViewYAMLSymbols.cpp index f67a0db690e..745f79cd77f 100644 --- a/lib/ObjectYAML/CodeViewYAMLSymbols.cpp +++ b/lib/ObjectYAML/CodeViewYAMLSymbols.cpp @@ -550,6 +550,10 @@ template <> void SymbolRecordImpl<ThreadLocalDataSym>::map(IO &IO) { IO.mapRequired("DisplayName", Symbol.Name); } +template <> void SymbolRecordImpl<UsingNamespaceSym>::map(IO &IO) { + IO.mapRequired("Namespace", Symbol.Name); +} + } // end namespace detail } // end namespace CodeViewYAML } // end namespace llvm diff --git a/test/DebugInfo/PDB/using-namespace.test b/test/DebugInfo/PDB/using-namespace.test new file mode 100644 index 00000000000..77c37826c8f --- /dev/null +++ b/test/DebugInfo/PDB/using-namespace.test @@ -0,0 +1,51 @@ +# RUN: yaml2obj < %s > %t.obj +# RUN: llvm-readobj -codeview %t.obj | FileCheck %s + +# CHECK: Kind: S_UNAMESPACE (0x1124) +# CHECK-NEXT: Namespace: __vc_attributes + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_OBJNAME + ObjNameSym: + Signature: 0 + ObjectName: 'SimpleFunction.obj' + - Kind: S_COMPILE3 + Compile3Sym: + Flags: [ SecurityChecks, HotPatch ] + Machine: X64 + FrontendMajor: 19 + FrontendMinor: 14 + FrontendBuild: 26433 + FrontendQFE: 0 + BackendMajor: 19 + BackendMinor: 14 + BackendBuild: 26433 + BackendQFE: 0 + Version: 'Microsoft (R) Optimizing Compiler' + - Kind: S_UNAMESPACE + UsingNamespaceSym: + Namespace: __vc_attributes + - Kind: S_UNAMESPACE + UsingNamespaceSym: + Namespace: helper_attributes + - Kind: S_UNAMESPACE + UsingNamespaceSym: + Namespace: atl + - Kind: S_UNAMESPACE + UsingNamespaceSym: + Namespace: std + - !StringTable + Strings: + - 'SimpleFunction.c' +symbols: +... diff --git a/tools/llvm-pdbutil/MinimalSymbolDumper.cpp b/tools/llvm-pdbutil/MinimalSymbolDumper.cpp index b454ab34545..f4e38a32a51 100644 --- a/tools/llvm-pdbutil/MinimalSymbolDumper.cpp +++ b/tools/llvm-pdbutil/MinimalSymbolDumper.cpp @@ -760,3 +760,9 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) { P.formatLine("original type = {0}", UDT.Type); return Error::success(); } + +Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, + UsingNamespaceSym &UN) { + P.format(" `{0}`", UN.Name); + return Error::success(); +} diff --git a/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp b/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp index 60ca56b0d14..7ee56042f4b 100644 --- a/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp +++ b/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp @@ -600,4 +600,11 @@ TEST_F(TypeIndexIteratorTest, VariableSizeIntegers) { BaseClassRecord BaseClass2(MemberAccess::Public, TypeIndex(48), 1); writeFieldList(BaseClass1, BaseClass2); checkTypeReferences(0, TypeIndex(47), TypeIndex(48)); -}
\ No newline at end of file +} + +TEST_F(TypeIndexIteratorTest, UsingNamespace) { + UsingNamespaceSym UN(SymbolRecordKind::UsingNamespaceSym); + UN.Name = "std"; + writeSymbolRecords(UN); + checkTypeReferences(0); +} |