Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 1 | //===- FunctionDumper.cpp ------------------------------------ *- 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 "FunctionDumper.h" |
Zachary Turner | d270d22 | 2015-02-26 23:49:23 +0000 | [diff] [blame] | 11 | #include "BuiltinDumper.h" |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 12 | #include "LinePrinter.h" |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 13 | #include "llvm-pdbdump.h" |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 14 | |
| 15 | #include "llvm/DebugInfo/PDB/IPDBSession.h" |
Zachary Turner | ec28fc3 | 2016-05-04 20:32:13 +0000 | [diff] [blame] | 16 | #include "llvm/DebugInfo/PDB/PDBExtras.h" |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 17 | #include "llvm/DebugInfo/PDB/PDBSymbolData.h" |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 18 | #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 19 | #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h" |
| 20 | #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h" |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 21 | #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h" |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 22 | #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" |
| 23 | #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h" |
| 24 | #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h" |
| 25 | #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h" |
| 26 | #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h" |
| 27 | #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 28 | #include "llvm/Support/Format.h" |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 29 | |
Zachary Turner | aea5992 | 2015-02-22 22:20:26 +0000 | [diff] [blame] | 30 | using namespace llvm; |
Reid Kleckner | 72e2ba7 | 2016-01-13 19:32:35 +0000 | [diff] [blame] | 31 | using namespace llvm::codeview; |
Zachary Turner | ec28fc3 | 2016-05-04 20:32:13 +0000 | [diff] [blame] | 32 | using namespace llvm::pdb; |
Zachary Turner | aea5992 | 2015-02-22 22:20:26 +0000 | [diff] [blame] | 33 | |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 34 | namespace { |
| 35 | template <class T> |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 36 | void dumpClassParentWithScopeOperator(const T &Symbol, LinePrinter &Printer, |
Zachary Turner | ec28fc3 | 2016-05-04 20:32:13 +0000 | [diff] [blame] | 37 | FunctionDumper &Dumper) { |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 38 | uint32_t ClassParentId = Symbol.getClassParentId(); |
| 39 | auto ClassParent = |
David Majnemer | 3f45d40 | 2015-02-22 22:33:57 +0000 | [diff] [blame] | 40 | Symbol.getSession().template getConcreteSymbolById<PDBSymbolTypeUDT>( |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 41 | ClassParentId); |
| 42 | if (!ClassParent) |
| 43 | return; |
| 44 | |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 45 | WithColor(Printer, PDB_ColorItem::Type).get() << ClassParent->getName(); |
| 46 | Printer << "::"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 50 | FunctionDumper::FunctionDumper(LinePrinter &P) |
| 51 | : PDBSymDumper(true), Printer(P) {} |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 52 | |
| 53 | void FunctionDumper::start(const PDBSymbolTypeFunctionSig &Symbol, |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 54 | const char *Name, PointerType Pointer) { |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 55 | auto ReturnType = Symbol.getReturnType(); |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 56 | ReturnType->dump(*this); |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 57 | Printer << " "; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 58 | uint32_t ClassParentId = Symbol.getClassParentId(); |
| 59 | auto ClassParent = |
| 60 | Symbol.getSession().getConcreteSymbolById<PDBSymbolTypeUDT>( |
| 61 | ClassParentId); |
| 62 | |
Zachary Turner | ec28fc3 | 2016-05-04 20:32:13 +0000 | [diff] [blame] | 63 | PDB_CallingConv CC = Symbol.getCallingConvention(); |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 64 | bool ShouldDumpCallingConvention = true; |
Reid Kleckner | 72e2ba7 | 2016-01-13 19:32:35 +0000 | [diff] [blame] | 65 | if ((ClassParent && CC == CallingConvention::ThisCall) || |
| 66 | (!ClassParent && CC == CallingConvention::NearStdCall)) { |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 67 | ShouldDumpCallingConvention = false; |
| 68 | } |
| 69 | |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 70 | if (Pointer == PointerType::None) { |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 71 | if (ShouldDumpCallingConvention) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 72 | WithColor(Printer, PDB_ColorItem::Keyword).get() << CC << " "; |
| 73 | if (ClassParent) { |
| 74 | Printer << "("; |
| 75 | WithColor(Printer, PDB_ColorItem::Identifier).get() |
| 76 | << ClassParent->getName(); |
| 77 | Printer << "::)"; |
| 78 | } |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 79 | } else { |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 80 | Printer << "("; |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 81 | if (ShouldDumpCallingConvention) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 82 | WithColor(Printer, PDB_ColorItem::Keyword).get() << CC << " "; |
| 83 | if (ClassParent) { |
| 84 | WithColor(Printer, PDB_ColorItem::Identifier).get() |
| 85 | << ClassParent->getName(); |
| 86 | Printer << "::"; |
| 87 | } |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 88 | if (Pointer == PointerType::Reference) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 89 | Printer << "&"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 90 | else |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 91 | Printer << "*"; |
Zachary Turner | d270d22 | 2015-02-26 23:49:23 +0000 | [diff] [blame] | 92 | if (Name) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 93 | WithColor(Printer, PDB_ColorItem::Identifier).get() << Name; |
| 94 | Printer << ")"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 97 | Printer << "("; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 98 | if (auto ChildEnum = Symbol.getArguments()) { |
| 99 | uint32_t Index = 0; |
| 100 | while (auto Arg = ChildEnum->getNext()) { |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 101 | Arg->dump(*this); |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 102 | if (++Index < ChildEnum->getChildCount()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 103 | Printer << ", "; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 104 | } |
| 105 | } |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 106 | Printer << ")"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 107 | |
| 108 | if (Symbol.isConstType()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 109 | WithColor(Printer, PDB_ColorItem::Keyword).get() << " const"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 110 | if (Symbol.isVolatileType()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 111 | WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 112 | } |
| 113 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 114 | void FunctionDumper::start(const PDBSymbolFunc &Symbol, PointerType Pointer) { |
Zachary Turner | e5cb269 | 2015-05-01 20:24:26 +0000 | [diff] [blame] | 115 | uint64_t FuncStart = Symbol.getVirtualAddress(); |
| 116 | uint64_t FuncEnd = FuncStart + Symbol.getLength(); |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 117 | |
Zachary Turner | 7797c72 | 2015-03-02 04:39:56 +0000 | [diff] [blame] | 118 | Printer << "func ["; |
| 119 | WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(FuncStart, 10); |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 120 | if (auto DebugStart = Symbol.findOneChild<PDBSymbolFuncDebugStart>()) { |
Zachary Turner | e5cb269 | 2015-05-01 20:24:26 +0000 | [diff] [blame] | 121 | uint64_t Prologue = DebugStart->getVirtualAddress() - FuncStart; |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 122 | WithColor(Printer, PDB_ColorItem::Offset).get() << "+" << Prologue; |
| 123 | } |
Zachary Turner | 7797c72 | 2015-03-02 04:39:56 +0000 | [diff] [blame] | 124 | Printer << " - "; |
| 125 | WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(FuncEnd, 10); |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 126 | if (auto DebugEnd = Symbol.findOneChild<PDBSymbolFuncDebugEnd>()) { |
Zachary Turner | e5cb269 | 2015-05-01 20:24:26 +0000 | [diff] [blame] | 127 | uint64_t Epilogue = FuncEnd - DebugEnd->getVirtualAddress(); |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 128 | WithColor(Printer, PDB_ColorItem::Offset).get() << "-" << Epilogue; |
| 129 | } |
Zachary Turner | 7797c72 | 2015-03-02 04:39:56 +0000 | [diff] [blame] | 130 | Printer << "] ("; |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 131 | |
Zachary Turner | 7797c72 | 2015-03-02 04:39:56 +0000 | [diff] [blame] | 132 | if (Symbol.hasFramePointer()) { |
| 133 | WithColor(Printer, PDB_ColorItem::Register).get() |
| 134 | << Symbol.getLocalBasePointerRegisterId(); |
| 135 | } else { |
| 136 | WithColor(Printer, PDB_ColorItem::Register).get() << "FPO"; |
| 137 | } |
| 138 | Printer << ") "; |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 139 | |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 140 | if (Symbol.isVirtual() || Symbol.isPureVirtual()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 141 | WithColor(Printer, PDB_ColorItem::Keyword).get() << "virtual "; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 142 | |
| 143 | auto Signature = Symbol.getSignature(); |
| 144 | if (!Signature) { |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 145 | WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName(); |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 146 | if (Pointer == PointerType::Pointer) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 147 | Printer << "*"; |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 148 | else if (Pointer == FunctionDumper::PointerType::Reference) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 149 | Printer << "&"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 150 | return; |
| 151 | } |
| 152 | |
| 153 | auto ReturnType = Signature->getReturnType(); |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 154 | ReturnType->dump(*this); |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 155 | Printer << " "; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 156 | |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 157 | auto ClassParent = Symbol.getClassParent(); |
Reid Kleckner | 72e2ba7 | 2016-01-13 19:32:35 +0000 | [diff] [blame] | 158 | CallingConvention CC = Signature->getCallingConvention(); |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 159 | if (Pointer != FunctionDumper::PointerType::None) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 160 | Printer << "("; |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 161 | |
Reid Kleckner | 72e2ba7 | 2016-01-13 19:32:35 +0000 | [diff] [blame] | 162 | if ((ClassParent && CC != CallingConvention::ThisCall) || |
| 163 | (!ClassParent && CC != CallingConvention::NearStdCall)) { |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 164 | WithColor(Printer, PDB_ColorItem::Keyword).get() |
| 165 | << Signature->getCallingConvention() << " "; |
| 166 | } |
| 167 | WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName(); |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 168 | if (Pointer != FunctionDumper::PointerType::None) { |
| 169 | if (Pointer == PointerType::Pointer) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 170 | Printer << "*"; |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 171 | else if (Pointer == FunctionDumper::PointerType::Reference) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 172 | Printer << "&"; |
| 173 | Printer << ")"; |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 174 | } |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 175 | |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 176 | Printer << "("; |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 177 | if (auto Arguments = Symbol.getArguments()) { |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 178 | uint32_t Index = 0; |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 179 | while (auto Arg = Arguments->getNext()) { |
| 180 | auto ArgType = Arg->getType(); |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 181 | ArgType->dump(*this); |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 182 | WithColor(Printer, PDB_ColorItem::Identifier).get() << " " |
| 183 | << Arg->getName(); |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 184 | if (++Index < Arguments->getChildCount()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 185 | Printer << ", "; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 186 | } |
| 187 | } |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 188 | Printer << ")"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 189 | if (Symbol.isConstType()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 190 | WithColor(Printer, PDB_ColorItem::Keyword).get() << " const"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 191 | if (Symbol.isVolatileType()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 192 | WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 193 | if (Symbol.isPureVirtual()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 194 | Printer << " = 0"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 195 | } |
| 196 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 197 | void FunctionDumper::dump(const PDBSymbolTypeArray &Symbol) { |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 198 | uint32_t ElementTypeId = Symbol.getTypeId(); |
| 199 | auto ElementType = Symbol.getSession().getSymbolById(ElementTypeId); |
| 200 | if (!ElementType) |
| 201 | return; |
| 202 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 203 | ElementType->dump(*this); |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 204 | Printer << "["; |
| 205 | WithColor(Printer, PDB_ColorItem::LiteralValue).get() << Symbol.getLength(); |
| 206 | Printer << "]"; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 209 | void FunctionDumper::dump(const PDBSymbolTypeBuiltin &Symbol) { |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 210 | BuiltinDumper Dumper(Printer); |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 211 | Dumper.start(Symbol); |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 212 | } |
| 213 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 214 | void FunctionDumper::dump(const PDBSymbolTypeEnum &Symbol) { |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 215 | dumpClassParentWithScopeOperator(Symbol, Printer, *this); |
| 216 | WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName(); |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 217 | } |
| 218 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 219 | void FunctionDumper::dump(const PDBSymbolTypeFunctionArg &Symbol) { |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 220 | // PDBSymbolTypeFunctionArg is just a shim over the real argument. Just drill |
Zachary Turner | 29c6910 | 2015-02-23 05:58:34 +0000 | [diff] [blame] | 221 | // through to the real thing and dump it. |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 222 | uint32_t TypeId = Symbol.getTypeId(); |
| 223 | auto Type = Symbol.getSession().getSymbolById(TypeId); |
| 224 | if (!Type) |
| 225 | return; |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 226 | Type->dump(*this); |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 229 | void FunctionDumper::dump(const PDBSymbolTypeTypedef &Symbol) { |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 230 | dumpClassParentWithScopeOperator(Symbol, Printer, *this); |
| 231 | WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName(); |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 232 | } |
| 233 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 234 | void FunctionDumper::dump(const PDBSymbolTypePointer &Symbol) { |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 235 | uint32_t PointeeId = Symbol.getTypeId(); |
| 236 | auto PointeeType = Symbol.getSession().getSymbolById(PointeeId); |
| 237 | if (!PointeeType) |
| 238 | return; |
| 239 | |
| 240 | if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) { |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 241 | FunctionDumper NestedDumper(Printer); |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 242 | PointerType Pointer = |
| 243 | Symbol.isReference() ? PointerType::Reference : PointerType::Pointer; |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 244 | NestedDumper.start(*FuncSig, nullptr, Pointer); |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 245 | } else { |
| 246 | if (Symbol.isConstType()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 247 | WithColor(Printer, PDB_ColorItem::Keyword).get() << "const "; |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 248 | if (Symbol.isVolatileType()) |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 249 | WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile "; |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 250 | PointeeType->dump(*this); |
| 251 | Printer << (Symbol.isReference() ? "&" : "*"); |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 252 | } |
| 253 | } |
| 254 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 255 | void FunctionDumper::dump(const PDBSymbolTypeUDT &Symbol) { |
Zachary Turner | 2d11c20 | 2015-02-27 09:15:59 +0000 | [diff] [blame] | 256 | WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName(); |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 257 | } |