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