llvm.org GIT mirror llvm / e1b020a
[PDB] Add native support for dumping array types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343412 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 11 months ago
11 changed file(s) with 186 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 //===- NativeTypeArray.h ------------------------------------------ C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEARRAY_H
10 #define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEARRAY_H
11
12 #include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
13
14 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
15 #include "llvm/DebugInfo/PDB/PDBTypes.h"
16
17 namespace llvm {
18 namespace pdb {
19
20 class NativeSession;
21
22 class NativeTypeArray : public NativeRawSymbol {
23 public:
24 NativeTypeArray(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI,
25 codeview::ArrayRecord Record);
26 ~NativeTypeArray() override;
27
28 void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
29 PdbSymbolIdField RecurseIdFields) const override;
30
31 SymIndexId getArrayIndexTypeId() const override;
32
33 bool isConstType() const override;
34 bool isUnalignedType() const override;
35 bool isVolatileType() const override;
36
37 uint32_t getCount() const override;
38 SymIndexId getTypeId() const override;
39 uint64_t getLength() const override;
40
41 protected:
42 codeview::ArrayRecord Record;
43 codeview::TypeIndex Index;
44 };
45
46 } // namespace pdb
47 } // namespace llvm
48
49 #endif
5151 Native/NativeExeSymbol.cpp
5252 Native/NativeRawSymbol.cpp
5353 Native/NativeSymbolEnumerator.cpp
54 Native/NativeTypeArray.cpp
5455 Native/NativeTypeBuiltin.cpp
5556 Native/NativeTypeEnum.cpp
5657 Native/NativeTypeFunctionSig.cpp
4040 return std::unique_ptr(new NativeEnumModules(Session));
4141 break;
4242 }
43 case PDB_SymType::ArrayType:
44 return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ARRAY);
4345 case PDB_SymType::Enum:
4446 return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ENUM);
4547 case PDB_SymType::PointerType:
0 //===- NativeTypeArray.cpp - info about arrays ------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/DebugInfo/PDB/Native/NativeTypeArray.h"
10
11 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
12 #include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
13 #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
14
15 using namespace llvm;
16 using namespace llvm::codeview;
17 using namespace llvm::pdb;
18
19 NativeTypeArray::NativeTypeArray(NativeSession &Session, SymIndexId Id,
20 codeview::TypeIndex TI,
21 codeview::ArrayRecord Record)
22 : NativeRawSymbol(Session, PDB_SymType::ArrayType, Id), Record(Record),
23 Index(TI) {}
24 NativeTypeArray::~NativeTypeArray() {}
25
26 void NativeTypeArray::dump(raw_ostream &OS, int Indent,
27 PdbSymbolIdField ShowIdFields,
28 PdbSymbolIdField RecurseIdFields) const {
29 NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
30
31 dumpSymbolField(OS, "arrayIndexTypeId", getArrayIndexTypeId(), Indent);
32 dumpSymbolIdField(OS, "elementTypeId", getTypeId(), Indent, Session,
33 PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
34
35 dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
36 PdbSymbolIdField::LexicalParent, ShowIdFields,
37 RecurseIdFields);
38 dumpSymbolField(OS, "length", getLength(), Indent);
39 dumpSymbolField(OS, "count", getCount(), Indent);
40 dumpSymbolField(OS, "constType", isConstType(), Indent);
41 dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
42 dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
43 }
44
45 SymIndexId NativeTypeArray::getArrayIndexTypeId() const {
46 return Session.getSymbolCache().findSymbolByTypeIndex(Record.getIndexType());
47 }
48
49 bool NativeTypeArray::isConstType() const { return false; }
50
51 bool NativeTypeArray::isUnalignedType() const { return false; }
52
53 bool NativeTypeArray::isVolatileType() const { return false; }
54
55 uint32_t NativeTypeArray::getCount() const {
56 NativeRawSymbol &Element =
57 Session.getSymbolCache().getNativeSymbolById(getTypeId());
58 return getLength() / Element.getLength();
59 }
60
61 SymIndexId NativeTypeArray::getTypeId() const {
62 return Session.getSymbolCache().findSymbolByTypeIndex(
63 Record.getElementType());
64 }
65
66 uint64_t NativeTypeArray::getLength() const { return Record.Size; }
66 #include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h"
77 #include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
88 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
9 #include "llvm/DebugInfo/PDB/Native/NativeTypeArray.h"
910 #include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
1011 #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
1112 #include "llvm/DebugInfo/PDB/Native/NativeTypeFunctionSig.h"
167168 case codeview::LF_ENUM:
168169 Id = createSymbolForType(Index, std::move(CVT));
169170 break;
171 case codeview::LF_ARRAY:
172 Id = createSymbolForType(Index,
173 std::move(CVT));
174 break;
170175 case codeview::LF_CLASS:
171176 case codeview::LF_STRUCTURE:
172177 case codeview::LF_INTERFACE:
0 // Build with "cl.exe /Zi /GR- /GX- every-array.cpp /link /debug /nodefaultlib /entry:main"
1
2 // clang-format off
3 void *__purecall = 0;
4
5 void __cdecl operator delete(void *,unsigned int) {}
6 void __cdecl operator delete(void *,unsigned __int64) {}
7
8
9 int func1() { return 42; }
10 int func2() { return 43; }
11 int func3() { return 44; }
12
13 template
14 void Reference(T &t) { }
15
16 int IA[3] = {1, 2, 3};
17 const int CIA[3] = {1, 2, 3};
18 volatile int VIA[3] = {1, 2, 3};
19
20 using FuncPtr = decltype(&func1);
21 FuncPtr FA[3] = {&func1, &func2, &func3};
22
23 struct S {
24 int N;
25 int f() const { return 42; }
26 };
27
28 using MemDataPtr = decltype(&S::N);
29 using MemFunPtr = decltype(&S::f);
30
31 MemDataPtr MDA[1] = {&S::N};
32 MemFunPtr MFA[1] = {&S::f};
33
34
35 int main(int argc, char **argv) {
36 }
1818
1919 #include "llvm/DebugInfo/PDB/IPDBSession.h"
2020 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
2122 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
2223 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
2324 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
200201 if (opts::pretty::Typedefs)
201202 dumpSymbolCategory(Printer, Exe, *this, "Typedefs");
202203
204 if (opts::pretty::Arrays)
205 dumpSymbolCategory(Printer, Exe, *this, "Arrays");
206
203207 if (opts::pretty::Pointers)
204208 dumpSymbolCategory(Printer, Exe, *this, "Pointers");
205209
283287 Dumper.start(Symbol);
284288 }
285289
290 void TypeDumper::dump(const PDBSymbolTypeArray &Symbol) {
291 auto ElementType = Symbol.getElementType();
292
293 ElementType->dump(*this);
294 Printer << "[";
295 WithColor(Printer, PDB_ColorItem::LiteralValue).get() << Symbol.getCount();
296 Printer << "]";
297 }
298
286299 void TypeDumper::dump(const PDBSymbolTypeFunctionSig &Symbol) {
287300 FunctionDumper Dumper(Printer);
288301 Dumper.start(Symbol, nullptr, FunctionDumper::PointerType::None);
2525 void dump(const PDBSymbolTypeEnum &Symbol) override;
2626 void dump(const PDBSymbolTypeTypedef &Symbol) override;
2727 void dump(const PDBSymbolTypeFunctionSig &Symbol) override;
28 void dump(const PDBSymbolTypeArray &Symbol) override;
2829 void dump(const PDBSymbolTypeBuiltin &Symbol) override;
2930 void dump(const PDBSymbolTypePointer &Symbol) override;
3031
192192 static cl::opt Funcsigs("funcsigs",
193193 cl::desc("Dump function signature information"),
194194 cl::sub(DiaDumpSubcommand));
195 static cl::opt Arrays("arrays", cl::desc("Dump array types"),
196 cl::sub(DiaDumpSubcommand));
195197 } // namespace diadump
196198
197199 namespace pretty {
244246 cl::cat(TypeCategory), cl::sub(PrettySubcommand));
245247 cl::opt Pointers("pointers", cl::desc("Display pointer types"),
246248 cl::cat(TypeCategory), cl::sub(PrettySubcommand));
249 cl::opt Arrays("arrays", cl::desc("Display arrays"),
250 cl::cat(TypeCategory), cl::sub(PrettySubcommand));
247251
248252 cl::opt SymbolOrder(
249253 "symbol-order", cl::desc("symbol sort order"),
10141018 SymTypes.push_back(PDB_SymType::UDT);
10151019 if (opts::diadump::Funcsigs)
10161020 SymTypes.push_back(PDB_SymType::FunctionSig);
1017
1021 if (opts::diadump::Arrays)
1022 SymTypes.push_back(PDB_SymType::ArrayType);
10181023 PdbSymbolIdField Ids = opts::diadump::NoSymIndexIds ? PdbSymbolIdField::None
10191024 : PdbSymbolIdField::All;
10201025 PdbSymbolIdField Recurse = PdbSymbolIdField::None;
11811186 }
11821187
11831188 if (opts::pretty::Classes || opts::pretty::Enums || opts::pretty::Typedefs ||
1184 opts::pretty::Funcsigs || opts::pretty::Pointers) {
1189 opts::pretty::Funcsigs || opts::pretty::Pointers ||
1190 opts::pretty::Arrays) {
11851191 Printer.NewLine();
11861192 WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---TYPES---";
11871193 Printer.Indent();
12741280 dumpInjectedSources(Printer, *Session);
12751281 }
12761282
1283 Printer.NewLine();
12771284 outs().flush();
12781285 }
12791286
8282 extern llvm::cl::opt Classes;
8383 extern llvm::cl::opt Enums;
8484 extern llvm::cl::opt Funcsigs;
85 extern llvm::cl::opt Arrays;
8586 extern llvm::cl::opt Typedefs;
8687 extern llvm::cl::opt Pointers;
8788 extern llvm::cl::opt All;