forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297883 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
1840112
commit 38f8b96
Showing
8 changed files
with
262 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters