mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-12 04:43:48 +00:00
Put PDB parsing code into a pdb namespace.
llvm-svn: 268072
This commit is contained in:
parent
6ba65deeb9
commit
2f09b5091c
@ -19,6 +19,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
class StreamReader;
|
||||
class ByteStream : public StreamInterface {
|
||||
public:
|
||||
@ -43,5 +44,6 @@ private:
|
||||
bool Owned;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- PDBDbiStream.h - PDB Dbi Stream (Stream 3) Access --------*- C++ -*-===//
|
||||
//===- DbiStream.h - PDB Dbi Stream (Stream 3) Access -----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -14,18 +14,19 @@
|
||||
#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBRawConstants.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
|
||||
#include "llvm/Support/Endian.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
class PDBFile;
|
||||
|
||||
class PDBDbiStream {
|
||||
class DbiStream {
|
||||
struct HeaderInfo;
|
||||
|
||||
public:
|
||||
PDBDbiStream(PDBFile &File);
|
||||
~PDBDbiStream();
|
||||
DbiStream(PDBFile &File);
|
||||
~DbiStream();
|
||||
std::error_code reload();
|
||||
|
||||
PdbRaw_DbiVer getDbiVersion() const;
|
||||
@ -65,5 +66,6 @@ private:
|
||||
std::unique_ptr<HeaderInfo> Header;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
//===- PDBInfoStream.h - PDB Info Stream (Stream 1) Access ------*- C++ -*-===//
|
||||
//===- InfoStream.h - PDB Info Stream (Stream 1) Access ---------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -13,16 +13,16 @@
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBTypes.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBNameMap.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBRawConstants.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/NameMap.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
|
||||
|
||||
#include "llvm/Support/Endian.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class PDBInfoStream {
|
||||
namespace pdb {
|
||||
class InfoStream {
|
||||
public:
|
||||
PDBInfoStream(PDBFile &File);
|
||||
InfoStream(PDBFile &File);
|
||||
|
||||
std::error_code reload();
|
||||
|
||||
@ -57,8 +57,9 @@ private:
|
||||
// universally unique.
|
||||
PDB_UniqueId Guid;
|
||||
|
||||
PDBNameMap NamedStreams;
|
||||
NameMap NamedStreams;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -18,6 +18,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
class PDBFile;
|
||||
|
||||
class MappedBlockStream : public StreamInterface {
|
||||
@ -34,5 +35,6 @@ private:
|
||||
const PDBFile &Pdb;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -16,8 +16,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class PDBFile;
|
||||
|
||||
namespace pdb {
|
||||
class ModInfo {
|
||||
private:
|
||||
struct FileLayout;
|
||||
@ -36,8 +35,8 @@ public:
|
||||
uint32_t getSourceFileNameIndex() const;
|
||||
uint32_t getPdbFilePathNameIndex() const;
|
||||
|
||||
llvm::StringRef getModuleName() const;
|
||||
llvm::StringRef getObjFileName() const;
|
||||
StringRef getModuleName() const;
|
||||
StringRef getObjFileName() const;
|
||||
|
||||
private:
|
||||
const FileLayout *Layout;
|
||||
@ -66,5 +65,6 @@ private:
|
||||
const uint8_t *Bytes;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- PDBNameMap.h - PDB Name Map ------------------------------*- C++ -*-===//
|
||||
//===- NameMap.h - PDB Name Map ---------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -17,10 +17,11 @@
|
||||
#include <utility>
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
class StreamReader;
|
||||
class PDBNameMap {
|
||||
class NameMap {
|
||||
public:
|
||||
PDBNameMap();
|
||||
NameMap();
|
||||
|
||||
std::error_code load(StreamReader &Stream);
|
||||
|
||||
@ -30,5 +31,6 @@ private:
|
||||
StringMap<uint32_t> Mapping;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -19,9 +19,10 @@
|
||||
namespace llvm {
|
||||
class MemoryBuffer;
|
||||
|
||||
namespace pdb {
|
||||
struct PDBFileContext;
|
||||
class PDBDbiStream;
|
||||
class PDBInfoStream;
|
||||
class DbiStream;
|
||||
class InfoStream;
|
||||
|
||||
class PDBFile {
|
||||
public:
|
||||
@ -39,11 +40,11 @@ public:
|
||||
|
||||
uint32_t getNumStreams() const;
|
||||
uint32_t getStreamByteSize(uint32_t StreamIndex) const;
|
||||
llvm::ArrayRef<uint32_t> getStreamBlockList(uint32_t StreamIndex) const;
|
||||
ArrayRef<uint32_t> getStreamBlockList(uint32_t StreamIndex) const;
|
||||
|
||||
StringRef getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const;
|
||||
|
||||
llvm::ArrayRef<support::ulittle32_t> getDirectoryBlockArray();
|
||||
ArrayRef<support::ulittle32_t> getDirectoryBlockArray();
|
||||
|
||||
std::error_code parseFileHeaders();
|
||||
std::error_code parseStreamData();
|
||||
@ -56,14 +57,15 @@ public:
|
||||
return BlockNumber * BlockSize;
|
||||
}
|
||||
|
||||
PDBInfoStream &getPDBInfoStream();
|
||||
PDBDbiStream &getPDBDbiStream();
|
||||
InfoStream &getPDBInfoStream();
|
||||
DbiStream &getPDBDbiStream();
|
||||
|
||||
private:
|
||||
std::unique_ptr<PDBFileContext> Context;
|
||||
std::unique_ptr<PDBInfoStream> InfoStream;
|
||||
std::unique_ptr<PDBDbiStream> DbiStream;
|
||||
std::unique_ptr<InfoStream> Info;
|
||||
std::unique_ptr<DbiStream> Dbi;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
namespace pdb {
|
||||
enum PdbRaw_ImplVer : uint32_t {
|
||||
PdbImplVC2 = 19941610,
|
||||
PdbImplVC4 = 19950623,
|
||||
@ -35,5 +35,6 @@ enum PdbRaw_DbiVer : uint32_t {
|
||||
PdbDbiV110 = 20091201
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -10,11 +10,12 @@
|
||||
#ifndef LLVM_DEBUGINFO_PDB_RAW_RAWSESSION_H
|
||||
#define LLVM_DEBUGINFO_PDB_RAW_RAWSESSION_H
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/DebugInfo/PDB/IPDBSession.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
class PDBFile;
|
||||
class StringRef;
|
||||
|
||||
class RawSession : public IPDBSession {
|
||||
public:
|
||||
@ -68,5 +69,6 @@ private:
|
||||
std::unique_ptr<PDBFile> Pdb;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <system_error>
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
class StreamInterface {
|
||||
public:
|
||||
virtual ~StreamInterface() {}
|
||||
@ -25,5 +26,6 @@ public:
|
||||
virtual uint32_t getLength() const = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -10,6 +10,7 @@
|
||||
#ifndef LLVM_DEBUGINFO_PDB_RAW_STREAMREADER_H
|
||||
#define LLVM_DEBUGINFO_PDB_RAW_STREAMREADER_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/StreamInterface.h"
|
||||
#include "llvm/Support/Endian.h"
|
||||
|
||||
@ -17,7 +18,8 @@
|
||||
#include <system_error>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
namespace pdb {
|
||||
class StreamInterface;
|
||||
class StreamReader {
|
||||
public:
|
||||
StreamReader(const StreamInterface &S);
|
||||
@ -42,5 +44,6 @@ private:
|
||||
uint32_t Offset;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -31,9 +31,9 @@ add_pdb_impl_folder(Raw
|
||||
Raw/MappedBlockStream.cpp
|
||||
Raw/ModInfo.cpp
|
||||
Raw/PDBFile.cpp
|
||||
Raw/PDBDbiStream.cpp
|
||||
Raw/PDBInfoStream.cpp
|
||||
Raw/PDBNameMap.cpp
|
||||
Raw/DbiStream.cpp
|
||||
Raw/InfoStream.cpp
|
||||
Raw/NameMap.cpp
|
||||
Raw/RawSession.cpp
|
||||
Raw/StreamReader.cpp)
|
||||
|
||||
|
@ -25,7 +25,7 @@ PDB_ErrorCode llvm::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
|
||||
std::unique_ptr<IPDBSession> &Session) {
|
||||
// Create the correct concrete instance type based on the value of Type.
|
||||
if (Type == PDB_ReaderType::Raw)
|
||||
return RawSession::createFromPdb(Path, Session);
|
||||
return pdb::RawSession::createFromPdb(Path, Session);
|
||||
|
||||
#if HAVE_DIA_SDK
|
||||
return DIASession::createFromPdb(Path, Session);
|
||||
@ -38,7 +38,7 @@ PDB_ErrorCode llvm::loadDataForEXE(PDB_ReaderType Type, StringRef Path,
|
||||
std::unique_ptr<IPDBSession> &Session) {
|
||||
// Create the correct concrete instance type based on the value of Type.
|
||||
if (Type == PDB_ReaderType::Raw)
|
||||
return RawSession::createFromExe(Path, Session);
|
||||
return pdb::RawSession::createFromExe(Path, Session);
|
||||
|
||||
#if HAVE_DIA_SDK
|
||||
return DIASession::createFromExe(Path, Session);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
|
||||
ByteStream::ByteStream() : Owned(false) {}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- PDBDbiStream.cpp - PDB Dbi Stream (Stream 3) Access ----------------===//
|
||||
//===- DbiStream.cpp - PDB Dbi Stream (Stream 3) Access -------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,14 +7,15 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBDbiStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBInfoStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBRawConstants.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
using namespace llvm::support;
|
||||
|
||||
namespace {
|
||||
@ -45,10 +46,10 @@ const uint16_t BuildMajorMask = 0x7F00;
|
||||
const uint16_t BuildMajorShift = 8;
|
||||
}
|
||||
|
||||
struct PDBDbiStream::HeaderInfo {
|
||||
struct DbiStream::HeaderInfo {
|
||||
little32_t VersionSignature;
|
||||
ulittle32_t VersionHeader;
|
||||
ulittle32_t Age; // Should match PDBInfoStream.
|
||||
ulittle32_t Age; // Should match InfoStream.
|
||||
ulittle16_t GSSyms; // Number of global symbols
|
||||
ulittle16_t BuildNumber; // See DbiBuildNo structure.
|
||||
ulittle16_t PSSyms; // Number of public symbols
|
||||
@ -59,23 +60,23 @@ struct PDBDbiStream::HeaderInfo {
|
||||
little32_t SecContrSubstreamSize; // Size of sec. contribution stream
|
||||
little32_t SectionMapSize; // Size of sec. map substream
|
||||
little32_t FileInfoSize; // Size of file info substream
|
||||
little32_t TypeServerSize; // Size of type server map
|
||||
ulittle32_t MFCTypeServerIndex; // Index of MFC Type Server
|
||||
little32_t OptionalDbgHdrSize; // Size of DbgHeader info
|
||||
little32_t ECSubstreamSize; // Size of EC stream (what is EC?)
|
||||
ulittle16_t Flags; // See DbiFlags enum.
|
||||
ulittle16_t MachineType; // See PDB_MachineType enum.
|
||||
little32_t TypeServerSize; // Size of type server map
|
||||
ulittle32_t MFCTypeServerIndex; // Index of MFC Type Server
|
||||
little32_t OptionalDbgHdrSize; // Size of DbgHeader info
|
||||
little32_t ECSubstreamSize; // Size of EC stream (what is EC?)
|
||||
ulittle16_t Flags; // See DbiFlags enum.
|
||||
ulittle16_t MachineType; // See PDB_MachineType enum.
|
||||
|
||||
ulittle32_t Reserved; // Pad to 64 bytes
|
||||
};
|
||||
|
||||
PDBDbiStream::PDBDbiStream(PDBFile &File) : Pdb(File), Stream(3, File) {
|
||||
DbiStream::DbiStream(PDBFile &File) : Pdb(File), Stream(3, File) {
|
||||
static_assert(sizeof(HeaderInfo) == 64, "Invalid HeaderInfo size!");
|
||||
}
|
||||
|
||||
PDBDbiStream::~PDBDbiStream() {}
|
||||
DbiStream::~DbiStream() {}
|
||||
|
||||
std::error_code PDBDbiStream::reload() {
|
||||
std::error_code DbiStream::reload() {
|
||||
StreamReader Reader(Stream);
|
||||
|
||||
Header.reset(new HeaderInfo());
|
||||
@ -127,7 +128,8 @@ std::error_code PDBDbiStream::reload() {
|
||||
for (auto Info : Range)
|
||||
ModuleInfos.push_back(ModuleInfoEx(Info));
|
||||
|
||||
if ((EC = SecContrSubstream.initialize(Reader, Header->SecContrSubstreamSize)))
|
||||
if ((EC =
|
||||
SecContrSubstream.initialize(Reader, Header->SecContrSubstreamSize)))
|
||||
return EC;
|
||||
if ((EC = SecMapSubstream.initialize(Reader, Header->SectionMapSize)))
|
||||
return EC;
|
||||
@ -149,47 +151,45 @@ std::error_code PDBDbiStream::reload() {
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
PdbRaw_DbiVer PDBDbiStream::getDbiVersion() const {
|
||||
PdbRaw_DbiVer DbiStream::getDbiVersion() const {
|
||||
uint32_t Value = Header->VersionHeader;
|
||||
return static_cast<PdbRaw_DbiVer>(Value);
|
||||
}
|
||||
|
||||
uint32_t PDBDbiStream::getAge() const { return Header->Age; }
|
||||
uint32_t DbiStream::getAge() const { return Header->Age; }
|
||||
|
||||
bool PDBDbiStream::isIncrementallyLinked() const {
|
||||
bool DbiStream::isIncrementallyLinked() const {
|
||||
return (Header->Flags & FlagIncrementalMask) != 0;
|
||||
}
|
||||
|
||||
bool PDBDbiStream::hasCTypes() const {
|
||||
bool DbiStream::hasCTypes() const {
|
||||
return (Header->Flags & FlagHasCTypesMask) != 0;
|
||||
}
|
||||
|
||||
bool PDBDbiStream::isStripped() const {
|
||||
bool DbiStream::isStripped() const {
|
||||
return (Header->Flags & FlagStrippedMask) != 0;
|
||||
}
|
||||
|
||||
uint16_t PDBDbiStream::getBuildMajorVersion() const {
|
||||
uint16_t DbiStream::getBuildMajorVersion() const {
|
||||
return (Header->BuildNumber & BuildMajorMask) >> BuildMajorShift;
|
||||
}
|
||||
|
||||
uint16_t PDBDbiStream::getBuildMinorVersion() const {
|
||||
uint16_t DbiStream::getBuildMinorVersion() const {
|
||||
return (Header->BuildNumber & BuildMinorMask) >> BuildMinorShift;
|
||||
}
|
||||
|
||||
uint32_t PDBDbiStream::getPdbDllVersion() const {
|
||||
return Header->PdbDllVersion;
|
||||
}
|
||||
uint32_t DbiStream::getPdbDllVersion() const { return Header->PdbDllVersion; }
|
||||
|
||||
uint32_t PDBDbiStream::getNumberOfSymbols() const { return Header->SymRecords; }
|
||||
uint32_t DbiStream::getNumberOfSymbols() const { return Header->SymRecords; }
|
||||
|
||||
PDB_Machine PDBDbiStream::getMachineType() const {
|
||||
PDB_Machine DbiStream::getMachineType() const {
|
||||
uint16_t Machine = Header->MachineType;
|
||||
return static_cast<PDB_Machine>(Machine);
|
||||
}
|
||||
|
||||
ArrayRef<ModuleInfoEx> PDBDbiStream::modules() const { return ModuleInfos; }
|
||||
ArrayRef<ModuleInfoEx> DbiStream::modules() const { return ModuleInfos; }
|
||||
|
||||
std::error_code PDBDbiStream::initializeFileInfo() {
|
||||
std::error_code DbiStream::initializeFileInfo() {
|
||||
struct FileInfoSubstreamHeader {
|
||||
ulittle16_t NumModules; // Total # of modules, should match number of
|
||||
// records in the ModuleInfo substream.
|
@ -1,4 +1,4 @@
|
||||
//===- PDBInfoStream.cpp - PDB Info Stream (Stream 1) Access ----*- C++ -*-===//
|
||||
//===- InfoStream.cpp - PDB Info Stream (Stream 1) Access -------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,16 +7,17 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBInfoStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
|
||||
#include "llvm/ADT/BitVector.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
|
||||
PDBInfoStream::PDBInfoStream(PDBFile &File) : Pdb(File), Stream(1, File) {}
|
||||
InfoStream::InfoStream(PDBFile &File) : Pdb(File), Stream(1, File) {}
|
||||
|
||||
std::error_code PDBInfoStream::reload() {
|
||||
std::error_code InfoStream::reload() {
|
||||
StreamReader Reader(Stream);
|
||||
|
||||
support::ulittle32_t Value;
|
||||
@ -38,19 +39,19 @@ std::error_code PDBInfoStream::reload() {
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
uint32_t PDBInfoStream::getNamedStreamIndex(llvm::StringRef Name) const {
|
||||
uint32_t InfoStream::getNamedStreamIndex(llvm::StringRef Name) const {
|
||||
uint32_t Result;
|
||||
if (!NamedStreams.tryGetValue(Name, Result))
|
||||
return 0;
|
||||
return Result;
|
||||
}
|
||||
|
||||
PdbRaw_ImplVer PDBInfoStream::getVersion() const {
|
||||
PdbRaw_ImplVer InfoStream::getVersion() const {
|
||||
return static_cast<PdbRaw_ImplVer>(Version);
|
||||
}
|
||||
|
||||
uint32_t PDBInfoStream::getSignature() const { return Signature; }
|
||||
uint32_t InfoStream::getSignature() const { return Signature; }
|
||||
|
||||
uint32_t PDBInfoStream::getAge() const { return Age; }
|
||||
uint32_t InfoStream::getAge() const { return Age; }
|
||||
|
||||
PDB_UniqueId PDBInfoStream::getGuid() const { return Guid; }
|
||||
PDB_UniqueId InfoStream::getGuid() const { return Guid; }
|
@ -11,6 +11,7 @@
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
|
||||
MappedBlockStream::MappedBlockStream(uint32_t StreamIdx, const PDBFile &File) : Pdb(File) {
|
||||
StreamLength = Pdb.getStreamByteSize(StreamIdx);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "llvm/Support/Endian.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
using namespace llvm::support;
|
||||
|
||||
namespace {
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- PDBNameMap.cpp - PDB Name Map ----------------------------*- C++ -*-===//
|
||||
//===- NameMap.cpp - PDB Name Map -------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,15 +7,16 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBNameMap.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/NameMap.h"
|
||||
#include "llvm/ADT/BitVector.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
|
||||
PDBNameMap::PDBNameMap() {}
|
||||
NameMap::NameMap() {}
|
||||
|
||||
std::error_code PDBNameMap::load(StreamReader &Stream) {
|
||||
std::error_code NameMap::load(StreamReader &Stream) {
|
||||
|
||||
// This is some sort of weird string-set/hash table encoded in the stream.
|
||||
// It starts with the number of bytes in the table.
|
||||
@ -100,7 +101,7 @@ std::error_code PDBNameMap::load(StreamReader &Stream) {
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
bool PDBNameMap::tryGetValue(StringRef Name, uint32_t &Value) const {
|
||||
bool NameMap::tryGetValue(StringRef Name, uint32_t &Value) const {
|
||||
auto Iter = Mapping.find(Name);
|
||||
if (Iter == Mapping.end())
|
||||
return false;
|
@ -9,12 +9,13 @@
|
||||
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBDbiStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBInfoStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
|
||||
#include "llvm/Support/Endian.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
|
||||
namespace {
|
||||
static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f',
|
||||
@ -45,7 +46,7 @@ struct SuperBlock {
|
||||
};
|
||||
}
|
||||
|
||||
struct llvm::PDBFileContext {
|
||||
struct llvm::pdb::PDBFileContext {
|
||||
std::unique_ptr<MemoryBuffer> Buffer;
|
||||
const SuperBlock *SB;
|
||||
std::vector<uint32_t> StreamSizes;
|
||||
@ -244,18 +245,18 @@ llvm::ArrayRef<support::ulittle32_t> PDBFile::getDirectoryBlockArray() {
|
||||
getNumDirectoryBlocks());
|
||||
}
|
||||
|
||||
PDBInfoStream &PDBFile::getPDBInfoStream() {
|
||||
if (!InfoStream) {
|
||||
InfoStream.reset(new PDBInfoStream(*this));
|
||||
InfoStream->reload();
|
||||
InfoStream &PDBFile::getPDBInfoStream() {
|
||||
if (!Info) {
|
||||
Info.reset(new InfoStream(*this));
|
||||
Info->reload();
|
||||
}
|
||||
return *InfoStream;
|
||||
return *Info;
|
||||
}
|
||||
|
||||
PDBDbiStream &PDBFile::getPDBDbiStream() {
|
||||
if (!DbiStream) {
|
||||
DbiStream.reset(new PDBDbiStream(*this));
|
||||
DbiStream->reload();
|
||||
DbiStream &PDBFile::getPDBDbiStream() {
|
||||
if (!Dbi) {
|
||||
Dbi.reset(new DbiStream(*this));
|
||||
Dbi->reload();
|
||||
}
|
||||
return *DbiStream;
|
||||
return *Dbi;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
|
||||
RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile)
|
||||
: Pdb(std::move(PdbFile)) {}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
|
||||
StreamReader::StreamReader(const StreamInterface &S) : Stream(S), Offset(0) {}
|
||||
|
||||
|
@ -35,11 +35,11 @@
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBDbiStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBInfoStream.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/RawSession.h"
|
||||
#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
@ -61,6 +61,7 @@
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
|
||||
namespace opts {
|
||||
|
||||
@ -237,15 +238,15 @@ static void dumpStructure(RawSession &RS) {
|
||||
}
|
||||
}
|
||||
|
||||
PDBInfoStream &InfoStream = File.getPDBInfoStream();
|
||||
outs() << "Version: " << InfoStream.getVersion() << '\n';
|
||||
InfoStream &IS = File.getPDBInfoStream();
|
||||
outs() << "Version: " << IS.getVersion() << '\n';
|
||||
outs() << "Signature: ";
|
||||
outs().write_hex(InfoStream.getSignature()) << '\n';
|
||||
outs() << "Age: " << InfoStream.getAge() << '\n';
|
||||
outs() << "Guid: " << InfoStream.getGuid() << '\n';
|
||||
outs().write_hex(IS.getSignature()) << '\n';
|
||||
outs() << "Age: " << IS.getAge() << '\n';
|
||||
outs() << "Guid: " << IS.getGuid() << '\n';
|
||||
|
||||
// Let's try to dump out the named stream "/names".
|
||||
uint32_t NameStreamIndex = InfoStream.getNamedStreamIndex("/names");
|
||||
uint32_t NameStreamIndex = IS.getNamedStreamIndex("/names");
|
||||
if (NameStreamIndex != 0) {
|
||||
MappedBlockStream NameStream(NameStreamIndex, File);
|
||||
StreamReader Reader(NameStream);
|
||||
@ -267,24 +268,23 @@ static void dumpStructure(RawSession &RS) {
|
||||
reportError("", std::make_error_code(std::errc::not_supported));
|
||||
}
|
||||
|
||||
PDBDbiStream &DbiStream = File.getPDBDbiStream();
|
||||
outs() << "Dbi Version: " << DbiStream.getDbiVersion() << '\n';
|
||||
outs() << "Age: " << DbiStream.getAge() << '\n';
|
||||
outs() << "Incremental Linking: " << DbiStream.isIncrementallyLinked()
|
||||
<< '\n';
|
||||
outs() << "Has CTypes: " << DbiStream.hasCTypes() << '\n';
|
||||
outs() << "Is Stripped: " << DbiStream.isStripped() << '\n';
|
||||
outs() << "Machine Type: " << DbiStream.getMachineType() << '\n';
|
||||
outs() << "Number of Symbols: " << DbiStream.getNumberOfSymbols() << '\n';
|
||||
DbiStream &DS = File.getPDBDbiStream();
|
||||
outs() << "Dbi Version: " << DS.getDbiVersion() << '\n';
|
||||
outs() << "Age: " << DS.getAge() << '\n';
|
||||
outs() << "Incremental Linking: " << DS.isIncrementallyLinked() << '\n';
|
||||
outs() << "Has CTypes: " << DS.hasCTypes() << '\n';
|
||||
outs() << "Is Stripped: " << DS.isStripped() << '\n';
|
||||
outs() << "Machine Type: " << DS.getMachineType() << '\n';
|
||||
outs() << "Number of Symbols: " << DS.getNumberOfSymbols() << '\n';
|
||||
|
||||
uint16_t Major = DbiStream.getBuildMajorVersion();
|
||||
uint16_t Minor = DbiStream.getBuildMinorVersion();
|
||||
uint16_t Major = DS.getBuildMajorVersion();
|
||||
uint16_t Minor = DS.getBuildMinorVersion();
|
||||
outs() << "Toolchain Version: " << Major << "." << Minor << '\n';
|
||||
outs() << "mspdb" << Major << Minor << ".dll version: " << Major << "."
|
||||
<< Minor << "." << DbiStream.getPdbDllVersion() << '\n';
|
||||
<< Minor << "." << DS.getPdbDllVersion() << '\n';
|
||||
|
||||
outs() << "Modules: \n";
|
||||
for (auto &Modi : DbiStream.modules()) {
|
||||
for (auto &Modi : DS.modules()) {
|
||||
outs() << Modi.Info.getModuleName() << '\n';
|
||||
outs().indent(4) << "Debug Stream Index: "
|
||||
<< Modi.Info.getModuleStreamIndex() << '\n';
|
||||
|
Loading…
x
Reference in New Issue
Block a user