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