summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Raw
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/ByteStream.cpp72
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp6
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp5
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp5
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/StreamReader.cpp50
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp5
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp6
10 files changed, 19 insertions, 142 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/ByteStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/ByteStream.cpp
deleted file mode 100644
index 09b51d96871..00000000000
--- a/llvm/lib/DebugInfo/PDB/Raw/ByteStream.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-//===- ByteStream.cpp - Reads stream data from a byte sequence ------------===//
-//
-// 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/Raw/ByteStream.h"
-#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
-#include <cstring>
-
-using namespace llvm;
-using namespace llvm::pdb;
-
-ByteStream::ByteStream() {}
-
-ByteStream::ByteStream(MutableArrayRef<uint8_t> Bytes) { initialize(Bytes); }
-
-ByteStream::ByteStream(uint32_t Length) { initialize(Length); }
-
-ByteStream::~ByteStream() { reset(); }
-
-void ByteStream::reset() {
- Ownership.reset();
- Data = MutableArrayRef<uint8_t>();
-}
-
-void ByteStream::initialize(MutableArrayRef<uint8_t> Bytes) {
- reset();
- Data = Bytes;
-}
-
-void ByteStream::initialize(uint32_t Length) {
- reset();
- if (Length > 0)
- Data = MutableArrayRef<uint8_t>(new uint8_t[Length], Length);
- Ownership.reset(Data.data());
-}
-
-Error ByteStream::initialize(StreamReader &Reader, uint32_t Length) {
- initialize(Length);
- auto EC = Reader.readBytes(Data);
- if (EC)
- reset();
- return EC;
-}
-
-Error ByteStream::readBytes(uint32_t Offset,
- MutableArrayRef<uint8_t> Buffer) const {
- if (Data.size() < Buffer.size() + Offset)
- return make_error<RawError>(raw_error_code::insufficient_buffer);
- ::memcpy(Buffer.data(), Data.data() + Offset, Buffer.size());
- return Error::success();
-}
-
-Error ByteStream::getArrayRef(uint32_t Offset, ArrayRef<uint8_t> &Buffer,
- uint32_t Length) const {
- if (Data.size() < Length + Offset)
- return make_error<RawError>(raw_error_code::insufficient_buffer);
- Buffer = Data.slice(Offset, Length);
- return Error::success();
-}
-
-uint32_t ByteStream::getLength() const { return Data.size(); }
-
-StringRef ByteStream::str() const {
- const char *CharData = reinterpret_cast<const char *>(Data.data());
- return StringRef(CharData, Data.size());
-}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
index 6b5cd212ed9..078384ebae3 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
@@ -9,13 +9,13 @@
#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
#include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
using namespace llvm;
using namespace llvm::pdb;
@@ -80,7 +80,7 @@ DbiStream::DbiStream(PDBFile &File) : Pdb(File), Stream(StreamDBI, File) {
DbiStream::~DbiStream() {}
Error DbiStream::reload() {
- StreamReader Reader(Stream);
+ codeview::StreamReader Reader(Stream);
Header.reset(new HeaderInfo());
@@ -170,7 +170,7 @@ Error DbiStream::reload() {
return make_error<RawError>(raw_error_code::corrupt_file,
"Found unexpected bytes in DBI Stream.");
- StreamReader ECReader(ECSubstream);
+ codeview::StreamReader ECReader(ECSubstream);
if (auto EC = ECNames.load(ECReader))
return EC;
diff --git a/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
index ccc4a5e6c9b..e7c8a831c73 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
@@ -10,9 +10,9 @@
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
using namespace llvm;
using namespace llvm::pdb;
@@ -20,7 +20,7 @@ using namespace llvm::pdb;
InfoStream::InfoStream(PDBFile &File) : Pdb(File), Stream(StreamPDB, File) {}
Error InfoStream::reload() {
- StreamReader Reader(Stream);
+ codeview::StreamReader Reader(Stream);
struct Header {
support::ulittle32_t Version;
diff --git a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp
index dfc7bfc0f5f..c359e7757d0 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/ModStream.cpp
@@ -8,9 +8,10 @@
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/Raw/ModStream.h"
+
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
using namespace llvm;
using namespace llvm::pdb;
@@ -21,7 +22,7 @@ ModStream::ModStream(PDBFile &File, const ModInfo &Module)
ModStream::~ModStream() {}
Error ModStream::reload() {
- StreamReader Reader(Stream);
+ codeview::StreamReader Reader(Stream);
uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
uint32_t C11Size = Mod.getLineInfoByteSize();
diff --git a/llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp b/llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
index 2005c3958db..a542a51b188 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
@@ -10,9 +10,8 @@
#include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
#include "llvm/Support/Endian.h"
using namespace llvm;
@@ -78,7 +77,7 @@ static inline uint32_t HashStringV2(StringRef Str) {
NameHashTable::NameHashTable() : Signature(0), HashVersion(0), NameCount(0) {}
-Error NameHashTable::load(StreamReader &Stream) {
+Error NameHashTable::load(codeview::StreamReader &Stream) {
struct Header {
support::ulittle32_t Signature;
support::ulittle32_t HashVersion;
diff --git a/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp b/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp
index 202e7173b0e..777d93279c1 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp
@@ -9,15 +9,15 @@
#include "llvm/DebugInfo/PDB/Raw/NameMap.h"
#include "llvm/ADT/BitVector.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
using namespace llvm;
using namespace llvm::pdb;
NameMap::NameMap() {}
-Error NameMap::load(StreamReader &Stream) {
+Error NameMap::load(codeview::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.
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
index af3cff32eb4..db66f536e5a 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
@@ -25,12 +25,12 @@
#include "llvm/DebugInfo/PDB/Raw/PublicsStream.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
#include "llvm/DebugInfo/PDB/Raw/SymbolStream.h"
#include "llvm/ADT/BitVector.h"
@@ -99,7 +99,7 @@ uint32_t PublicsStream::getAddrMap() const { return Header->AddrMap; }
// we skip over the hash table which we believe contains information about
// public symbols.
Error PublicsStream::reload() {
- StreamReader Reader(Stream);
+ codeview::StreamReader Reader(Stream);
// Check stream size.
if (Reader.bytesRemaining() < sizeof(HeaderInfo) + sizeof(GSIHashHeader))
diff --git a/llvm/lib/DebugInfo/PDB/Raw/StreamReader.cpp b/llvm/lib/DebugInfo/PDB/Raw/StreamReader.cpp
deleted file mode 100644
index ed9c9d400af..00000000000
--- a/llvm/lib/DebugInfo/PDB/Raw/StreamReader.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//===- StreamReader.cpp - Reads bytes and objects from a stream -----------===//
-//
-// 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/Raw/StreamReader.h"
-#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-
-using namespace llvm;
-using namespace llvm::pdb;
-
-StreamReader::StreamReader(const StreamInterface &S) : Stream(S), Offset(0) {}
-
-Error StreamReader::readBytes(MutableArrayRef<uint8_t> Buffer) {
- if (auto EC = Stream.readBytes(Offset, Buffer))
- return EC;
- Offset += Buffer.size();
- return Error::success();
-}
-
-Error StreamReader::readInteger(uint32_t &Dest) {
- support::ulittle32_t P;
- if (auto EC = readObject(&P))
- return EC;
- Dest = P;
- return Error::success();
-}
-
-Error StreamReader::readZeroString(std::string &Dest) {
- Dest.clear();
- char C;
- do {
- if (auto EC = readObject(&C))
- return EC;
- if (C != '\0')
- Dest.push_back(C);
- } while (C != '\0');
- return Error::success();
-}
-
-Error StreamReader::getArrayRef(ArrayRef<uint8_t> &Array, uint32_t Length) {
- if (auto EC = Stream.getArrayRef(Offset, Array, Length))
- return EC;
- Offset += Length;
- return Error::success();
-}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
index 6249524eddd..2037a646de7 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
@@ -10,12 +10,11 @@
#include "llvm/DebugInfo/PDB/Raw/SymbolStream.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/PDB/Raw/ByteStream.h"
#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
#include "llvm/Support/Endian.h"
@@ -29,7 +28,7 @@ SymbolStream::SymbolStream(PDBFile &File, uint32_t StreamNum)
SymbolStream::~SymbolStream() {}
Error SymbolStream::reload() {
- StreamReader Reader(MappedStream);
+ codeview::StreamReader Reader(MappedStream);
if (Stream.initialize(Reader, MappedStream.getLength()))
return make_error<RawError>(raw_error_code::corrupt_file,
diff --git a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
index 8ce8c01f608..99daf6e29fd 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
@@ -10,11 +10,11 @@
#include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/StreamReader.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
#include "llvm/DebugInfo/PDB/Raw/RawError.h"
-#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
#include "llvm/Support/Endian.h"
@@ -62,7 +62,7 @@ TpiStream::TpiStream(PDBFile &File, uint32_t StreamIdx)
TpiStream::~TpiStream() {}
Error TpiStream::reload() {
- StreamReader Reader(Stream);
+ codeview::StreamReader Reader(Stream);
if (Reader.bytesRemaining() < sizeof(HeaderInfo))
return make_error<RawError>(raw_error_code::corrupt_file,
@@ -98,7 +98,7 @@ Error TpiStream::reload() {
// Hash indices, hash values, etc come from the hash stream.
MappedBlockStream HS(Header->HashStreamIndex, Pdb);
- StreamReader HSR(HS);
+ codeview::StreamReader HSR(HS);
HSR.setOffset(Header->HashValueBuffer.Off);
if (auto EC =
HashValuesBuffer.initialize(HSR, Header->HashValueBuffer.Length))
OpenPOWER on IntegriCloud