[llvm] r304222 - [CodeView] Add more DebugSubsection implementations.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Tue May 30 10:13:33 PDT 2017
Author: zturner
Date: Tue May 30 12:13:33 2017
New Revision: 304222
URL: http://llvm.org/viewvc/llvm-project?rev=304222&view=rev
Log:
[CodeView] Add more DebugSubsection implementations.
This adds implementations for Symbols and FrameData, and renames
the existing codeview::StringTable class to conform to the
DebugSectionStringTable convention.
Added:
llvm/trunk/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h
llvm/trunk/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h
llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h
llvm/trunk/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp
llvm/trunk/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
llvm/trunk/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp
Removed:
llvm/trunk/include/llvm/DebugInfo/CodeView/StringTable.h
llvm/trunk/lib/DebugInfo/CodeView/StringTable.cpp
llvm/trunk/tools/llvm-readobj/CodeView.h
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h
llvm/trunk/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h
llvm/trunk/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h
llvm/trunk/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h
llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsection.h
llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h
llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
llvm/trunk/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp
llvm/trunk/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp
llvm/trunk/lib/DebugInfo/CodeView/DebugLinesSubsection.cpp
llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h Tue May 30 12:13:33 2017
@@ -13,6 +13,8 @@
#include <cinttypes>
#include <type_traits>
+#include "llvm/Support/Endian.h"
+
namespace llvm {
namespace codeview {
@@ -550,6 +552,24 @@ enum LineFlags : uint16_t {
LF_None = 0,
LF_HaveColumns = 1, // CV_LINES_HAVE_COLUMNS
};
+
+/// Data in the the SUBSEC_FRAMEDATA subection.
+struct FrameData {
+ support::ulittle32_t RvaStart;
+ support::ulittle32_t CodeSize;
+ support::ulittle32_t LocalSize;
+ support::ulittle32_t ParamsSize;
+ support::ulittle32_t MaxStackSize;
+ support::ulittle32_t FrameFunc;
+ support::ulittle16_t PrologSize;
+ support::ulittle16_t SavedRegsSize;
+ support::ulittle32_t Flags;
+ enum : uint32_t {
+ HasSEH = 1 << 0,
+ HasEH = 1 << 1,
+ IsFunctionStart = 1 << 2,
+ };
+};
}
}
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h Tue May 30 12:13:33 2017
@@ -21,7 +21,7 @@
namespace llvm {
namespace codeview {
-class StringTable;
+class DebugStringTableSubsection;
struct FileChecksumEntry {
uint32_t FileNameOffset; // Byte offset of filename in global stringtable.
@@ -55,7 +55,10 @@ public:
return S->kind() == DebugSubsectionKind::FileChecksums;
}
+ bool valid() const { return Checksums.valid(); }
+
Error initialize(BinaryStreamReader Reader);
+ Error initialize(BinaryStreamRef Stream);
Iterator begin() { return Checksums.begin(); }
Iterator end() { return Checksums.end(); }
@@ -68,7 +71,7 @@ private:
class DebugChecksumsSubsection final : public DebugSubsection {
public:
- explicit DebugChecksumsSubsection(StringTable &Strings);
+ explicit DebugChecksumsSubsection(DebugStringTableSubsection &Strings);
static bool classof(const DebugSubsection *S) {
return S->kind() == DebugSubsectionKind::FileChecksums;
@@ -77,12 +80,12 @@ public:
void addChecksum(StringRef FileName, FileChecksumKind Kind,
ArrayRef<uint8_t> Bytes);
- uint32_t calculateSerializedLength() override;
- Error commit(BinaryStreamWriter &Writer) override;
+ uint32_t calculateSerializedSize() const override;
+ Error commit(BinaryStreamWriter &Writer) const override;
uint32_t mapChecksumOffset(StringRef FileName) const;
private:
- StringTable &Strings;
+ DebugStringTableSubsection &Strings;
DenseMap<uint32_t, uint32_t> OffsetMap;
uint32_t SerializedSize = 0;
Added: llvm/trunk/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h?rev=304222&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h Tue May 30 12:13:33 2017
@@ -0,0 +1,59 @@
+//===- DebugFrameDataSubsection.h ------------------------------*- 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_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H
+#define LLVM_DEBUGINFO_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H
+
+#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
+#include "llvm/Support/BinaryStreamReader.h"
+#include "llvm/Support/Error.h"
+
+namespace llvm {
+namespace codeview {
+class DebugFrameDataSubsectionRef final : public DebugSubsectionRef {
+public:
+ DebugFrameDataSubsectionRef()
+ : DebugSubsectionRef(DebugSubsectionKind::FrameData) {}
+ static bool classof(const DebugSubsection *S) {
+ return S->kind() == DebugSubsectionKind::FrameData;
+ }
+
+ Error initialize(BinaryStreamReader Reader);
+
+ FixedStreamArray<FrameData>::Iterator begin() const { return Frames.begin(); }
+ FixedStreamArray<FrameData>::Iterator end() const { return Frames.end(); }
+
+ const void *getRelocPtr() const { return RelocPtr; }
+
+private:
+ const uint32_t *RelocPtr = nullptr;
+ FixedStreamArray<FrameData> Frames;
+};
+
+class DebugFrameDataSubsection final : public DebugSubsection {
+public:
+ DebugFrameDataSubsection()
+ : DebugSubsection(DebugSubsectionKind::FrameData) {}
+ static bool classof(const DebugSubsection *S) {
+ return S->kind() == DebugSubsectionKind::FrameData;
+ }
+
+ uint32_t calculateSerializedSize() const override;
+ Error commit(BinaryStreamWriter &Writer) const override;
+
+ void addFrameData(const FrameData &Frame);
+
+private:
+ std::vector<FrameData> Frames;
+};
+}
+}
+
+#endif
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h Tue May 30 12:13:33 2017
@@ -21,7 +21,6 @@ namespace codeview {
class DebugInlineeLinesSubsectionsRef;
class DebugChecksumsSubsection;
-class StringTable;
enum class InlineeLinesSignature : uint32_t {
Normal, // CV_INLINEE_SOURCE_LINE_SIGNATURE
@@ -82,8 +81,8 @@ public:
return S->kind() == DebugSubsectionKind::InlineeLines;
}
- Error commit(BinaryStreamWriter &Writer) override;
- uint32_t calculateSerializedLength() override;
+ Error commit(BinaryStreamWriter &Writer) const override;
+ uint32_t calculateSerializedSize() const override;
void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine);
void addExtraFile(StringRef FileName);
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h Tue May 30 12:13:33 2017
@@ -20,7 +20,7 @@ namespace llvm {
namespace codeview {
class DebugChecksumsSubsection;
-class StringTable;
+class DebugStringTableSubsection;
// Corresponds to the `CV_DebugSLinesHeader_t` structure.
struct LineFragmentHeader {
@@ -108,7 +108,7 @@ class DebugLinesSubsection final : publi
public:
DebugLinesSubsection(DebugChecksumsSubsection &Checksums,
- StringTable &Strings);
+ DebugStringTableSubsection &Strings);
static bool classof(const DebugSubsection *S) {
return S->kind() == DebugSubsectionKind::Lines;
@@ -119,8 +119,8 @@ public:
void addLineAndColumnInfo(uint32_t Offset, const LineInfo &Line,
uint32_t ColStart, uint32_t ColEnd);
- uint32_t calculateSerializedLength() override;
- Error commit(BinaryStreamWriter &Writer) override;
+ uint32_t calculateSerializedSize() const override;
+ Error commit(BinaryStreamWriter &Writer) const override;
void setRelocationAddress(uint16_t Segment, uint16_t Offset);
void setCodeSize(uint32_t Size);
Added: llvm/trunk/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h?rev=304222&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h Tue May 30 12:13:33 2017
@@ -0,0 +1,86 @@
+//===- DebugStringTableSubsection.h - CodeView String Table -----*- 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_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H
+#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H
+
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
+#include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/Error.h"
+
+#include <stdint.h>
+
+namespace llvm {
+
+class BinaryStreamReader;
+class BinaryStreamRef;
+class BinaryStreamWriter;
+
+namespace codeview {
+
+/// Represents a read-only view of a CodeView string table. This is a very
+/// simple flat buffer consisting of null-terminated strings, where strings
+/// are retrieved by their offset in the buffer. DebugStringTableSubsectionRef
+/// does not own the underlying storage for the buffer.
+class DebugStringTableSubsectionRef : public DebugSubsectionRef {
+public:
+ DebugStringTableSubsectionRef();
+
+ static bool classof(const DebugSubsectionRef *S) {
+ return S->kind() == DebugSubsectionKind::StringTable;
+ }
+
+ Error initialize(BinaryStreamRef Contents);
+
+ Expected<StringRef> getString(uint32_t Offset) const;
+
+ bool valid() const { return Stream.valid(); }
+
+private:
+ BinaryStreamRef Stream;
+};
+
+/// Represents a read-write view of a CodeView string table.
+/// DebugStringTableSubsection owns the underlying storage for the table, and is
+/// capable of serializing the string table into a format understood by
+/// DebugStringTableSubsectionRef.
+class DebugStringTableSubsection : public DebugSubsection {
+public:
+ DebugStringTableSubsection();
+
+ static bool classof(const DebugSubsection *S) {
+ return S->kind() == DebugSubsectionKind::StringTable;
+ }
+
+ // If string S does not exist in the string table, insert it.
+ // Returns the ID for S.
+ uint32_t insert(StringRef S);
+
+ // Return the ID for string S. Assumes S exists in the table.
+ uint32_t getStringId(StringRef S) const;
+
+ uint32_t calculateSerializedSize() const override;
+ Error commit(BinaryStreamWriter &Writer) const override;
+
+ uint32_t size() const;
+
+ StringMap<uint32_t>::const_iterator begin() const { return Strings.begin(); }
+
+ StringMap<uint32_t>::const_iterator end() const { return Strings.end(); }
+
+private:
+ StringMap<uint32_t> Strings;
+ uint32_t StringSize = 1;
+};
+}
+}
+
+#endif
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsection.h?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsection.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSubsection.h Tue May 30 12:13:33 2017
@@ -22,6 +22,8 @@ public:
explicit DebugSubsectionRef(DebugSubsectionKind Kind) : Kind(Kind) {}
virtual ~DebugSubsectionRef();
+ static bool classof(const DebugSubsectionRef *S) { return true; }
+
DebugSubsectionKind kind() const { return Kind; }
protected:
@@ -33,10 +35,12 @@ public:
explicit DebugSubsection(DebugSubsectionKind Kind) : Kind(Kind) {}
virtual ~DebugSubsection();
+ static bool classof(const DebugSubsection *S) { return true; }
+
DebugSubsectionKind kind() const { return Kind; }
- virtual Error commit(BinaryStreamWriter &Writer) = 0;
- virtual uint32_t calculateSerializedLength() = 0;
+ virtual Error commit(BinaryStreamWriter &Writer) const = 0;
+ virtual uint32_t calculateSerializedSize() const = 0;
protected:
DebugSubsectionKind Kind;
Added: llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h?rev=304222&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h Tue May 30 12:13:33 2017
@@ -0,0 +1,53 @@
+//===- DebugSymbolsSubsection.h --------------------------------*- 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_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H
+#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H
+
+#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
+#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
+#include "llvm/Support/Error.h"
+
+namespace llvm {
+namespace codeview {
+class DebugSymbolsSubsectionRef final : public DebugSubsectionRef {
+public:
+ DebugSymbolsSubsectionRef()
+ : DebugSubsectionRef(DebugSubsectionKind::Symbols) {}
+
+ static bool classof(const DebugSubsectionRef *S) {
+ return S->kind() == DebugSubsectionKind::Symbols;
+ }
+
+ Error initialize(BinaryStreamReader Reader);
+
+private:
+ CVSymbolArray Records;
+};
+
+class DebugSymbolsSubsection final : public DebugSubsection {
+public:
+ DebugSymbolsSubsection() : DebugSubsection(DebugSubsectionKind::Symbols) {}
+ static bool classof(const DebugSubsection *S) {
+ return S->kind() == DebugSubsectionKind::Symbols;
+ }
+
+ uint32_t calculateSerializedSize() const override;
+ Error commit(BinaryStreamWriter &Writer) const override;
+
+ void addSymbol(CVSymbol Symbol);
+
+private:
+ uint32_t Length = 0;
+ std::vector<CVSymbol> Records;
+};
+}
+}
+
+#endif
Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/StringTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StringTable.h?rev=304221&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/StringTable.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/StringTable.h (removed)
@@ -1,75 +0,0 @@
-//===- StringTable.h - CodeView String Table Reader/Writer ------*- 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_CODEVIEW_STRINGTABLE_H
-#define LLVM_DEBUGINFO_CODEVIEW_STRINGTABLE_H
-
-#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringRef.h"
-
-#include "llvm/Support/BinaryStreamRef.h"
-#include "llvm/Support/Error.h"
-
-#include <stdint.h>
-
-namespace llvm {
-
-class BinaryStreamReader;
-class BinaryStreamRef;
-class BinaryStreamWriter;
-
-namespace codeview {
-
-/// Represents a read-only view of a CodeView string table. This is a very
-/// simple flat buffer consisting of null-terminated strings, where strings
-/// are retrieved by their offset in the buffer. StringTableRef does not own
-/// the underlying storage for the buffer.
-class StringTableRef {
-public:
- StringTableRef();
-
- Error initialize(BinaryStreamRef Contents);
-
- Expected<StringRef> getString(uint32_t Offset) const;
-
- bool valid() const { return Stream.valid(); }
-
-private:
- BinaryStreamRef Stream;
-};
-
-/// Represents a read-write view of a CodeView string table. StringTable owns
-/// the underlying storage for the table, and is capable of serializing the
-/// string table into a format understood by StringTableRef.
-class StringTable {
-public:
- // If string S does not exist in the string table, insert it.
- // Returns the ID for S.
- uint32_t insert(StringRef S);
-
- // Return the ID for string S. Assumes S exists in the table.
- uint32_t getStringId(StringRef S) const;
-
- uint32_t calculateSerializedSize() const;
- Error commit(BinaryStreamWriter &Writer) const;
-
- uint32_t size() const;
-
- StringMap<uint32_t>::const_iterator begin() const { return Strings.begin(); }
-
- StringMap<uint32_t>::const_iterator end() const { return Strings.end(); }
-
-private:
- StringMap<uint32_t> Strings;
- uint32_t StringSize = 1;
-};
-}
-}
-
-#endif
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h Tue May 30 12:13:33 2017
@@ -19,7 +19,7 @@ class BinaryStreamReader;
namespace codeview {
-class StringTableRef;
+class DebugStringTableSubsectionRef;
class SymbolVisitorDelegate {
public:
@@ -27,7 +27,7 @@ public:
virtual uint32_t getRecordOffset(BinaryStreamReader Reader) = 0;
virtual StringRef getFileNameForFileOffset(uint32_t FileOffset) = 0;
- virtual StringTableRef getStringTable() = 0;
+ virtual DebugStringTableSubsectionRef getStringTable() = 0;
};
} // end namespace codeview
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h Tue May 30 12:13:33 2017
@@ -12,7 +12,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/DebugInfo/CodeView/StringTable.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/Support/BinaryStreamArray.h"
#include "llvm/Support/BinaryStreamRef.h"
#include "llvm/Support/Endian.h"
@@ -52,7 +52,7 @@ private:
Error readEpilogue(BinaryStreamReader &Reader);
const PDBStringTableHeader *Header = nullptr;
- codeview::StringTableRef Strings;
+ codeview::DebugStringTableSubsectionRef Strings;
FixedStreamArray<support::ulittle32_t> IDs;
uint32_t ByteSize = 0;
uint32_t NameCount = 0;
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h Tue May 30 12:13:33 2017
@@ -16,7 +16,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/DebugInfo/CodeView/StringTable.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/Support/Error.h"
#include <vector>
@@ -41,8 +41,10 @@ public:
uint32_t calculateSerializedSize() const;
Error commit(BinaryStreamWriter &Writer) const;
- codeview::StringTable &getStrings() { return Strings; }
- const codeview::StringTable &getStrings() const { return Strings; }
+ codeview::DebugStringTableSubsection &getStrings() { return Strings; }
+ const codeview::DebugStringTableSubsection &getStrings() const {
+ return Strings;
+ }
private:
uint32_t calculateHashTableSize() const;
@@ -51,7 +53,7 @@ private:
Error writeHashTable(BinaryStreamWriter &Writer) const;
Error writeEpilogue(BinaryStreamWriter &Writer) const;
- codeview::StringTable Strings;
+ codeview::DebugStringTableSubsection Strings;
};
} // end namespace pdb
Modified: llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt Tue May 30 12:13:33 2017
@@ -8,13 +8,15 @@ add_llvm_library(LLVMDebugInfoCodeView
LazyRandomTypeCollection.cpp
Line.cpp
DebugChecksumsSubsection.cpp
+ DebugFrameDataSubsection.cpp
+ DebugInlineeLinesSubsection.cpp
+ DebugLinesSubsection.cpp
+ DebugStringTableSubsection.cpp
DebugSubsection.cpp
DebugSubsectionRecord.cpp
DebugSubsectionVisitor.cpp
- DebugInlineeLinesSubsection.cpp
- DebugLinesSubsection.cpp
+ DebugSymbolsSubsection.cpp
RecordSerialization.cpp
- StringTable.cpp
SymbolRecordMapping.cpp
SymbolDumper.cpp
SymbolSerializer.cpp
Modified: llvm/trunk/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp Tue May 30 12:13:33 2017
@@ -10,7 +10,7 @@
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
-#include "llvm/DebugInfo/CodeView/StringTable.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/Support/BinaryStreamReader.h"
using namespace llvm;
@@ -48,8 +48,13 @@ Error DebugChecksumsSubsectionRef::initi
return Error::success();
}
+Error DebugChecksumsSubsectionRef::initialize(BinaryStreamRef Section) {
+ BinaryStreamReader Reader(Section);
+ return initialize(Reader);
+}
-DebugChecksumsSubsection::DebugChecksumsSubsection(StringTable &Strings)
+DebugChecksumsSubsection::DebugChecksumsSubsection(
+ DebugStringTableSubsection &Strings)
: DebugSubsection(DebugSubsectionKind::FileChecksums), Strings(Strings) {}
void DebugChecksumsSubsection::addChecksum(StringRef FileName,
@@ -75,11 +80,11 @@ void DebugChecksumsSubsection::addChecks
SerializedSize += Len;
}
-uint32_t DebugChecksumsSubsection::calculateSerializedLength() {
+uint32_t DebugChecksumsSubsection::calculateSerializedSize() const {
return SerializedSize;
}
-Error DebugChecksumsSubsection::commit(BinaryStreamWriter &Writer) {
+Error DebugChecksumsSubsection::commit(BinaryStreamWriter &Writer) const {
for (const auto &FC : Checksums) {
FileChecksumEntryHeader Header;
Header.ChecksumKind = uint8_t(FC.Kind);
Added: llvm/trunk/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp?rev=304222&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp (added)
+++ llvm/trunk/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp Tue May 30 12:13:33 2017
@@ -0,0 +1,44 @@
+//===- DebugFrameDataSubsection.cpp -----------------------------*- 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/CodeView/DebugFrameDataSubsection.h"
+#include "llvm/DebugInfo/CodeView/CodeViewError.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+Error DebugFrameDataSubsectionRef::initialize(BinaryStreamReader Reader) {
+ if (auto EC = Reader.readObject(RelocPtr))
+ return EC;
+ if (Reader.bytesRemaining() % sizeof(FrameData) != 0)
+ return make_error<CodeViewError>(cv_error_code::corrupt_record,
+ "Invalid frame data record format!");
+
+ uint32_t Count = Reader.bytesRemaining() / sizeof(FrameData);
+ if (auto EC = Reader.readArray(Frames, Count))
+ return EC;
+ return Error::success();
+}
+
+uint32_t DebugFrameDataSubsection::calculateSerializedSize() const {
+ return 4 + sizeof(FrameData) * Frames.size();
+}
+
+Error DebugFrameDataSubsection::commit(BinaryStreamWriter &Writer) const {
+ if (auto EC = Writer.writeInteger<uint32_t>(0))
+ return EC;
+
+ if (auto EC = Writer.writeArray(makeArrayRef(Frames)))
+ return EC;
+ return Error::success();
+}
+
+void DebugFrameDataSubsection::addFrameData(const FrameData &Frame) {
+ Frames.push_back(Frame);
+}
Modified: llvm/trunk/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp Tue May 30 12:13:33 2017
@@ -11,8 +11,8 @@
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
-#include "llvm/DebugInfo/CodeView/StringTable.h"
using namespace llvm;
using namespace llvm::codeview;
@@ -61,7 +61,7 @@ DebugInlineeLinesSubsection::DebugInline
: DebugSubsection(DebugSubsectionKind::InlineeLines), Checksums(Checksums),
HasExtraFiles(HasExtraFiles) {}
-uint32_t DebugInlineeLinesSubsection::calculateSerializedLength() {
+uint32_t DebugInlineeLinesSubsection::calculateSerializedSize() const {
// 4 bytes for the signature
uint32_t Size = sizeof(InlineeLinesSignature);
@@ -78,7 +78,7 @@ uint32_t DebugInlineeLinesSubsection::ca
return Size;
}
-Error DebugInlineeLinesSubsection::commit(BinaryStreamWriter &Writer) {
+Error DebugInlineeLinesSubsection::commit(BinaryStreamWriter &Writer) const {
InlineeLinesSignature Sig = InlineeLinesSignature::Normal;
if (HasExtraFiles)
Sig = InlineeLinesSignature::ExtraFiles;
Modified: llvm/trunk/lib/DebugInfo/CodeView/DebugLinesSubsection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/DebugLinesSubsection.cpp?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/DebugLinesSubsection.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/DebugLinesSubsection.cpp Tue May 30 12:13:33 2017
@@ -11,8 +11,8 @@
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
-#include "llvm/DebugInfo/CodeView/StringTable.h"
using namespace llvm;
using namespace llvm::codeview;
@@ -68,7 +68,7 @@ bool DebugLinesSubsectionRef::hasColumnI
}
DebugLinesSubsection::DebugLinesSubsection(DebugChecksumsSubsection &Checksums,
- StringTable &Strings)
+ DebugStringTableSubsection &Strings)
: DebugSubsection(DebugSubsectionKind::Lines), Checksums(Checksums) {}
void DebugLinesSubsection::createBlock(StringRef FileName) {
@@ -99,7 +99,7 @@ void DebugLinesSubsection::addLineAndCol
B.Columns.push_back(CNE);
}
-Error DebugLinesSubsection::commit(BinaryStreamWriter &Writer) {
+Error DebugLinesSubsection::commit(BinaryStreamWriter &Writer) const {
LineFragmentHeader Header;
Header.CodeSize = CodeSize;
Header.Flags = hasColumnInfo() ? LF_HaveColumns : 0;
@@ -133,7 +133,7 @@ Error DebugLinesSubsection::commit(Binar
return Error::success();
}
-uint32_t DebugLinesSubsection::calculateSerializedLength() {
+uint32_t DebugLinesSubsection::calculateSerializedSize() const {
uint32_t Size = sizeof(LineFragmentHeader);
for (const auto &B : Blocks) {
Size += sizeof(LineBlockFragmentHeader);
Added: llvm/trunk/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp?rev=304222&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp (added)
+++ llvm/trunk/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp Tue May 30 12:13:33 2017
@@ -0,0 +1,78 @@
+//===- DebugStringTableSubsection.cpp - CodeView String Table ---*- 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/CodeView/DebugStringTableSubsection.h"
+
+#include "llvm/Support/BinaryStream.h"
+#include "llvm/Support/BinaryStreamReader.h"
+#include "llvm/Support/BinaryStreamWriter.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+DebugStringTableSubsectionRef::DebugStringTableSubsectionRef()
+ : DebugSubsectionRef(DebugSubsectionKind::StringTable) {}
+
+Error DebugStringTableSubsectionRef::initialize(BinaryStreamRef Contents) {
+ Stream = Contents;
+ return Error::success();
+}
+
+Expected<StringRef>
+DebugStringTableSubsectionRef::getString(uint32_t Offset) const {
+ BinaryStreamReader Reader(Stream);
+ Reader.setOffset(Offset);
+ StringRef Result;
+ if (auto EC = Reader.readCString(Result))
+ return std::move(EC);
+ return Result;
+}
+
+DebugStringTableSubsection::DebugStringTableSubsection()
+ : DebugSubsection(DebugSubsectionKind::StringTable) {}
+
+uint32_t DebugStringTableSubsection::insert(StringRef S) {
+ auto P = Strings.insert({S, StringSize});
+
+ // If a given string didn't exist in the string table, we want to increment
+ // the string table size.
+ if (P.second)
+ StringSize += S.size() + 1; // +1 for '\0'
+ return P.first->second;
+}
+
+uint32_t DebugStringTableSubsection::calculateSerializedSize() const {
+ return StringSize;
+}
+
+Error DebugStringTableSubsection::commit(BinaryStreamWriter &Writer) const {
+ assert(Writer.bytesRemaining() == StringSize);
+ uint32_t MaxOffset = 1;
+
+ for (auto &Pair : Strings) {
+ StringRef S = Pair.getKey();
+ uint32_t Offset = Pair.getValue();
+ Writer.setOffset(Offset);
+ if (auto EC = Writer.writeCString(S))
+ return EC;
+ MaxOffset = std::max<uint32_t>(MaxOffset, Offset + S.size() + 1);
+ }
+
+ Writer.setOffset(MaxOffset);
+ assert(Writer.bytesRemaining() == 0);
+ return Error::success();
+}
+
+uint32_t DebugStringTableSubsection::size() const { return Strings.size(); }
+
+uint32_t DebugStringTableSubsection::getStringId(StringRef S) const {
+ auto P = Strings.find(S);
+ assert(P != Strings.end());
+ return P->second;
+}
Modified: llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp Tue May 30 12:13:33 2017
@@ -61,7 +61,7 @@ DebugSubsectionRecordBuilder::DebugSubse
uint32_t DebugSubsectionRecordBuilder::calculateSerializedLength() {
uint32_t Size = sizeof(DebugSubsectionHeader) +
- alignTo(Frag.calculateSerializedLength(), 4);
+ alignTo(Frag.calculateSerializedSize(), 4);
return Size;
}
Added: llvm/trunk/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp?rev=304222&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp (added)
+++ llvm/trunk/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp Tue May 30 12:13:33 2017
@@ -0,0 +1,34 @@
+//===- DebugSymbolsSubsection.cpp -------------------------------*- 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/CodeView/DebugSymbolsSubsection.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+Error DebugSymbolsSubsectionRef::initialize(BinaryStreamReader Reader) {
+ return Reader.readArray(Records, Reader.getLength());
+}
+
+uint32_t DebugSymbolsSubsection::calculateSerializedSize() const {
+ return Length;
+}
+
+Error DebugSymbolsSubsection::commit(BinaryStreamWriter &Writer) const {
+ for (const auto &Record : Records) {
+ if (auto EC = Writer.writeBytes(Record.RecordData))
+ return EC;
+ }
+ return Error::success();
+}
+
+void DebugSymbolsSubsection::addSymbol(CVSymbol Symbol) {
+ Records.push_back(Symbol);
+ Length += Symbol.length();
+}
\ No newline at end of file
Removed: llvm/trunk/lib/DebugInfo/CodeView/StringTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/StringTable.cpp?rev=304221&view=auto
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/StringTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/StringTable.cpp (removed)
@@ -1,71 +0,0 @@
-//===- StringTable.cpp - CodeView String Table Reader/Writer ----*- 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/CodeView/StringTable.h"
-
-#include "llvm/Support/BinaryStream.h"
-#include "llvm/Support/BinaryStreamReader.h"
-#include "llvm/Support/BinaryStreamWriter.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-
-StringTableRef::StringTableRef() {}
-
-Error StringTableRef::initialize(BinaryStreamRef Contents) {
- Stream = Contents;
- return Error::success();
-}
-
-Expected<StringRef> StringTableRef::getString(uint32_t Offset) const {
- BinaryStreamReader Reader(Stream);
- Reader.setOffset(Offset);
- StringRef Result;
- if (auto EC = Reader.readCString(Result))
- return std::move(EC);
- return Result;
-}
-
-uint32_t StringTable::insert(StringRef S) {
- auto P = Strings.insert({S, StringSize});
-
- // If a given string didn't exist in the string table, we want to increment
- // the string table size.
- if (P.second)
- StringSize += S.size() + 1; // +1 for '\0'
- return P.first->second;
-}
-
-uint32_t StringTable::calculateSerializedSize() const { return StringSize; }
-
-Error StringTable::commit(BinaryStreamWriter &Writer) const {
- assert(Writer.bytesRemaining() == StringSize);
- uint32_t MaxOffset = 1;
-
- for (auto &Pair : Strings) {
- StringRef S = Pair.getKey();
- uint32_t Offset = Pair.getValue();
- Writer.setOffset(Offset);
- if (auto EC = Writer.writeCString(S))
- return EC;
- MaxOffset = std::max<uint32_t>(MaxOffset, Offset + S.size() + 1);
- }
-
- Writer.setOffset(MaxOffset);
- assert(Writer.bytesRemaining() == 0);
- return Error::success();
-}
-
-uint32_t StringTable::size() const { return Strings.size(); }
-
-uint32_t StringTable::getStringId(StringRef S) const {
- auto P = Strings.find(S);
- assert(P != Strings.end());
- return P->second;
-}
Modified: llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp Tue May 30 12:13:33 2017
@@ -11,8 +11,8 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
-#include "llvm/DebugInfo/CodeView/StringTable.h"
#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
@@ -369,7 +369,7 @@ Error CVSymbolDumperImpl::visitKnownReco
DictScope S(W, "DefRangeSubfield");
if (ObjDelegate) {
- StringTableRef Strings = ObjDelegate->getStringTable();
+ DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
auto ExpectedProgram = Strings.getString(DefRangeSubfield.Program);
if (!ExpectedProgram) {
consumeError(ExpectedProgram.takeError());
@@ -390,7 +390,7 @@ Error CVSymbolDumperImpl::visitKnownReco
DictScope S(W, "DefRange");
if (ObjDelegate) {
- StringTableRef Strings = ObjDelegate->getStringTable();
+ DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
auto ExpectedProgram = Strings.getString(DefRange.Program);
if (!ExpectedProgram) {
consumeError(ExpectedProgram.takeError());
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=304222&r1=304221&r2=304222&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Tue May 30 12:13:33 2017
@@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//
#include "ARMWinEHPrinter.h"
-#include "CodeView.h"
#include "Error.h"
#include "ObjDumper.h"
#include "StackMapPrinter.h"
@@ -25,12 +24,13 @@
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
#include "llvm/DebugInfo/CodeView/Line.h"
#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
-#include "llvm/DebugInfo/CodeView/StringTable.h"
#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
#include "llvm/DebugInfo/CodeView/SymbolDumper.h"
@@ -157,9 +157,9 @@ private:
bool RelocCached = false;
RelocMapTy RelocMap;
- VarStreamArray<FileChecksumEntry> CVFileChecksumTable;
+ DebugChecksumsSubsectionRef CVFileChecksumTable;
- StringTableRef CVStringTable;
+ DebugStringTableSubsectionRef CVStringTable;
ScopedPrinter &Writer;
BinaryByteStream TypeContents;
@@ -200,7 +200,9 @@ public:
return CD.getFileNameForFileOffset(FileOffset);
}
- StringTableRef getStringTable() override { return CD.CVStringTable; }
+ DebugStringTableSubsectionRef getStringTable() override {
+ return CD.CVStringTable;
+ }
private:
COFFDumper &CD;
@@ -774,16 +776,14 @@ void COFFDumper::initializeFileAndString
StringRef Contents;
error(Reader.readFixedString(Contents, SubSectionSize));
+ BinaryStreamRef ST(Contents, support::little);
switch (DebugSubsectionKind(SubType)) {
- case DebugSubsectionKind::FileChecksums: {
- BinaryStreamReader CSR(Contents, support::little);
- error(CSR.readArray(CVFileChecksumTable, CSR.getLength()));
+ case DebugSubsectionKind::FileChecksums:
+ error(CVFileChecksumTable.initialize(ST));
break;
- }
- case DebugSubsectionKind::StringTable: {
- BinaryStreamRef ST(Contents, support::little);
+ case DebugSubsectionKind::StringTable:
error(CVStringTable.initialize(ST));
- } break;
+ break;
default:
break;
}
@@ -889,31 +889,30 @@ void COFFDumper::printCodeViewSymbolSect
case DebugSubsectionKind::FrameData: {
// First four bytes is a relocation against the function.
BinaryStreamReader SR(Contents, llvm::support::little);
- const uint32_t *CodePtr;
- error(SR.readObject(CodePtr));
+
+ DebugFrameDataSubsectionRef FrameData;
+ error(FrameData.initialize(SR));
+
StringRef LinkageName;
error(resolveSymbolName(Obj->getCOFFSection(Section), SectionContents,
- CodePtr, LinkageName));
+ FrameData.getRelocPtr(), LinkageName));
W.printString("LinkageName", LinkageName);
// To find the active frame description, search this array for the
// smallest PC range that includes the current PC.
- while (!SR.empty()) {
- const FrameData *FD;
- error(SR.readObject(FD));
-
- StringRef FrameFunc = error(CVStringTable.getString(FD->FrameFunc));
+ for (const auto &FD : FrameData) {
+ StringRef FrameFunc = error(CVStringTable.getString(FD.FrameFunc));
DictScope S(W, "FrameData");
- W.printHex("RvaStart", FD->RvaStart);
- W.printHex("CodeSize", FD->CodeSize);
- W.printHex("LocalSize", FD->LocalSize);
- W.printHex("ParamsSize", FD->ParamsSize);
- W.printHex("MaxStackSize", FD->MaxStackSize);
+ W.printHex("RvaStart", FD.RvaStart);
+ W.printHex("CodeSize", FD.CodeSize);
+ W.printHex("LocalSize", FD.LocalSize);
+ W.printHex("ParamsSize", FD.ParamsSize);
+ W.printHex("MaxStackSize", FD.MaxStackSize);
W.printString("FrameFunc", FrameFunc);
- W.printHex("PrologSize", FD->PrologSize);
- W.printHex("SavedRegsSize", FD->SavedRegsSize);
- W.printFlags("Flags", FD->Flags, makeArrayRef(FrameDataFlags));
+ W.printHex("PrologSize", FD.PrologSize);
+ W.printHex("SavedRegsSize", FD.SavedRegsSize);
+ W.printFlags("Flags", FD.Flags, makeArrayRef(FrameDataFlags));
}
break;
}
@@ -996,9 +995,9 @@ void COFFDumper::printCodeViewSymbolsSub
}
void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
- BinaryStreamReader SR(Subsection, llvm::support::little);
+ BinaryStreamRef Stream(Subsection, llvm::support::little);
DebugChecksumsSubsectionRef Checksums;
- error(Checksums.initialize(SR));
+ error(Checksums.initialize(Stream));
for (auto &FC : Checksums) {
DictScope S(W, "FileChecksum");
@@ -1039,7 +1038,7 @@ StringRef COFFDumper::getFileNameForFile
if (!CVFileChecksumTable.valid() || !CVStringTable.valid())
error(object_error::parse_failed);
- auto Iter = CVFileChecksumTable.at(FileOffset);
+ auto Iter = CVFileChecksumTable.getArray().at(FileOffset);
// Check if the file checksum table offset is valid.
if (Iter == CVFileChecksumTable.end())
Removed: llvm/trunk/tools/llvm-readobj/CodeView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/CodeView.h?rev=304221&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-readobj/CodeView.h (original)
+++ llvm/trunk/tools/llvm-readobj/CodeView.h (removed)
@@ -1,54 +0,0 @@
-//===-- CodeView.h - On-disk record types for CodeView ----------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// \brief This file provides data structures useful for consuming on-disk
-/// CodeView. It is based on information published by Microsoft at
-/// https://github.com/Microsoft/microsoft-pdb/.
-///
-//===----------------------------------------------------------------------===//
-
-// FIXME: Find a home for this in include/llvm/DebugInfo/CodeView/.
-
-#ifndef LLVM_READOBJ_CODEVIEW_H
-#define LLVM_READOBJ_CODEVIEW_H
-
-#include "llvm/DebugInfo/CodeView/CodeView.h"
-#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-#include "llvm/Support/Endian.h"
-
-namespace llvm {
-namespace codeview {
-
-using llvm::support::ulittle16_t;
-using llvm::support::ulittle32_t;
-
-/// Data in the the SUBSEC_FRAMEDATA subection.
-struct FrameData {
- ulittle32_t RvaStart;
- ulittle32_t CodeSize;
- ulittle32_t LocalSize;
- ulittle32_t ParamsSize;
- ulittle32_t MaxStackSize;
- ulittle32_t FrameFunc;
- ulittle16_t PrologSize;
- ulittle16_t SavedRegsSize;
- ulittle32_t Flags;
- enum : uint32_t {
- HasSEH = 1 << 0,
- HasEH = 1 << 1,
- IsFunctionStart = 1 << 2,
- };
-};
-
-
-} // namespace codeview
-} // namespace llvm
-
-#endif // LLVM_READOBJ_CODEVIEW_H
More information about the llvm-commits
mailing list