-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make NativeExeSymbol a concrete subclass of NativeRawSymbol [PDB]
This moves exe symbol-specific method implementations out of NativeRawSymbol into a concrete subclass. Also adds implementations for hasCTypes and hasPrivateSymbols and a simple test to ensure the native reader can access the summary information for the executable from the PDB. Differential Revision: https://reviews.llvm.org/D31059 llvm-svn: 298005
- Loading branch information
1 parent
5c5091f
commit 21b54cf
Showing
7 changed files
with
134 additions
and
35 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,39 @@ | ||
//===- NativeExeSymbol.h - native impl for PDBSymbolExe ---------*- 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_NATIVEEXESYMBOL_H | ||
#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEEXESYMBOL_H | ||
|
||
#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" | ||
#include "llvm/DebugInfo/PDB/Native/NativeSession.h" | ||
|
||
namespace llvm { | ||
namespace pdb { | ||
|
||
class NativeExeSymbol : public NativeRawSymbol { | ||
public: | ||
NativeExeSymbol(NativeSession &Session); | ||
|
||
std::unique_ptr<IPDBEnumSymbols> | ||
findChildren(PDB_SymType Type) const override; | ||
|
||
uint32_t getAge() const override; | ||
std::string getSymbolsFileName() const override; | ||
PDB_UniqueId getGuid() const override; | ||
bool hasCTypes() const override; | ||
bool hasPrivateSymbols() const override; | ||
|
||
private: | ||
PDBFile &File; | ||
}; | ||
|
||
} // 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
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,79 @@ | ||
//===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- 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/NativeExeSymbol.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/PDBFile.h" | ||
|
||
namespace llvm { | ||
namespace pdb { | ||
|
||
NativeExeSymbol::NativeExeSymbol(NativeSession &Session) | ||
: NativeRawSymbol(Session), File(Session.getPDBFile()) {} | ||
|
||
std::unique_ptr<IPDBEnumSymbols> | ||
NativeExeSymbol::findChildren(PDB_SymType Type) const { | ||
switch (Type) { | ||
case PDB_SymType::Compiland: { | ||
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; | ||
} | ||
|
||
uint32_t NativeExeSymbol::getAge() const { | ||
auto IS = File.getPDBInfoStream(); | ||
if (IS) | ||
return IS->getAge(); | ||
consumeError(IS.takeError()); | ||
return 0; | ||
} | ||
|
||
std::string NativeExeSymbol::getSymbolsFileName() const { | ||
return File.getFilePath(); | ||
} | ||
|
||
PDB_UniqueId NativeExeSymbol::getGuid() const { | ||
auto IS = File.getPDBInfoStream(); | ||
if (IS) | ||
return IS->getGuid(); | ||
consumeError(IS.takeError()); | ||
return PDB_UniqueId{{0}}; | ||
} | ||
|
||
bool NativeExeSymbol::hasCTypes() const { | ||
auto Dbi = File.getPDBDbiStream(); | ||
if (Dbi) | ||
return Dbi->hasCTypes(); | ||
consumeError(Dbi.takeError()); | ||
return false; | ||
} | ||
|
||
bool NativeExeSymbol::hasPrivateSymbols() const { | ||
auto Dbi = File.getPDBDbiStream(); | ||
if (Dbi) | ||
return !Dbi->isStripped(); | ||
consumeError(Dbi.takeError()); | ||
return false; | ||
} | ||
|
||
} // 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
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,11 @@ | ||
; Test that the native PDB reader gets the PDB summary correct. | ||
; RUN: llvm-pdbdump pretty -native %p/../Inputs/empty.pdb \ | ||
; RUN: | FileCheck -check-prefix=EMPTY %s | ||
|
||
; Reference output was generated with the DIA reader to ensure that the | ||
; `-native` option produces identical output. | ||
|
||
EMPTY: Size: 102400 bytes | ||
EMPTY: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0} | ||
EMPTY: Age: 1 | ||
EMPTY: Attributes: HasPrivateSymbols |