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