llvm.org GIT mirror llvm / 6def39b
[codeview] Finish support for reading and writing S_ANNOTATION records Implement dumping via llvm-pdbutil and llvm-readobj. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360813 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 3 months ago
9 changed file(s) with 144 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
101101 CV_SYMBOL(S_GPROCIA64_ST , 0x1016)
102102 CV_SYMBOL(S_LOCALSLOT_ST , 0x1017)
103103 CV_SYMBOL(S_PARAMSLOT_ST , 0x1018)
104 CV_SYMBOL(S_ANNOTATION , 0x1019)
105104 CV_SYMBOL(S_GMANPROC_ST , 0x101a)
106105 CV_SYMBOL(S_LMANPROC_ST , 0x101b)
107106 CV_SYMBOL(S_RESERVED1 , 0x101c)
253252 SYMBOL_RECORD_ALIAS(S_GTHREAD32 , 0x1113, GlobalTLS, ThreadLocalDataSym)
254253
255254 SYMBOL_RECORD(S_UNAMESPACE , 0x1124, UsingNamespaceSym)
255 SYMBOL_RECORD(S_ANNOTATION , 0x1019, AnnotationSym)
256256
257257 #undef CV_SYMBOL
258258 #undef SYMBOL_RECORD
972972 public:
973973 explicit UsingNamespaceSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
974974 explicit UsingNamespaceSym(uint32_t RecordOffset)
975 : SymbolRecord(SymbolRecordKind::RegRelativeSym),
975 : SymbolRecord(SymbolRecordKind::UsingNamespaceSym),
976976 RecordOffset(RecordOffset) {}
977977
978978 StringRef Name;
981981 };
982982
983983 // S_ANNOTATION
984 class AnnotationSym : public SymbolRecord {
985 public:
986 explicit AnnotationSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
987 explicit AnnotationSym(uint32_t RecordOffset)
988 : SymbolRecord(SymbolRecordKind::AnnotationSym),
989 RecordOffset(RecordOffset) {}
990
991 uint32_t CodeOffset = 0;
992 uint16_t Segment = 0;
993 std::vector Strings;
994
995 uint32_t RecordOffset;
996 };
984997
985998 using CVSymbol = CVRecord;
986999 using CVSymbolArray = VarStreamArray;
629629 return Error::success();
630630 }
631631
632 Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
633 AnnotationSym &Annot) {
634 W.printHex("Offset", Annot.CodeOffset);
635 W.printHex("Segment", Annot.Segment);
636
637 ListScope S(W, "Strings");
638 for (StringRef Str : Annot.Strings)
639 W.printString(Str);
640
641 return Error::success();
642 }
643
632644 Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) {
633645 W.printNumber("Length", CVR.length());
634646 return Error::success();
466466 UsingNamespaceSym &UN) {
467467
468468 error(IO.mapStringZ(UN.Name));
469
470 return Error::success();
471 }
472
473 Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
474 AnnotationSym &Annot) {
475
476 error(IO.mapInteger(Annot.CodeOffset));
477 error(IO.mapInteger(Annot.Segment));
478 error(IO.mapVectorN(
479 Annot.Strings,
480 [](CodeViewRecordIO &IO, StringRef &S) { return IO.mapStringZ(S); }));
469481
470482 return Error::success();
471483 }
552552 IO.mapRequired("Namespace", Symbol.Name);
553553 }
554554
555 template <> void SymbolRecordImpl::map(IO &IO) {
556 IO.mapOptional("Offset", Symbol.CodeOffset, 0U);
557 IO.mapOptional("Segment", Symbol.Segment, uint16_t(0));
558 IO.mapRequired("Strings", Symbol.Strings);
559 }
560
555561 } // end namespace detail
556562 } // end namespace CodeViewYAML
557563 } // end namespace llvm
33 - Module: unknown-symbol.yaml
44 Modi:
55 Records:
6 - Kind: S_ANNOTATION
6 - Kind: S_RESERVED1
77 UnknownSym:
88 Data: 123456789ABCDEF0
99 ...
0 # RUN: yaml2obj < %s > %t.obj
1 # RUN: llvm-pdbutil dump --symbols %t.obj | FileCheck %s
2 # RUN: llvm-readobj -codeview %t.obj | FileCheck %s --check-prefix=READOBJ
3
4 # CHECK: S_ANNOTATION [size = 20]
5 # CHECK-NEXT: addr = 0001:0042
6 # CHECK-NEXT: strings = [
7 # CHECK-NEXT: foo
8 # CHECK-NEXT: bar]
9
10 # READOBJ: AnnotationSym {
11 # READOBJ-NEXT: Kind: S_ANNOTATION (0x1019)
12 # READOBJ-NEXT: Offset: 0x2A
13 # READOBJ-NEXT: Segment: 0x1
14 # READOBJ-NEXT: Strings [
15 # READOBJ-NEXT: foo
16 # READOBJ-NEXT: bar
17 # READOBJ-NEXT: ]
18 # READOBJ-NEXT: }
19
20 --- !COFF
21 header:
22 Machine: IMAGE_FILE_MACHINE_AMD64
23 Characteristics: [ ]
24 sections:
25 - Name: .text
26 Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
27 Alignment: 16
28 SectionData: CD2C0F0B
29 - Name: '.debug$S'
30 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
31 Alignment: 1
32 Subsections:
33 - !Symbols
34 Records:
35 - Kind: S_OBJNAME
36 ObjNameSym:
37 Signature: 0
38 ObjectName: 'SimpleFunction.obj'
39 - Kind: S_COMPILE3
40 Compile3Sym:
41 Flags: [ SecurityChecks, HotPatch ]
42 Machine: X64
43 FrontendMajor: 19
44 FrontendMinor: 14
45 FrontendBuild: 26433
46 FrontendQFE: 0
47 BackendMajor: 19
48 BackendMinor: 14
49 BackendBuild: 26433
50 BackendQFE: 0
51 Version: 'Microsoft (R) Optimizing Compiler'
52 - Kind: S_ANNOTATION
53 AnnotationSym:
54 Offset: 42
55 Segment: 1
56 Strings:
57 - foo
58 - bar
59 - !StringTable
60 Strings:
61 - 'SimpleFunction.c'
62 symbols:
63 - Name: .text
64 Value: 0
65 SectionNumber: 1
66 SimpleType: IMAGE_SYM_TYPE_NULL
67 ComplexType: IMAGE_SYM_DTYPE_NULL
68 StorageClass: IMAGE_SYM_CLASS_STATIC
69 SectionDefinition:
70 Length: 4
71 NumberOfRelocations: 0
72 NumberOfLinenumbers: 0
73 CheckSum: 2772061208
74 Number: 1
75 - Name: '.debug$S'
76 Value: 0
77 SectionNumber: 2
78 SimpleType: IMAGE_SYM_TYPE_NULL
79 ComplexType: IMAGE_SYM_DTYPE_NULL
80 StorageClass: IMAGE_SYM_CLASS_STATIC
81 SectionDefinition:
82 Length: 396
83 NumberOfRelocations: 0
84 NumberOfLinenumbers: 0
85 CheckSum: 0
86 Number: 2
87 ...
0 ; RUN: llvm-pdbutil yaml2pdb -pdb=%t.pdb %p/Inputs/unknown-symbol.yaml
11 ; RUN: llvm-pdbutil pdb2yaml -minimal -module-syms -no-file-headers %t.pdb | FileCheck %s
22
3 CHECK: - Kind: S_ANNOTATION
3 CHECK: - Kind: S_RESERVED1
44 CHECK: UnknownSym:
55 CHECK: Data: 123456789ABCDEF0
779779 P.format(" `{0}`", UN.Name);
780780 return Error::success();
781781 }
782
783 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
784 AnnotationSym &Annot) {
785 AutoIndent Indent(P, 7);
786 P.formatLine("addr = {0}", formatSegmentOffset(Annot.Segment, Annot.CodeOffset));
787 P.formatLine("strings = {0}", typesetStringList(P.getIndentLevel() + 9 + 2,
788 Annot.Strings));
789 return Error::success();
790 }