Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 1 | //===-- SymbolDumper.cpp - CodeView symbol info dumper ----------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/DebugInfo/CodeView/SymbolDumper.h" |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 11 | #include "llvm/ADT/SmallString.h" |
| 12 | #include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h" |
Zachary Turner | 591312c | 2017-05-30 17:13:33 +0000 | [diff] [blame] | 13 | #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" |
Zachary Turner | 93839cb | 2016-06-02 05:07:49 +0000 | [diff] [blame] | 14 | #include "llvm/DebugInfo/CodeView/EnumTables.h" |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 15 | #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 16 | #include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h" |
| 17 | #include "llvm/DebugInfo/CodeView/SymbolRecord.h" |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 18 | #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h" |
| 19 | #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 20 | #include "llvm/DebugInfo/CodeView/TypeIndex.h" |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 21 | #include "llvm/Support/Error.h" |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 22 | #include "llvm/Support/ScopedPrinter.h" |
| 23 | |
| 24 | #include <system_error> |
| 25 | |
| 26 | using namespace llvm; |
| 27 | using namespace llvm::codeview; |
| 28 | |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 29 | namespace { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 30 | /// Use this private dumper implementation to keep implementation details about |
| 31 | /// the visitor out of SymbolDumper.h. |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 32 | class CVSymbolDumperImpl : public SymbolVisitorCallbacks { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 33 | public: |
Zachary Turner | 526f4f2 | 2017-05-19 19:26:58 +0000 | [diff] [blame] | 34 | CVSymbolDumperImpl(TypeCollection &Types, SymbolDumpDelegate *ObjDelegate, |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 35 | ScopedPrinter &W, CPUType CPU, bool PrintRecordBytes) |
| 36 | : Types(Types), ObjDelegate(ObjDelegate), W(W), CompilationCPUType(CPU), |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 37 | PrintRecordBytes(PrintRecordBytes), InFunctionScope(false) {} |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 38 | |
| 39 | /// CVSymbolVisitor overrides. |
| 40 | #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 41 | Error visitKnownRecord(CVSymbol &CVR, Name &Record) override; |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 42 | #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) |
Zachary Turner | d427383 | 2017-05-30 21:53:05 +0000 | [diff] [blame] | 43 | #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 44 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 45 | Error visitSymbolBegin(CVSymbol &Record) override; |
| 46 | Error visitSymbolEnd(CVSymbol &Record) override; |
| 47 | Error visitUnknownSymbol(CVSymbol &Record) override; |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 48 | |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 49 | CPUType getCompilationCPUType() const { return CompilationCPUType; } |
| 50 | |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 51 | private: |
| 52 | void printLocalVariableAddrRange(const LocalVariableAddrRange &Range, |
| 53 | uint32_t RelocationOffset); |
| 54 | void printLocalVariableAddrGap(ArrayRef<LocalVariableAddrGap> Gaps); |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 55 | void printTypeIndex(StringRef FieldName, TypeIndex TI); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 56 | |
Zachary Turner | 526f4f2 | 2017-05-19 19:26:58 +0000 | [diff] [blame] | 57 | TypeCollection &Types; |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 58 | SymbolDumpDelegate *ObjDelegate; |
| 59 | ScopedPrinter &W; |
| 60 | |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 61 | /// Save the machine or CPU type when dumping a compile symbols. |
| 62 | CPUType CompilationCPUType = CPUType::X64; |
| 63 | |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 64 | bool PrintRecordBytes; |
| 65 | bool InFunctionScope; |
| 66 | }; |
| 67 | } |
| 68 | |
Reid Kleckner | 8d8888f | 2017-07-11 23:41:41 +0000 | [diff] [blame] | 69 | static StringRef getSymbolKindName(SymbolKind Kind) { |
| 70 | switch (Kind) { |
| 71 | #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ |
| 72 | case EnumName: \ |
| 73 | return #Name; |
| 74 | #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" |
| 75 | default: |
| 76 | break; |
| 77 | } |
| 78 | return "UnknownSym"; |
| 79 | } |
| 80 | |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 81 | void CVSymbolDumperImpl::printLocalVariableAddrRange( |
| 82 | const LocalVariableAddrRange &Range, uint32_t RelocationOffset) { |
| 83 | DictScope S(W, "LocalVariableAddrRange"); |
| 84 | if (ObjDelegate) |
| 85 | ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset, |
| 86 | Range.OffsetStart); |
| 87 | W.printHex("ISectStart", Range.ISectStart); |
| 88 | W.printHex("Range", Range.Range); |
| 89 | } |
| 90 | |
| 91 | void CVSymbolDumperImpl::printLocalVariableAddrGap( |
| 92 | ArrayRef<LocalVariableAddrGap> Gaps) { |
| 93 | for (auto &Gap : Gaps) { |
| 94 | ListScope S(W, "LocalVariableAddrGap"); |
| 95 | W.printHex("GapStartOffset", Gap.GapStartOffset); |
| 96 | W.printHex("Range", Gap.Range); |
| 97 | } |
| 98 | } |
| 99 | |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 100 | void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) { |
Zachary Turner | 526f4f2 | 2017-05-19 19:26:58 +0000 | [diff] [blame] | 101 | codeview::printTypeIndex(W, FieldName, TI, Types); |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 104 | Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) { |
Reid Kleckner | 8d8888f | 2017-07-11 23:41:41 +0000 | [diff] [blame] | 105 | W.startLine() << getSymbolKindName(CVR.Type); |
| 106 | W.getOStream() << " {\n"; |
| 107 | W.indent(); |
| 108 | W.printEnum("Kind", unsigned(CVR.Type), getSymbolTypeNames()); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 109 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 112 | Error CVSymbolDumperImpl::visitSymbolEnd(CVSymbol &CVR) { |
| 113 | if (PrintRecordBytes && ObjDelegate) |
| 114 | ObjDelegate->printBinaryBlockWithRelocs("SymData", CVR.content()); |
Reid Kleckner | 8d8888f | 2017-07-11 23:41:41 +0000 | [diff] [blame] | 115 | |
| 116 | W.unindent(); |
| 117 | W.startLine() << "}\n"; |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 118 | return Error::success(); |
| 119 | } |
| 120 | |
| 121 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 122 | StringRef LinkageName; |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 123 | W.printHex("PtrParent", Block.Parent); |
| 124 | W.printHex("PtrEnd", Block.End); |
| 125 | W.printHex("CodeSize", Block.CodeSize); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 126 | if (ObjDelegate) { |
| 127 | ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(), |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 128 | Block.CodeOffset, &LinkageName); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 129 | } |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 130 | W.printHex("Segment", Block.Segment); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 131 | W.printString("BlockName", Block.Name); |
| 132 | W.printString("LinkageName", LinkageName); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 133 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 134 | } |
| 135 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 136 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) { |
Brock Wyma | 94ece8f | 2018-04-16 16:53:57 +0000 | [diff] [blame] | 137 | W.printString("Name", Thunk.Name); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 138 | W.printNumber("Parent", Thunk.Parent); |
| 139 | W.printNumber("End", Thunk.End); |
| 140 | W.printNumber("Next", Thunk.Next); |
| 141 | W.printNumber("Off", Thunk.Offset); |
| 142 | W.printNumber("Seg", Thunk.Segment); |
| 143 | W.printNumber("Len", Thunk.Length); |
| 144 | W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames()); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 145 | return Error::success(); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 146 | } |
| 147 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 148 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 149 | TrampolineSym &Tramp) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 150 | W.printEnum("Type", uint16_t(Tramp.Type), getTrampolineNames()); |
| 151 | W.printNumber("Size", Tramp.Size); |
| 152 | W.printNumber("ThunkOff", Tramp.ThunkOffset); |
| 153 | W.printNumber("TargetOff", Tramp.TargetOffset); |
| 154 | W.printNumber("ThunkSection", Tramp.ThunkSection); |
| 155 | W.printNumber("TargetSection", Tramp.TargetSection); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 156 | return Error::success(); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 157 | } |
| 158 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 159 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 160 | W.printNumber("SectionNumber", Section.SectionNumber); |
| 161 | W.printNumber("Alignment", Section.Alignment); |
| 162 | W.printNumber("Rva", Section.Rva); |
| 163 | W.printNumber("Length", Section.Length); |
| 164 | W.printFlags("Characteristics", Section.Characteristics, |
Zachary Turner | 93839cb | 2016-06-02 05:07:49 +0000 | [diff] [blame] | 165 | getImageSectionCharacteristicNames(), |
| 166 | COFF::SectionCharacteristics(0x00F00000)); |
| 167 | |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 168 | W.printString("Name", Section.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 169 | return Error::success(); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 172 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 173 | CoffGroupSym &CoffGroup) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 174 | W.printNumber("Size", CoffGroup.Size); |
| 175 | W.printFlags("Characteristics", CoffGroup.Characteristics, |
Zachary Turner | 93839cb | 2016-06-02 05:07:49 +0000 | [diff] [blame] | 176 | getImageSectionCharacteristicNames(), |
| 177 | COFF::SectionCharacteristics(0x00F00000)); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 178 | W.printNumber("Offset", CoffGroup.Offset); |
| 179 | W.printNumber("Segment", CoffGroup.Segment); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 180 | W.printString("Name", CoffGroup.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 181 | return Error::success(); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 182 | } |
| 183 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 184 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 185 | BPRelativeSym &BPRel) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 186 | W.printNumber("Offset", BPRel.Offset); |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 187 | printTypeIndex("Type", BPRel.Type); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 188 | W.printString("VarName", BPRel.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 189 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 190 | } |
| 191 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 192 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 193 | BuildInfoSym &BuildInfo) { |
Reid Kleckner | af88a91 | 2017-07-15 18:10:39 +0000 | [diff] [blame] | 194 | printTypeIndex("BuildId", BuildInfo.BuildId); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 195 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 198 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 199 | CallSiteInfoSym &CallSiteInfo) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 200 | StringRef LinkageName; |
| 201 | if (ObjDelegate) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 202 | ObjDelegate->printRelocatedField("CodeOffset", |
| 203 | CallSiteInfo.getRelocationOffset(), |
| 204 | CallSiteInfo.CodeOffset, &LinkageName); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 205 | } |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 206 | W.printHex("Segment", CallSiteInfo.Segment); |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 207 | printTypeIndex("Type", CallSiteInfo.Type); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 208 | if (!LinkageName.empty()) |
| 209 | W.printString("LinkageName", LinkageName); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 210 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 213 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 214 | EnvBlockSym &EnvBlock) { |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 215 | ListScope L(W, "Entries"); |
| 216 | for (auto Entry : EnvBlock.Fields) { |
| 217 | W.printString(Entry); |
| 218 | } |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 219 | return Error::success(); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 220 | } |
| 221 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 222 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 223 | FileStaticSym &FileStatic) { |
Zachary Turner | 6305545 | 2017-06-15 22:24:24 +0000 | [diff] [blame] | 224 | printTypeIndex("Index", FileStatic.Index); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 225 | W.printNumber("ModFilenameOffset", FileStatic.ModFilenameOffset); |
| 226 | W.printFlags("Flags", uint16_t(FileStatic.Flags), getLocalFlagNames()); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 227 | W.printString("Name", FileStatic.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 228 | return Error::success(); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 231 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 232 | W.printNumber("Ordinal", Export.Ordinal); |
| 233 | W.printFlags("Flags", uint16_t(Export.Flags), getExportSymFlagNames()); |
Zachary Turner | 9f054d4 | 2016-05-25 00:12:40 +0000 | [diff] [blame] | 234 | W.printString("Name", Export.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 235 | return Error::success(); |
Zachary Turner | 9f054d4 | 2016-05-25 00:12:40 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 238 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 239 | Compile2Sym &Compile2) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 240 | W.printEnum("Language", Compile2.getLanguage(), getSourceLanguageNames()); |
| 241 | W.printFlags("Flags", Compile2.getFlags(), getCompileSym2FlagNames()); |
| 242 | W.printEnum("Machine", unsigned(Compile2.Machine), getCPUTypeNames()); |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 243 | CompilationCPUType = Compile2.Machine; |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 244 | std::string FrontendVersion; |
| 245 | { |
| 246 | raw_string_ostream Out(FrontendVersion); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 247 | Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor |
| 248 | << '.' << Compile2.VersionFrontendBuild; |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 249 | } |
| 250 | std::string BackendVersion; |
| 251 | { |
| 252 | raw_string_ostream Out(BackendVersion); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 253 | Out << Compile2.VersionBackendMajor << '.' << Compile2.VersionBackendMinor |
| 254 | << '.' << Compile2.VersionBackendBuild; |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 255 | } |
| 256 | W.printString("FrontendVersion", FrontendVersion); |
| 257 | W.printString("BackendVersion", BackendVersion); |
| 258 | W.printString("VersionName", Compile2.Version); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 259 | return Error::success(); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 262 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 263 | Compile3Sym &Compile3) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 264 | W.printEnum("Language", Compile3.getLanguage(), getSourceLanguageNames()); |
Zachary Turner | 94926a6 | 2018-10-08 04:19:16 +0000 | [diff] [blame^] | 265 | W.printFlags("Flags", uint32_t(Compile3.getFlags()), |
| 266 | getCompileSym3FlagNames()); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 267 | W.printEnum("Machine", unsigned(Compile3.Machine), getCPUTypeNames()); |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 268 | CompilationCPUType = Compile3.Machine; |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 269 | std::string FrontendVersion; |
| 270 | { |
| 271 | raw_string_ostream Out(FrontendVersion); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 272 | Out << Compile3.VersionFrontendMajor << '.' << Compile3.VersionFrontendMinor |
| 273 | << '.' << Compile3.VersionFrontendBuild << '.' |
| 274 | << Compile3.VersionFrontendQFE; |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 275 | } |
| 276 | std::string BackendVersion; |
| 277 | { |
| 278 | raw_string_ostream Out(BackendVersion); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 279 | Out << Compile3.VersionBackendMajor << '.' << Compile3.VersionBackendMinor |
| 280 | << '.' << Compile3.VersionBackendBuild << '.' |
| 281 | << Compile3.VersionBackendQFE; |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 282 | } |
| 283 | W.printString("FrontendVersion", FrontendVersion); |
| 284 | W.printString("BackendVersion", BackendVersion); |
| 285 | W.printString("VersionName", Compile3.Version); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 286 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 287 | } |
| 288 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 289 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 290 | ConstantSym &Constant) { |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 291 | printTypeIndex("Type", Constant.Type); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 292 | W.printNumber("Value", Constant.Value); |
| 293 | W.printString("Name", Constant.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 294 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 297 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, DataSym &Data) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 298 | StringRef LinkageName; |
| 299 | if (ObjDelegate) { |
| 300 | ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(), |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 301 | Data.DataOffset, &LinkageName); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 302 | } |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 303 | printTypeIndex("Type", Data.Type); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 304 | W.printString("DisplayName", Data.Name); |
| 305 | if (!LinkageName.empty()) |
| 306 | W.printString("LinkageName", LinkageName); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 307 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 308 | } |
| 309 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 310 | Error CVSymbolDumperImpl::visitKnownRecord( |
| 311 | CVSymbol &CVR, |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 312 | DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 313 | W.printNumber("Offset", DefRangeFramePointerRelFullScope.Offset); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 314 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 315 | } |
| 316 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 317 | Error CVSymbolDumperImpl::visitKnownRecord( |
| 318 | CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 319 | W.printNumber("Offset", DefRangeFramePointerRel.Offset); |
| 320 | printLocalVariableAddrRange(DefRangeFramePointerRel.Range, |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 321 | DefRangeFramePointerRel.getRelocationOffset()); |
| 322 | printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 323 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 324 | } |
| 325 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 326 | Error CVSymbolDumperImpl::visitKnownRecord( |
| 327 | CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) { |
Hans Wennborg | ea89ff7 | 2017-10-02 17:44:47 +0000 | [diff] [blame] | 328 | W.printEnum("BaseRegister", uint16_t(DefRangeRegisterRel.Hdr.Register), |
| 329 | getRegisterNames()); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 330 | W.printBoolean("HasSpilledUDTMember", |
| 331 | DefRangeRegisterRel.hasSpilledUDTMember()); |
| 332 | W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent()); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 333 | W.printNumber("BasePointerOffset", DefRangeRegisterRel.Hdr.BasePointerOffset); |
| 334 | printLocalVariableAddrRange(DefRangeRegisterRel.Range, |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 335 | DefRangeRegisterRel.getRelocationOffset()); |
| 336 | printLocalVariableAddrGap(DefRangeRegisterRel.Gaps); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 337 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 338 | } |
| 339 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 340 | Error CVSymbolDumperImpl::visitKnownRecord( |
| 341 | CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) { |
Hans Wennborg | ea89ff7 | 2017-10-02 17:44:47 +0000 | [diff] [blame] | 342 | W.printEnum("Register", uint16_t(DefRangeRegister.Hdr.Register), |
| 343 | getRegisterNames()); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 344 | W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName); |
| 345 | printLocalVariableAddrRange(DefRangeRegister.Range, |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 346 | DefRangeRegister.getRelocationOffset()); |
| 347 | printLocalVariableAddrGap(DefRangeRegister.Gaps); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 348 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 349 | } |
| 350 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 351 | Error CVSymbolDumperImpl::visitKnownRecord( |
| 352 | CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) { |
Hans Wennborg | ea89ff7 | 2017-10-02 17:44:47 +0000 | [diff] [blame] | 353 | W.printEnum("Register", uint16_t(DefRangeSubfieldRegister.Hdr.Register), |
| 354 | getRegisterNames()); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 355 | W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName); |
| 356 | W.printNumber("OffsetInParent", DefRangeSubfieldRegister.Hdr.OffsetInParent); |
| 357 | printLocalVariableAddrRange(DefRangeSubfieldRegister.Range, |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 358 | DefRangeSubfieldRegister.getRelocationOffset()); |
| 359 | printLocalVariableAddrGap(DefRangeSubfieldRegister.Gaps); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 360 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 361 | } |
| 362 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 363 | Error CVSymbolDumperImpl::visitKnownRecord( |
| 364 | CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 365 | if (ObjDelegate) { |
Zachary Turner | 591312c | 2017-05-30 17:13:33 +0000 | [diff] [blame] | 366 | DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable(); |
Zachary Turner | 2d5c2cd | 2017-05-03 17:11:11 +0000 | [diff] [blame] | 367 | auto ExpectedProgram = Strings.getString(DefRangeSubfield.Program); |
| 368 | if (!ExpectedProgram) { |
| 369 | consumeError(ExpectedProgram.takeError()); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 370 | return llvm::make_error<CodeViewError>( |
| 371 | "String table offset outside of bounds of String Table!"); |
Zachary Turner | 2d5c2cd | 2017-05-03 17:11:11 +0000 | [diff] [blame] | 372 | } |
| 373 | W.printString("Program", *ExpectedProgram); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 374 | } |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 375 | W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent); |
| 376 | printLocalVariableAddrRange(DefRangeSubfield.Range, |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 377 | DefRangeSubfield.getRelocationOffset()); |
| 378 | printLocalVariableAddrGap(DefRangeSubfield.Gaps); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 379 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 380 | } |
| 381 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 382 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 383 | DefRangeSym &DefRange) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 384 | if (ObjDelegate) { |
Zachary Turner | 591312c | 2017-05-30 17:13:33 +0000 | [diff] [blame] | 385 | DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable(); |
Zachary Turner | 2d5c2cd | 2017-05-03 17:11:11 +0000 | [diff] [blame] | 386 | auto ExpectedProgram = Strings.getString(DefRange.Program); |
| 387 | if (!ExpectedProgram) { |
| 388 | consumeError(ExpectedProgram.takeError()); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 389 | return llvm::make_error<CodeViewError>( |
| 390 | "String table offset outside of bounds of String Table!"); |
Zachary Turner | 2d5c2cd | 2017-05-03 17:11:11 +0000 | [diff] [blame] | 391 | } |
| 392 | W.printString("Program", *ExpectedProgram); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 393 | } |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 394 | printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset()); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 395 | printLocalVariableAddrGap(DefRange.Gaps); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 396 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 397 | } |
| 398 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 399 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 400 | FrameCookieSym &FrameCookie) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 401 | StringRef LinkageName; |
| 402 | if (ObjDelegate) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 403 | ObjDelegate->printRelocatedField("CodeOffset", |
| 404 | FrameCookie.getRelocationOffset(), |
| 405 | FrameCookie.CodeOffset, &LinkageName); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 406 | } |
Hans Wennborg | ea89ff7 | 2017-10-02 17:44:47 +0000 | [diff] [blame] | 407 | W.printEnum("Register", uint16_t(FrameCookie.Register), getRegisterNames()); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 408 | W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind), |
Zachary Turner | 93839cb | 2016-06-02 05:07:49 +0000 | [diff] [blame] | 409 | getFrameCookieKindNames()); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 410 | W.printHex("Flags", FrameCookie.Flags); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 411 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 412 | } |
| 413 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 414 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 415 | FrameProcSym &FrameProc) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 416 | W.printHex("TotalFrameBytes", FrameProc.TotalFrameBytes); |
| 417 | W.printHex("PaddingFrameBytes", FrameProc.PaddingFrameBytes); |
| 418 | W.printHex("OffsetToPadding", FrameProc.OffsetToPadding); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 419 | W.printHex("BytesOfCalleeSavedRegisters", |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 420 | FrameProc.BytesOfCalleeSavedRegisters); |
| 421 | W.printHex("OffsetOfExceptionHandler", FrameProc.OffsetOfExceptionHandler); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 422 | W.printHex("SectionIdOfExceptionHandler", |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 423 | FrameProc.SectionIdOfExceptionHandler); |
| 424 | W.printFlags("Flags", static_cast<uint32_t>(FrameProc.Flags), |
| 425 | getFrameProcSymFlagNames()); |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 426 | W.printEnum("LocalFramePtrReg", |
| 427 | uint16_t(FrameProc.getLocalFramePtrReg(CompilationCPUType)), |
| 428 | getRegisterNames()); |
| 429 | W.printEnum("ParamFramePtrReg", |
| 430 | uint16_t(FrameProc.getParamFramePtrReg(CompilationCPUType)), |
| 431 | getRegisterNames()); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 432 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 433 | } |
| 434 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 435 | Error CVSymbolDumperImpl::visitKnownRecord( |
| 436 | CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 437 | StringRef LinkageName; |
| 438 | if (ObjDelegate) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 439 | ObjDelegate->printRelocatedField("CodeOffset", |
| 440 | HeapAllocSite.getRelocationOffset(), |
| 441 | HeapAllocSite.CodeOffset, &LinkageName); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 442 | } |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 443 | W.printHex("Segment", HeapAllocSite.Segment); |
| 444 | W.printHex("CallInstructionSize", HeapAllocSite.CallInstructionSize); |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 445 | printTypeIndex("Type", HeapAllocSite.Type); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 446 | if (!LinkageName.empty()) |
| 447 | W.printString("LinkageName", LinkageName); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 448 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 449 | } |
| 450 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 451 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 452 | InlineSiteSym &InlineSite) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 453 | W.printHex("PtrParent", InlineSite.Parent); |
| 454 | W.printHex("PtrEnd", InlineSite.End); |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 455 | printTypeIndex("Inlinee", InlineSite.Inlinee); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 456 | |
| 457 | ListScope BinaryAnnotations(W, "BinaryAnnotations"); |
| 458 | for (auto &Annotation : InlineSite.annotations()) { |
| 459 | switch (Annotation.OpCode) { |
| 460 | case BinaryAnnotationsOpCode::Invalid: |
Zachary Turner | 42cb87f | 2017-03-17 00:15:27 +0000 | [diff] [blame] | 461 | W.printString("(Annotation Padding)"); |
| 462 | break; |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 463 | case BinaryAnnotationsOpCode::CodeOffset: |
| 464 | case BinaryAnnotationsOpCode::ChangeCodeOffset: |
| 465 | case BinaryAnnotationsOpCode::ChangeCodeLength: |
| 466 | W.printHex(Annotation.Name, Annotation.U1); |
| 467 | break; |
| 468 | case BinaryAnnotationsOpCode::ChangeCodeOffsetBase: |
| 469 | case BinaryAnnotationsOpCode::ChangeLineEndDelta: |
| 470 | case BinaryAnnotationsOpCode::ChangeRangeKind: |
| 471 | case BinaryAnnotationsOpCode::ChangeColumnStart: |
| 472 | case BinaryAnnotationsOpCode::ChangeColumnEnd: |
| 473 | W.printNumber(Annotation.Name, Annotation.U1); |
| 474 | break; |
| 475 | case BinaryAnnotationsOpCode::ChangeLineOffset: |
| 476 | case BinaryAnnotationsOpCode::ChangeColumnEndDelta: |
| 477 | W.printNumber(Annotation.Name, Annotation.S1); |
| 478 | break; |
| 479 | case BinaryAnnotationsOpCode::ChangeFile: |
| 480 | if (ObjDelegate) { |
| 481 | W.printHex("ChangeFile", |
| 482 | ObjDelegate->getFileNameForFileOffset(Annotation.U1), |
| 483 | Annotation.U1); |
| 484 | } else { |
| 485 | W.printHex("ChangeFile", Annotation.U1); |
| 486 | } |
| 487 | |
| 488 | break; |
| 489 | case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: { |
| 490 | W.startLine() << "ChangeCodeOffsetAndLineOffset: {CodeOffset: " |
| 491 | << W.hex(Annotation.U1) << ", LineOffset: " << Annotation.S1 |
| 492 | << "}\n"; |
| 493 | break; |
| 494 | } |
| 495 | case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: { |
| 496 | W.startLine() << "ChangeCodeLengthAndCodeOffset: {CodeOffset: " |
| 497 | << W.hex(Annotation.U2) |
| 498 | << ", Length: " << W.hex(Annotation.U1) << "}\n"; |
| 499 | break; |
| 500 | } |
| 501 | } |
| 502 | } |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 503 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 504 | } |
| 505 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 506 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 507 | RegisterSym &Register) { |
Zachary Turner | 6305545 | 2017-06-15 22:24:24 +0000 | [diff] [blame] | 508 | printTypeIndex("Type", Register.Index); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 509 | W.printEnum("Seg", uint16_t(Register.Register), getRegisterNames()); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 510 | W.printString("Name", Register.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 511 | return Error::success(); |
Zachary Turner | 4caa1bf | 2016-05-24 22:58:46 +0000 | [diff] [blame] | 512 | } |
| 513 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 514 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) { |
Reid Kleckner | 18d90e1 | 2017-06-19 16:54:51 +0000 | [diff] [blame] | 515 | W.printFlags("Flags", uint32_t(Public.Flags), getPublicSymFlagNames()); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 516 | W.printNumber("Seg", Public.Segment); |
| 517 | W.printNumber("Off", Public.Offset); |
Zachary Turner | 9e33e6f | 2016-05-24 18:55:14 +0000 | [diff] [blame] | 518 | W.printString("Name", Public.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 519 | return Error::success(); |
Zachary Turner | 9e33e6f | 2016-05-24 18:55:14 +0000 | [diff] [blame] | 520 | } |
| 521 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 522 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcRefSym &ProcRef) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 523 | W.printNumber("SumName", ProcRef.SumName); |
| 524 | W.printNumber("SymOffset", ProcRef.SymOffset); |
| 525 | W.printNumber("Mod", ProcRef.Module); |
Zachary Turner | 9e33e6f | 2016-05-24 18:55:14 +0000 | [diff] [blame] | 526 | W.printString("Name", ProcRef.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 527 | return Error::success(); |
Zachary Turner | 9e33e6f | 2016-05-24 18:55:14 +0000 | [diff] [blame] | 528 | } |
| 529 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 530 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 531 | StringRef LinkageName; |
| 532 | if (ObjDelegate) { |
| 533 | ObjDelegate->printRelocatedField("CodeOffset", Label.getRelocationOffset(), |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 534 | Label.CodeOffset, &LinkageName); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 535 | } |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 536 | W.printHex("Segment", Label.Segment); |
| 537 | W.printHex("Flags", uint8_t(Label.Flags)); |
| 538 | W.printFlags("Flags", uint8_t(Label.Flags), getProcSymFlagNames()); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 539 | W.printString("DisplayName", Label.Name); |
| 540 | if (!LinkageName.empty()) |
| 541 | W.printString("LinkageName", LinkageName); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 542 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 543 | } |
| 544 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 545 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) { |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 546 | printTypeIndex("Type", Local.Type); |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 547 | W.printFlags("Flags", uint16_t(Local.Flags), getLocalFlagNames()); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 548 | W.printString("VarName", Local.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 549 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 550 | } |
| 551 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 552 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ObjNameSym &ObjName) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 553 | W.printHex("Signature", ObjName.Signature); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 554 | W.printString("ObjectName", ObjName.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 555 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 558 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 559 | if (InFunctionScope) |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 560 | return llvm::make_error<CodeViewError>( |
| 561 | "Visiting a ProcSym while inside function scope!"); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 562 | |
| 563 | InFunctionScope = true; |
| 564 | |
| 565 | StringRef LinkageName; |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 566 | W.printHex("PtrParent", Proc.Parent); |
| 567 | W.printHex("PtrEnd", Proc.End); |
| 568 | W.printHex("PtrNext", Proc.Next); |
| 569 | W.printHex("CodeSize", Proc.CodeSize); |
| 570 | W.printHex("DbgStart", Proc.DbgStart); |
| 571 | W.printHex("DbgEnd", Proc.DbgEnd); |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 572 | printTypeIndex("FunctionType", Proc.FunctionType); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 573 | if (ObjDelegate) { |
| 574 | ObjDelegate->printRelocatedField("CodeOffset", Proc.getRelocationOffset(), |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 575 | Proc.CodeOffset, &LinkageName); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 576 | } |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 577 | W.printHex("Segment", Proc.Segment); |
| 578 | W.printFlags("Flags", static_cast<uint8_t>(Proc.Flags), |
Zachary Turner | 93839cb | 2016-06-02 05:07:49 +0000 | [diff] [blame] | 579 | getProcSymFlagNames()); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 580 | W.printString("DisplayName", Proc.Name); |
| 581 | if (!LinkageName.empty()) |
| 582 | W.printString("LinkageName", LinkageName); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 583 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 584 | } |
| 585 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 586 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 587 | ScopeEndSym &ScopeEnd) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 588 | InFunctionScope = false; |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 589 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 590 | } |
| 591 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 592 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) { |
| 593 | ListScope S(W, CVR.kind() == S_CALLEES ? "Callees" : "Callers"); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 594 | for (auto FuncID : Caller.Indices) |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 595 | printTypeIndex("FuncID", FuncID); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 596 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 597 | } |
| 598 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 599 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 600 | RegRelativeSym &RegRel) { |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 601 | W.printHex("Offset", RegRel.Offset); |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 602 | printTypeIndex("Type", RegRel.Type); |
Zachary Turner | 6305545 | 2017-06-15 22:24:24 +0000 | [diff] [blame] | 603 | W.printEnum("Register", uint16_t(RegRel.Register), getRegisterNames()); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 604 | W.printString("VarName", RegRel.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 605 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 606 | } |
| 607 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 608 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 609 | ThreadLocalDataSym &Data) { |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 610 | StringRef LinkageName; |
| 611 | if (ObjDelegate) { |
| 612 | ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(), |
Zachary Turner | 46225b1 | 2016-12-16 22:48:14 +0000 | [diff] [blame] | 613 | Data.DataOffset, &LinkageName); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 614 | } |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 615 | printTypeIndex("Type", Data.Type); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 616 | W.printString("DisplayName", Data.Name); |
| 617 | if (!LinkageName.empty()) |
| 618 | W.printString("LinkageName", LinkageName); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 619 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 620 | } |
| 621 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 622 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) { |
Zachary Turner | 629cb7d | 2017-01-11 23:24:22 +0000 | [diff] [blame] | 623 | printTypeIndex("Type", UDT.Type); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 624 | W.printString("UDTName", UDT.Name); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 625 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 626 | } |
| 627 | |
Alexandre Ganea | ee8a720 | 2018-07-31 19:15:50 +0000 | [diff] [blame] | 628 | Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, |
| 629 | UsingNamespaceSym &UN) { |
| 630 | W.printString("Namespace", UN.Name); |
| 631 | return Error::success(); |
| 632 | } |
| 633 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 634 | Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) { |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 635 | W.printNumber("Length", CVR.length()); |
| 636 | return Error::success(); |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 637 | } |
| 638 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 639 | Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) { |
| 640 | SymbolVisitorCallbackPipeline Pipeline; |
Zachary Turner | ebd3ae8 | 2017-06-01 21:52:41 +0000 | [diff] [blame] | 641 | SymbolDeserializer Deserializer(ObjDelegate.get(), Container); |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 642 | CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, CompilationCPUType, |
| 643 | PrintRecordBytes); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 644 | |
| 645 | Pipeline.addCallbackToPipeline(Deserializer); |
| 646 | Pipeline.addCallbackToPipeline(Dumper); |
| 647 | CVSymbolVisitor Visitor(Pipeline); |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 648 | auto Err = Visitor.visitSymbolRecord(Record); |
| 649 | CompilationCPUType = Dumper.getCompilationCPUType(); |
| 650 | return Err; |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 651 | } |
| 652 | |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 653 | Error CVSymbolDumper::dump(const CVSymbolArray &Symbols) { |
| 654 | SymbolVisitorCallbackPipeline Pipeline; |
Zachary Turner | ebd3ae8 | 2017-06-01 21:52:41 +0000 | [diff] [blame] | 655 | SymbolDeserializer Deserializer(ObjDelegate.get(), Container); |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 656 | CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, CompilationCPUType, |
| 657 | PrintRecordBytes); |
Zachary Turner | 0d84074 | 2016-10-07 21:34:46 +0000 | [diff] [blame] | 658 | |
| 659 | Pipeline.addCallbackToPipeline(Deserializer); |
| 660 | Pipeline.addCallbackToPipeline(Dumper); |
| 661 | CVSymbolVisitor Visitor(Pipeline); |
Reid Kleckner | a6f6426 | 2018-09-11 22:00:50 +0000 | [diff] [blame] | 662 | auto Err = Visitor.visitSymbolStream(Symbols); |
| 663 | CompilationCPUType = Dumper.getCompilationCPUType(); |
| 664 | return Err; |
Zachary Turner | aaad574 | 2016-05-23 23:41:13 +0000 | [diff] [blame] | 665 | } |