mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[PDB] Add native support for dumping array types.
llvm-svn: 343412
This commit is contained in:
parent
aa519f0231
commit
3032fee0fa
50
include/llvm/DebugInfo/PDB/Native/NativeTypeArray.h
Normal file
50
include/llvm/DebugInfo/PDB/Native/NativeTypeArray.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
//===- NativeTypeArray.h ------------------------------------------ C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEARRAY_H
|
||||||
|
#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEARRAY_H
|
||||||
|
|
||||||
|
#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
|
||||||
|
|
||||||
|
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
|
||||||
|
#include "llvm/DebugInfo/PDB/PDBTypes.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
namespace pdb {
|
||||||
|
|
||||||
|
class NativeSession;
|
||||||
|
|
||||||
|
class NativeTypeArray : public NativeRawSymbol {
|
||||||
|
public:
|
||||||
|
NativeTypeArray(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI,
|
||||||
|
codeview::ArrayRecord Record);
|
||||||
|
~NativeTypeArray() override;
|
||||||
|
|
||||||
|
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields,
|
||||||
|
PdbSymbolIdField RecurseIdFields) const override;
|
||||||
|
|
||||||
|
SymIndexId getArrayIndexTypeId() const override;
|
||||||
|
|
||||||
|
bool isConstType() const override;
|
||||||
|
bool isUnalignedType() const override;
|
||||||
|
bool isVolatileType() const override;
|
||||||
|
|
||||||
|
uint32_t getCount() const override;
|
||||||
|
SymIndexId getTypeId() const override;
|
||||||
|
uint64_t getLength() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
codeview::ArrayRecord Record;
|
||||||
|
codeview::TypeIndex Index;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pdb
|
||||||
|
} // namespace llvm
|
||||||
|
|
||||||
|
#endif
|
@ -52,6 +52,7 @@ add_pdb_impl_folder(Native
|
|||||||
Native/NativeExeSymbol.cpp
|
Native/NativeExeSymbol.cpp
|
||||||
Native/NativeRawSymbol.cpp
|
Native/NativeRawSymbol.cpp
|
||||||
Native/NativeSymbolEnumerator.cpp
|
Native/NativeSymbolEnumerator.cpp
|
||||||
|
Native/NativeTypeArray.cpp
|
||||||
Native/NativeTypeBuiltin.cpp
|
Native/NativeTypeBuiltin.cpp
|
||||||
Native/NativeTypeEnum.cpp
|
Native/NativeTypeEnum.cpp
|
||||||
Native/NativeTypeFunctionSig.cpp
|
Native/NativeTypeFunctionSig.cpp
|
||||||
|
@ -41,6 +41,8 @@ NativeExeSymbol::findChildren(PDB_SymType Type) const {
|
|||||||
return std::unique_ptr<IPDBEnumSymbols>(new NativeEnumModules(Session));
|
return std::unique_ptr<IPDBEnumSymbols>(new NativeEnumModules(Session));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case PDB_SymType::ArrayType:
|
||||||
|
return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ARRAY);
|
||||||
case PDB_SymType::Enum:
|
case PDB_SymType::Enum:
|
||||||
return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ENUM);
|
return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ENUM);
|
||||||
case PDB_SymType::PointerType:
|
case PDB_SymType::PointerType:
|
||||||
|
67
lib/DebugInfo/PDB/Native/NativeTypeArray.cpp
Normal file
67
lib/DebugInfo/PDB/Native/NativeTypeArray.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
//===- NativeTypeArray.cpp - info about arrays ------------------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/DebugInfo/PDB/Native/NativeTypeArray.h"
|
||||||
|
|
||||||
|
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
|
||||||
|
#include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
|
||||||
|
#include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
|
||||||
|
|
||||||
|
using namespace llvm;
|
||||||
|
using namespace llvm::codeview;
|
||||||
|
using namespace llvm::pdb;
|
||||||
|
|
||||||
|
NativeTypeArray::NativeTypeArray(NativeSession &Session, SymIndexId Id,
|
||||||
|
codeview::TypeIndex TI,
|
||||||
|
codeview::ArrayRecord Record)
|
||||||
|
: NativeRawSymbol(Session, PDB_SymType::ArrayType, Id), Record(Record),
|
||||||
|
Index(TI) {}
|
||||||
|
NativeTypeArray::~NativeTypeArray() {}
|
||||||
|
|
||||||
|
void NativeTypeArray::dump(raw_ostream &OS, int Indent,
|
||||||
|
PdbSymbolIdField ShowIdFields,
|
||||||
|
PdbSymbolIdField RecurseIdFields) const {
|
||||||
|
NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
|
||||||
|
|
||||||
|
dumpSymbolField(OS, "arrayIndexTypeId", getArrayIndexTypeId(), Indent);
|
||||||
|
dumpSymbolIdField(OS, "elementTypeId", getTypeId(), Indent, Session,
|
||||||
|
PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
|
||||||
|
|
||||||
|
dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
|
||||||
|
PdbSymbolIdField::LexicalParent, ShowIdFields,
|
||||||
|
RecurseIdFields);
|
||||||
|
dumpSymbolField(OS, "length", getLength(), Indent);
|
||||||
|
dumpSymbolField(OS, "count", getCount(), Indent);
|
||||||
|
dumpSymbolField(OS, "constType", isConstType(), Indent);
|
||||||
|
dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
|
||||||
|
dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
|
||||||
|
}
|
||||||
|
|
||||||
|
SymIndexId NativeTypeArray::getArrayIndexTypeId() const {
|
||||||
|
return Session.getSymbolCache().findSymbolByTypeIndex(Record.getIndexType());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NativeTypeArray::isConstType() const { return false; }
|
||||||
|
|
||||||
|
bool NativeTypeArray::isUnalignedType() const { return false; }
|
||||||
|
|
||||||
|
bool NativeTypeArray::isVolatileType() const { return false; }
|
||||||
|
|
||||||
|
uint32_t NativeTypeArray::getCount() const {
|
||||||
|
NativeRawSymbol &Element =
|
||||||
|
Session.getSymbolCache().getNativeSymbolById(getTypeId());
|
||||||
|
return getLength() / Element.getLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
SymIndexId NativeTypeArray::getTypeId() const {
|
||||||
|
return Session.getSymbolCache().findSymbolByTypeIndex(
|
||||||
|
Record.getElementType());
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t NativeTypeArray::getLength() const { return Record.Size; }
|
@ -7,6 +7,7 @@
|
|||||||
#include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h"
|
#include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h"
|
||||||
#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
|
#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
|
||||||
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
|
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
|
||||||
|
#include "llvm/DebugInfo/PDB/Native/NativeTypeArray.h"
|
||||||
#include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
|
#include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
|
||||||
#include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
|
#include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
|
||||||
#include "llvm/DebugInfo/PDB/Native/NativeTypeFunctionSig.h"
|
#include "llvm/DebugInfo/PDB/Native/NativeTypeFunctionSig.h"
|
||||||
@ -168,6 +169,10 @@ SymIndexId SymbolCache::findSymbolByTypeIndex(codeview::TypeIndex Index) {
|
|||||||
case codeview::LF_ENUM:
|
case codeview::LF_ENUM:
|
||||||
Id = createSymbolForType<NativeTypeEnum, EnumRecord>(Index, std::move(CVT));
|
Id = createSymbolForType<NativeTypeEnum, EnumRecord>(Index, std::move(CVT));
|
||||||
break;
|
break;
|
||||||
|
case codeview::LF_ARRAY:
|
||||||
|
Id = createSymbolForType<NativeTypeArray, ArrayRecord>(Index,
|
||||||
|
std::move(CVT));
|
||||||
|
break;
|
||||||
case codeview::LF_CLASS:
|
case codeview::LF_CLASS:
|
||||||
case codeview::LF_STRUCTURE:
|
case codeview::LF_STRUCTURE:
|
||||||
case codeview::LF_INTERFACE:
|
case codeview::LF_INTERFACE:
|
||||||
|
37
test/DebugInfo/PDB/Inputs/every-array.cpp
Normal file
37
test/DebugInfo/PDB/Inputs/every-array.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Build with "cl.exe /Zi /GR- /GX- every-array.cpp /link /debug /nodefaultlib /entry:main"
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
void *__purecall = 0;
|
||||||
|
|
||||||
|
void __cdecl operator delete(void *,unsigned int) {}
|
||||||
|
void __cdecl operator delete(void *,unsigned __int64) {}
|
||||||
|
|
||||||
|
|
||||||
|
int func1() { return 42; }
|
||||||
|
int func2() { return 43; }
|
||||||
|
int func3() { return 44; }
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void Reference(T &t) { }
|
||||||
|
|
||||||
|
int IA[3] = {1, 2, 3};
|
||||||
|
const int CIA[3] = {1, 2, 3};
|
||||||
|
volatile int VIA[3] = {1, 2, 3};
|
||||||
|
|
||||||
|
using FuncPtr = decltype(&func1);
|
||||||
|
FuncPtr FA[3] = {&func1, &func2, &func3};
|
||||||
|
|
||||||
|
struct S {
|
||||||
|
int N;
|
||||||
|
int f() const { return 42; }
|
||||||
|
};
|
||||||
|
|
||||||
|
using MemDataPtr = decltype(&S::N);
|
||||||
|
using MemFunPtr = decltype(&S::f);
|
||||||
|
|
||||||
|
MemDataPtr MDA[1] = {&S::N};
|
||||||
|
MemFunPtr MFA[1] = {&S::f};
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
}
|
BIN
test/DebugInfo/PDB/Inputs/every-array.pdb
Normal file
BIN
test/DebugInfo/PDB/Inputs/every-array.pdb
Normal file
Binary file not shown.
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "llvm/DebugInfo/PDB/IPDBSession.h"
|
#include "llvm/DebugInfo/PDB/IPDBSession.h"
|
||||||
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
|
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
|
||||||
|
#include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
|
||||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
|
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
|
||||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
|
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
|
||||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
|
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
|
||||||
@ -201,6 +202,9 @@ void TypeDumper::start(const PDBSymbolExe &Exe) {
|
|||||||
if (opts::pretty::Typedefs)
|
if (opts::pretty::Typedefs)
|
||||||
dumpSymbolCategory<PDBSymbolTypeTypedef>(Printer, Exe, *this, "Typedefs");
|
dumpSymbolCategory<PDBSymbolTypeTypedef>(Printer, Exe, *this, "Typedefs");
|
||||||
|
|
||||||
|
if (opts::pretty::Arrays)
|
||||||
|
dumpSymbolCategory<PDBSymbolTypeArray>(Printer, Exe, *this, "Arrays");
|
||||||
|
|
||||||
if (opts::pretty::Pointers)
|
if (opts::pretty::Pointers)
|
||||||
dumpSymbolCategory<PDBSymbolTypePointer>(Printer, Exe, *this, "Pointers");
|
dumpSymbolCategory<PDBSymbolTypePointer>(Printer, Exe, *this, "Pointers");
|
||||||
|
|
||||||
@ -284,6 +288,15 @@ void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol) {
|
|||||||
Dumper.start(Symbol);
|
Dumper.start(Symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TypeDumper::dump(const PDBSymbolTypeArray &Symbol) {
|
||||||
|
auto ElementType = Symbol.getElementType();
|
||||||
|
|
||||||
|
ElementType->dump(*this);
|
||||||
|
Printer << "[";
|
||||||
|
WithColor(Printer, PDB_ColorItem::LiteralValue).get() << Symbol.getCount();
|
||||||
|
Printer << "]";
|
||||||
|
}
|
||||||
|
|
||||||
void TypeDumper::dump(const PDBSymbolTypeFunctionSig &Symbol) {
|
void TypeDumper::dump(const PDBSymbolTypeFunctionSig &Symbol) {
|
||||||
FunctionDumper Dumper(Printer);
|
FunctionDumper Dumper(Printer);
|
||||||
Dumper.start(Symbol, nullptr, FunctionDumper::PointerType::None);
|
Dumper.start(Symbol, nullptr, FunctionDumper::PointerType::None);
|
||||||
|
@ -26,6 +26,7 @@ public:
|
|||||||
void dump(const PDBSymbolTypeEnum &Symbol) override;
|
void dump(const PDBSymbolTypeEnum &Symbol) override;
|
||||||
void dump(const PDBSymbolTypeTypedef &Symbol) override;
|
void dump(const PDBSymbolTypeTypedef &Symbol) override;
|
||||||
void dump(const PDBSymbolTypeFunctionSig &Symbol) override;
|
void dump(const PDBSymbolTypeFunctionSig &Symbol) override;
|
||||||
|
void dump(const PDBSymbolTypeArray &Symbol) override;
|
||||||
void dump(const PDBSymbolTypeBuiltin &Symbol) override;
|
void dump(const PDBSymbolTypeBuiltin &Symbol) override;
|
||||||
void dump(const PDBSymbolTypePointer &Symbol) override;
|
void dump(const PDBSymbolTypePointer &Symbol) override;
|
||||||
|
|
||||||
|
@ -193,6 +193,8 @@ static cl::opt<bool> Compilands("compilands",
|
|||||||
static cl::opt<bool> Funcsigs("funcsigs",
|
static cl::opt<bool> Funcsigs("funcsigs",
|
||||||
cl::desc("Dump function signature information"),
|
cl::desc("Dump function signature information"),
|
||||||
cl::sub(DiaDumpSubcommand));
|
cl::sub(DiaDumpSubcommand));
|
||||||
|
static cl::opt<bool> Arrays("arrays", cl::desc("Dump array types"),
|
||||||
|
cl::sub(DiaDumpSubcommand));
|
||||||
} // namespace diadump
|
} // namespace diadump
|
||||||
|
|
||||||
namespace pretty {
|
namespace pretty {
|
||||||
@ -245,6 +247,8 @@ cl::opt<bool> Funcsigs("funcsigs", cl::desc("Display function signatures"),
|
|||||||
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
|
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
|
||||||
cl::opt<bool> Pointers("pointers", cl::desc("Display pointer types"),
|
cl::opt<bool> Pointers("pointers", cl::desc("Display pointer types"),
|
||||||
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
|
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
|
||||||
|
cl::opt<bool> Arrays("arrays", cl::desc("Display arrays"),
|
||||||
|
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
|
||||||
|
|
||||||
cl::opt<SymbolSortMode> SymbolOrder(
|
cl::opt<SymbolSortMode> SymbolOrder(
|
||||||
"symbol-order", cl::desc("symbol sort order"),
|
"symbol-order", cl::desc("symbol sort order"),
|
||||||
@ -1015,7 +1019,8 @@ static void dumpDia(StringRef Path) {
|
|||||||
SymTypes.push_back(PDB_SymType::UDT);
|
SymTypes.push_back(PDB_SymType::UDT);
|
||||||
if (opts::diadump::Funcsigs)
|
if (opts::diadump::Funcsigs)
|
||||||
SymTypes.push_back(PDB_SymType::FunctionSig);
|
SymTypes.push_back(PDB_SymType::FunctionSig);
|
||||||
|
if (opts::diadump::Arrays)
|
||||||
|
SymTypes.push_back(PDB_SymType::ArrayType);
|
||||||
PdbSymbolIdField Ids = opts::diadump::NoSymIndexIds ? PdbSymbolIdField::None
|
PdbSymbolIdField Ids = opts::diadump::NoSymIndexIds ? PdbSymbolIdField::None
|
||||||
: PdbSymbolIdField::All;
|
: PdbSymbolIdField::All;
|
||||||
PdbSymbolIdField Recurse = PdbSymbolIdField::None;
|
PdbSymbolIdField Recurse = PdbSymbolIdField::None;
|
||||||
@ -1182,7 +1187,8 @@ static void dumpPretty(StringRef Path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opts::pretty::Classes || opts::pretty::Enums || opts::pretty::Typedefs ||
|
if (opts::pretty::Classes || opts::pretty::Enums || opts::pretty::Typedefs ||
|
||||||
opts::pretty::Funcsigs || opts::pretty::Pointers) {
|
opts::pretty::Funcsigs || opts::pretty::Pointers ||
|
||||||
|
opts::pretty::Arrays) {
|
||||||
Printer.NewLine();
|
Printer.NewLine();
|
||||||
WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---TYPES---";
|
WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---TYPES---";
|
||||||
Printer.Indent();
|
Printer.Indent();
|
||||||
@ -1275,6 +1281,7 @@ static void dumpPretty(StringRef Path) {
|
|||||||
dumpInjectedSources(Printer, *Session);
|
dumpInjectedSources(Printer, *Session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Printer.NewLine();
|
||||||
outs().flush();
|
outs().flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ extern llvm::cl::opt<bool> Globals;
|
|||||||
extern llvm::cl::opt<bool> Classes;
|
extern llvm::cl::opt<bool> Classes;
|
||||||
extern llvm::cl::opt<bool> Enums;
|
extern llvm::cl::opt<bool> Enums;
|
||||||
extern llvm::cl::opt<bool> Funcsigs;
|
extern llvm::cl::opt<bool> Funcsigs;
|
||||||
|
extern llvm::cl::opt<bool> Arrays;
|
||||||
extern llvm::cl::opt<bool> Typedefs;
|
extern llvm::cl::opt<bool> Typedefs;
|
||||||
extern llvm::cl::opt<bool> Pointers;
|
extern llvm::cl::opt<bool> Pointers;
|
||||||
extern llvm::cl::opt<bool> All;
|
extern llvm::cl::opt<bool> All;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user