forked from OSchip/llvm-project
Introduce NativeEnumModules and NativeCompilandSymbol
Together, these allow lldb-pdbdump to list all the modules from a PDB using a native reader (rather than DIA). Note that I'll probably be specializing NativeRawSymbol in a subsequent patch. Differential Revision: https://reviews.llvm.org/D30956 llvm-svn: 297883
This commit is contained in:
parent
9fd6ee6a78
commit
65d2688842
|
@ -0,0 +1,35 @@
|
|||
//===- NativeCompilandSymbol.h - native impl for compiland syms -*- 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_NATIVECOMPILANDSYMBOL_H
|
||||
#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVECOMPILANDSYMBOL_H
|
||||
|
||||
#include "llvm/DebugInfo/PDB/Native/ModInfo.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
|
||||
class NativeCompilandSymbol : public NativeRawSymbol {
|
||||
public:
|
||||
NativeCompilandSymbol(NativeSession &Session, const ModuleInfoEx &MI);
|
||||
PDB_SymType getSymTag() const override;
|
||||
bool isEditAndContinueEnabled() const override;
|
||||
uint32_t getLexicalParentId() const override;
|
||||
std::string getLibraryName() const override;
|
||||
std::string getName() const override;
|
||||
|
||||
private:
|
||||
ModuleInfoEx Module;
|
||||
};
|
||||
|
||||
} // namespace pdb
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
|
@ -0,0 +1,41 @@
|
|||
//==- NativeEnumModules.h - Native Module Enumerator impl --------*- 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_NATIVEENUMMODULES_H
|
||||
#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMMODULES_H
|
||||
|
||||
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/ModInfo.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
|
||||
class NativeSession;
|
||||
|
||||
class NativeEnumModules : public IPDBEnumChildren<PDBSymbol> {
|
||||
public:
|
||||
explicit NativeEnumModules(NativeSession &Session,
|
||||
ArrayRef<ModuleInfoEx> Modules,
|
||||
uint32_t Index = 0);
|
||||
|
||||
uint32_t getChildCount() const override;
|
||||
std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override;
|
||||
std::unique_ptr<PDBSymbol> getNext() override;
|
||||
void reset() override;
|
||||
NativeEnumModules *clone() const override;
|
||||
|
||||
private:
|
||||
NativeSession &Session;
|
||||
ArrayRef<ModuleInfoEx> Modules;
|
||||
uint32_t Index;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -39,6 +39,8 @@ add_pdb_impl_folder(Native
|
|||
Native/InfoStreamBuilder.cpp
|
||||
Native/ModInfo.cpp
|
||||
Native/ModStream.cpp
|
||||
Native/NativeCompilandSymbol.cpp
|
||||
Native/NativeEnumModules.cpp
|
||||
Native/NativeRawSymbol.cpp
|
||||
Native/NamedStreamMap.cpp
|
||||
Native/NativeSession.cpp
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
//===- NativeCompilandSymbol.h - Native impl of PDBCompilandSymbol -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/NativeCompilandSymbol.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
|
||||
NativeCompilandSymbol::NativeCompilandSymbol(NativeSession &Session,
|
||||
const ModuleInfoEx &MI)
|
||||
: NativeRawSymbol(Session), Module(MI) {}
|
||||
|
||||
PDB_SymType NativeCompilandSymbol::getSymTag() const {
|
||||
return PDB_SymType::Compiland;
|
||||
}
|
||||
|
||||
bool NativeCompilandSymbol::isEditAndContinueEnabled() const {
|
||||
return Module.Info.hasECInfo();
|
||||
}
|
||||
|
||||
uint32_t NativeCompilandSymbol::getLexicalParentId() const { return 0; }
|
||||
|
||||
// DIA, which this API was modeled after, uses counter-intuitive meanings for
|
||||
// IDiaSymbol::get_name and IDiaSymbol::get_libraryName, which is why these
|
||||
// methods may appear to be cross-mapped.
|
||||
|
||||
std::string NativeCompilandSymbol::getLibraryName() const {
|
||||
return Module.Info.getObjFileName();
|
||||
}
|
||||
|
||||
std::string NativeCompilandSymbol::getName() const {
|
||||
return Module.Info.getModuleName();
|
||||
}
|
||||
|
||||
} // namespace pdb
|
||||
} // namespace llvm
|
|
@ -0,0 +1,52 @@
|
|||
//==- NativeEnumModules.cpp - Native Symbol Enumerator impl ------*- 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/NativeEnumModules.h"
|
||||
|
||||
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
|
||||
NativeEnumModules::NativeEnumModules(NativeSession &PDBSession,
|
||||
ArrayRef<ModuleInfoEx> Modules,
|
||||
uint32_t Index)
|
||||
: Session(PDBSession), Modules(Modules), Index(Index) {}
|
||||
|
||||
uint32_t NativeEnumModules::getChildCount() const {
|
||||
return static_cast<uint32_t>(Modules.size());
|
||||
}
|
||||
|
||||
std::unique_ptr<PDBSymbol>
|
||||
NativeEnumModules::getChildAtIndex(uint32_t Index) const {
|
||||
if (Index >= Modules.size())
|
||||
return nullptr;
|
||||
return std::unique_ptr<PDBSymbol>(new PDBSymbolCompiland(Session,
|
||||
std::unique_ptr<IPDBRawSymbol>(
|
||||
new NativeCompilandSymbol(Session, Modules[Index]))));
|
||||
}
|
||||
|
||||
std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
|
||||
if (Index >= Modules.size())
|
||||
return nullptr;
|
||||
return getChildAtIndex(Index++);
|
||||
}
|
||||
|
||||
void NativeEnumModules::reset() { Index = 0; }
|
||||
|
||||
NativeEnumModules *NativeEnumModules::clone() const {
|
||||
return new NativeEnumModules(Session, Modules, Index);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -10,11 +10,13 @@
|
|||
#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
|
||||
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBExtras.h"
|
||||
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
|
||||
#include "llvm/Support/ConvertUTF.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
|
@ -28,6 +30,21 @@ void NativeRawSymbol::dump(raw_ostream &OS, int Indent) const {}
|
|||
|
||||
std::unique_ptr<IPDBEnumSymbols>
|
||||
NativeRawSymbol::findChildren(PDB_SymType Type) const {
|
||||
switch (Type) {
|
||||
case PDB_SymType::Compiland: {
|
||||
auto &File = Session.getPDBFile();
|
||||
auto Dbi = File.getPDBDbiStream();
|
||||
if (Dbi) {
|
||||
const auto Modules = Dbi->modules();
|
||||
return std::unique_ptr<IPDBEnumSymbols>(
|
||||
new NativeEnumModules(Session, Modules));
|
||||
}
|
||||
consumeError(Dbi.takeError());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
; Test that the native PDB reader can enumerate the compilands.
|
||||
; RUN: llvm-pdbdump pretty -native -compilands %p/../Inputs/empty.pdb \
|
||||
; RUN: | FileCheck -check-prefix=EMPTY %s
|
||||
; RUN: llvm-pdbdump pretty -native -compilands %p/../Inputs/big-read.pdb \
|
||||
; RUN: | FileCheck -check-prefix=BIGREAD %s
|
||||
|
||||
; Reference output was generated with the DIA reader to ensure that the
|
||||
; `-native` option produces identical output. The paths output will have
|
||||
; backslashes even on non-Windows platforms because they are from PDBs built
|
||||
; on Windows. The path prefixes have been elided because those may be
|
||||
; machine-specific.
|
||||
|
||||
EMPTY:---COMPILANDS---
|
||||
EMPTY: \llvm\test\DebugInfo\PDB\Inputs\empty.obj
|
||||
EMPTY: * Linker *
|
||||
|
||||
BIGREAD:---COMPILANDS---
|
||||
BIGREAD: \llvm\test\tools\llvm-symbolizer\pdb\Inputs\test.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\_cpu_disp_.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\_initsect_.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\_sehprolg4_.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\_chandler4gs_.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\_secchk_.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\gs_cookie.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\gs_report.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\gs_support.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\checkcfg.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\guard_support.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\loadcfg.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\dyn_tls_dtor.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\dyn_tls_init.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\matherr_detection.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\ucrt_detection.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\argv_mode.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\commit_mode.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\default_local_stdio_options.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\denormal_control.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\env_mode.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\file_mode.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\invalid_parameter_handler.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\matherr.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\new_mode.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\thread_locale.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\tncleanup.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\exe_main.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\initializers.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\utility.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\ucrt_stubs.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\utility_desktop.obj
|
||||
BIGREAD: f:\dd\vctools\crt\vcstartup\build\md\msvcrt_kernel32\obj1r\i386\default_precision.obj
|
||||
BIGREAD: Import:KERNEL32.dll
|
||||
BIGREAD: KERNEL32.dll
|
||||
BIGREAD: Import:VCRUNTIME140.dll
|
||||
BIGREAD: VCRUNTIME140.dll
|
||||
BIGREAD: Import:api-ms-win-crt-stdio-l1-1-0.dll
|
||||
BIGREAD: api-ms-win-crt-stdio-l1-1-0.dll
|
||||
BIGREAD: Import:api-ms-win-crt-runtime-l1-1-0.dll
|
||||
BIGREAD: api-ms-win-crt-runtime-l1-1-0.dll
|
||||
BIGREAD: Import:api-ms-win-crt-math-l1-1-0.dll
|
||||
BIGREAD: api-ms-win-crt-math-l1-1-0.dll
|
||||
BIGREAD: Import:api-ms-win-crt-locale-l1-1-0.dll
|
||||
BIGREAD: api-ms-win-crt-locale-l1-1-0.dll
|
||||
BIGREAD: Import:api-ms-win-crt-heap-l1-1-0.dll
|
||||
BIGREAD: api-ms-win-crt-heap-l1-1-0.dll
|
||||
BIGREAD: * Linker *
|
|
@ -123,6 +123,9 @@ cl::opt<uint64_t> LoadAddress(
|
|||
"load-address",
|
||||
cl::desc("Assume the module is loaded at the specified address"),
|
||||
cl::cat(OtherOptions), cl::sub(PrettySubcommand));
|
||||
cl::opt<bool> Native("native", cl::desc("Use native PDB reader instead of DIA"),
|
||||
cl::cat(OtherOptions), cl::sub(PrettySubcommand));
|
||||
|
||||
cl::list<std::string> ExcludeTypes(
|
||||
"exclude-types", cl::desc("Exclude types by regular expression"),
|
||||
cl::ZeroOrMore, cl::cat(FilterCategory), cl::sub(PrettySubcommand));
|
||||
|
@ -476,7 +479,9 @@ static void diff(StringRef Path1, StringRef Path2) {
|
|||
static void dumpPretty(StringRef Path) {
|
||||
std::unique_ptr<IPDBSession> Session;
|
||||
|
||||
ExitOnErr(loadDataForPDB(PDB_ReaderType::DIA, Path, Session));
|
||||
const auto ReaderType =
|
||||
opts::pretty::Native ? PDB_ReaderType::Native : PDB_ReaderType::DIA;
|
||||
ExitOnErr(loadDataForPDB(ReaderType, Path, Session));
|
||||
|
||||
if (opts::pretty::LoadAddress)
|
||||
Session->setLoadAddress(opts::pretty::LoadAddress);
|
||||
|
|
Loading…
Reference in New Issue