[llvm] r360813 - [codeview] Finish support for reading and writing S_ANNOTATION records
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 13:53:39 PDT 2019
Author: rnk
Date: Wed May 15 13:53:39 2019
New Revision: 360813
URL: http://llvm.org/viewvc/llvm-project?rev=360813&view=rev
Log:
[codeview] Finish support for reading and writing S_ANNOTATION records
Implement dumping via llvm-pdbutil and llvm-readobj.
Added:
llvm/trunk/test/DebugInfo/PDB/annotation.test
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def
llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h
llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp
llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp
llvm/trunk/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
llvm/trunk/test/DebugInfo/PDB/Inputs/unknown-symbol.yaml
llvm/trunk/test/DebugInfo/PDB/pdb-unknown-symbol.test
llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def?rev=360813&r1=360812&r2=360813&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def Wed May 15 13:53:39 2019
@@ -102,7 +102,6 @@ CV_SYMBOL(S_LPROCIA64_ST , 0x1015)
CV_SYMBOL(S_GPROCIA64_ST , 0x1016)
CV_SYMBOL(S_LOCALSLOT_ST , 0x1017)
CV_SYMBOL(S_PARAMSLOT_ST , 0x1018)
-CV_SYMBOL(S_ANNOTATION , 0x1019)
CV_SYMBOL(S_GMANPROC_ST , 0x101a)
CV_SYMBOL(S_LMANPROC_ST , 0x101b)
CV_SYMBOL(S_RESERVED1 , 0x101c)
@@ -254,6 +253,7 @@ SYMBOL_RECORD(S_LTHREAD32 , 0x1112,
SYMBOL_RECORD_ALIAS(S_GTHREAD32 , 0x1113, GlobalTLS, ThreadLocalDataSym)
SYMBOL_RECORD(S_UNAMESPACE , 0x1124, UsingNamespaceSym)
+SYMBOL_RECORD(S_ANNOTATION , 0x1019, AnnotationSym)
#undef CV_SYMBOL
#undef SYMBOL_RECORD
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h?rev=360813&r1=360812&r2=360813&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h Wed May 15 13:53:39 2019
@@ -973,7 +973,7 @@ class UsingNamespaceSym : public SymbolR
public:
explicit UsingNamespaceSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
explicit UsingNamespaceSym(uint32_t RecordOffset)
- : SymbolRecord(SymbolRecordKind::RegRelativeSym),
+ : SymbolRecord(SymbolRecordKind::UsingNamespaceSym),
RecordOffset(RecordOffset) {}
StringRef Name;
@@ -982,6 +982,19 @@ public:
};
// S_ANNOTATION
+class AnnotationSym : public SymbolRecord {
+public:
+ explicit AnnotationSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
+ explicit AnnotationSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::AnnotationSym),
+ RecordOffset(RecordOffset) {}
+
+ uint32_t CodeOffset = 0;
+ uint16_t Segment = 0;
+ std::vector<StringRef> Strings;
+
+ uint32_t RecordOffset;
+};
using CVSymbol = CVRecord<SymbolKind>;
using CVSymbolArray = VarStreamArray<CVSymbol>;
Modified: llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp?rev=360813&r1=360812&r2=360813&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp Wed May 15 13:53:39 2019
@@ -630,6 +630,18 @@ Error CVSymbolDumperImpl::visitKnownReco
return Error::success();
}
+Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
+ AnnotationSym &Annot) {
+ W.printHex("Offset", Annot.CodeOffset);
+ W.printHex("Segment", Annot.Segment);
+
+ ListScope S(W, "Strings");
+ for (StringRef Str : Annot.Strings)
+ W.printString(Str);
+
+ return Error::success();
+}
+
Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) {
W.printNumber("Length", CVR.length());
return Error::success();
Modified: llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp?rev=360813&r1=360812&r2=360813&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp Wed May 15 13:53:39 2019
@@ -471,6 +471,18 @@ Error SymbolRecordMapping::visitKnownRec
return Error::success();
}
+Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
+ AnnotationSym &Annot) {
+
+ error(IO.mapInteger(Annot.CodeOffset));
+ error(IO.mapInteger(Annot.Segment));
+ error(IO.mapVectorN<uint16_t>(
+ Annot.Strings,
+ [](CodeViewRecordIO &IO, StringRef &S) { return IO.mapStringZ(S); }));
+
+ return Error::success();
+}
+
RegisterId codeview::decodeFramePtrReg(EncodedFramePtrReg EncodedReg,
CPUType CPU) {
assert(unsigned(EncodedReg) < 4);
Modified: llvm/trunk/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/CodeViewYAMLSymbols.cpp?rev=360813&r1=360812&r2=360813&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/CodeViewYAMLSymbols.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/CodeViewYAMLSymbols.cpp Wed May 15 13:53:39 2019
@@ -553,6 +553,12 @@ template <> void SymbolRecordImpl<UsingN
IO.mapRequired("Namespace", Symbol.Name);
}
+template <> void SymbolRecordImpl<AnnotationSym>::map(IO &IO) {
+ IO.mapOptional("Offset", Symbol.CodeOffset, 0U);
+ IO.mapOptional("Segment", Symbol.Segment, uint16_t(0));
+ IO.mapRequired("Strings", Symbol.Strings);
+}
+
} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm
Modified: llvm/trunk/test/DebugInfo/PDB/Inputs/unknown-symbol.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/Inputs/unknown-symbol.yaml?rev=360813&r1=360812&r2=360813&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/PDB/Inputs/unknown-symbol.yaml (original)
+++ llvm/trunk/test/DebugInfo/PDB/Inputs/unknown-symbol.yaml Wed May 15 13:53:39 2019
@@ -4,7 +4,7 @@ DbiStream:
- Module: unknown-symbol.yaml
Modi:
Records:
- - Kind: S_ANNOTATION
+ - Kind: S_RESERVED1
UnknownSym:
Data: 123456789ABCDEF0
...
Added: llvm/trunk/test/DebugInfo/PDB/annotation.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/annotation.test?rev=360813&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/PDB/annotation.test (added)
+++ llvm/trunk/test/DebugInfo/PDB/annotation.test Wed May 15 13:53:39 2019
@@ -0,0 +1,88 @@
+# RUN: yaml2obj < %s > %t.obj
+# RUN: llvm-pdbutil dump --symbols %t.obj | FileCheck %s
+# RUN: llvm-readobj -codeview %t.obj | FileCheck %s --check-prefix=READOBJ
+
+# CHECK: S_ANNOTATION [size = 20]
+# CHECK-NEXT: addr = 0001:0042
+# CHECK-NEXT: strings = [
+# CHECK-NEXT: foo
+# CHECK-NEXT: bar]
+
+# READOBJ: AnnotationSym {
+# READOBJ-NEXT: Kind: S_ANNOTATION (0x1019)
+# READOBJ-NEXT: Offset: 0x2A
+# READOBJ-NEXT: Segment: 0x1
+# READOBJ-NEXT: Strings [
+# READOBJ-NEXT: foo
+# READOBJ-NEXT: bar
+# READOBJ-NEXT: ]
+# READOBJ-NEXT: }
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ ]
+sections:
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 16
+ SectionData: CD2C0F0B
+ - 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_ANNOTATION
+ AnnotationSym:
+ Offset: 42
+ Segment: 1
+ Strings:
+ - foo
+ - bar
+ - !StringTable
+ Strings:
+ - 'SimpleFunction.c'
+symbols:
+ - Name: .text
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 4
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 2772061208
+ Number: 1
+ - Name: '.debug$S'
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 396
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 2
+...
Modified: llvm/trunk/test/DebugInfo/PDB/pdb-unknown-symbol.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/pdb-unknown-symbol.test?rev=360813&r1=360812&r2=360813&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/PDB/pdb-unknown-symbol.test (original)
+++ llvm/trunk/test/DebugInfo/PDB/pdb-unknown-symbol.test Wed May 15 13:53:39 2019
@@ -1,6 +1,6 @@
; RUN: llvm-pdbutil yaml2pdb -pdb=%t.pdb %p/Inputs/unknown-symbol.yaml
; RUN: llvm-pdbutil pdb2yaml -minimal -module-syms -no-file-headers %t.pdb | FileCheck %s
-CHECK: - Kind: S_ANNOTATION
+CHECK: - Kind: S_RESERVED1
CHECK: UnknownSym:
CHECK: Data: 123456789ABCDEF0
Modified: llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp?rev=360813&r1=360812&r2=360813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp Wed May 15 13:53:39 2019
@@ -780,3 +780,12 @@ Error MinimalSymbolDumper::visitKnownRec
P.format(" `{0}`", UN.Name);
return Error::success();
}
+
+Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
+ AnnotationSym &Annot) {
+ AutoIndent Indent(P, 7);
+ P.formatLine("addr = {0}", formatSegmentOffset(Annot.Segment, Annot.CodeOffset));
+ P.formatLine("strings = {0}", typesetStringList(P.getIndentLevel() + 9 + 2,
+ Annot.Strings));
+ return Error::success();
+}
More information about the llvm-commits
mailing list