summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/CodeView
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView')
-rw-r--r--llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp21
-rw-r--r--llvm/lib/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.cpp17
-rw-r--r--llvm/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp14
-rw-r--r--llvm/lib/DebugInfo/CodeView/StringTable.cpp6
4 files changed, 41 insertions, 17 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp b/llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp
index 87763248391..42f0afc3e2d 100644
--- a/llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp
@@ -10,6 +10,7 @@
#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
+#include "llvm/DebugInfo/CodeView/StringTable.h"
#include "llvm/Support/BinaryStreamReader.h"
using namespace llvm;
@@ -49,10 +50,12 @@ Error ModuleDebugFileChecksumFragmentRef::initialize(
return Error::success();
}
-ModuleDebugFileChecksumFragment::ModuleDebugFileChecksumFragment()
- : ModuleDebugFragment(ModuleDebugFragmentKind::FileChecksums) {}
+ModuleDebugFileChecksumFragment::ModuleDebugFileChecksumFragment(
+ StringTable &Strings)
+ : ModuleDebugFragment(ModuleDebugFragmentKind::FileChecksums),
+ Strings(Strings) {}
-void ModuleDebugFileChecksumFragment::addChecksum(uint32_t StringTableOffset,
+void ModuleDebugFileChecksumFragment::addChecksum(StringRef FileName,
FileChecksumKind Kind,
ArrayRef<uint8_t> Bytes) {
FileChecksumEntry Entry;
@@ -61,13 +64,14 @@ void ModuleDebugFileChecksumFragment::addChecksum(uint32_t StringTableOffset,
::memcpy(Copy, Bytes.data(), Bytes.size());
Entry.Checksum = makeArrayRef(Copy, Bytes.size());
}
- Entry.FileNameOffset = StringTableOffset;
+
+ Entry.FileNameOffset = Strings.insert(FileName);
Entry.Kind = Kind;
Checksums.push_back(Entry);
// This maps the offset of this string in the string table to the offset
// of this checksum entry in the checksum buffer.
- OffsetMap[StringTableOffset] = SerializedSize;
+ OffsetMap[Entry.FileNameOffset] = SerializedSize;
assert(SerializedSize % 4 == 0);
uint32_t Len = alignTo(sizeof(FileChecksumEntryHeader) + Bytes.size(), 4);
@@ -94,9 +98,10 @@ Error ModuleDebugFileChecksumFragment::commit(BinaryStreamWriter &Writer) {
return Error::success();
}
-uint32_t ModuleDebugFileChecksumFragment::mapChecksumOffset(
- uint32_t StringTableOffset) const {
- auto Iter = OffsetMap.find(StringTableOffset);
+uint32_t
+ModuleDebugFileChecksumFragment::mapChecksumOffset(StringRef FileName) const {
+ uint32_t Offset = Strings.getStringId(FileName);
+ auto Iter = OffsetMap.find(Offset);
assert(Iter != OffsetMap.end());
return Iter->second;
}
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.cpp b/llvm/lib/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.cpp
index c54fb2d784a..a908e7df28b 100644
--- a/llvm/lib/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.cpp
@@ -10,7 +10,9 @@
#include "llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"
+#include "llvm/DebugInfo/CodeView/StringTable.h"
using namespace llvm;
using namespace llvm::codeview;
@@ -55,9 +57,10 @@ bool ModuleDebugInlineeLineFragmentRef::hasExtraFiles() const {
}
ModuleDebugInlineeLineFragment::ModuleDebugInlineeLineFragment(
+ ModuleDebugFileChecksumFragment &Checksums, StringTable &Strings,
bool HasExtraFiles)
: ModuleDebugFragment(ModuleDebugFragmentKind::InlineeLines),
- HasExtraFiles(HasExtraFiles) {}
+ Checksums(Checksums), Strings(Strings), HasExtraFiles(HasExtraFiles) {}
uint32_t ModuleDebugInlineeLineFragment::calculateSerializedLength() {
// 4 bytes for the signature
@@ -100,18 +103,22 @@ Error ModuleDebugInlineeLineFragment::commit(BinaryStreamWriter &Writer) {
return Error::success();
}
-void ModuleDebugInlineeLineFragment::addExtraFile(uint32_t FileOffset) {
+void ModuleDebugInlineeLineFragment::addExtraFile(StringRef FileName) {
+ uint32_t Offset = Checksums.mapChecksumOffset(FileName);
+
auto &Entry = Entries.back();
- Entry.ExtraFiles.push_back(ulittle32_t(FileOffset));
+ Entry.ExtraFiles.push_back(ulittle32_t(Offset));
++ExtraFileCount;
}
void ModuleDebugInlineeLineFragment::addInlineSite(TypeIndex FuncId,
- uint32_t FileOffset,
+ StringRef FileName,
uint32_t SourceLine) {
+ uint32_t Offset = Checksums.mapChecksumOffset(FileName);
+
Entries.emplace_back();
auto &Entry = Entries.back();
- Entry.Header.FileID = FileOffset;
+ Entry.Header.FileID = Offset;
Entry.Header.SourceLineNum = SourceLine;
Entry.Header.Inlinee = FuncId;
}
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp b/llvm/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp
index 103010ca283..fdba1147f0b 100644
--- a/llvm/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp
@@ -10,7 +10,9 @@
#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"
+#include "llvm/DebugInfo/CodeView/StringTable.h"
using namespace llvm;
using namespace llvm::codeview;
@@ -65,11 +67,15 @@ bool ModuleDebugLineFragmentRef::hasColumnInfo() const {
return !!(Header->Flags & LF_HaveColumns);
}
-ModuleDebugLineFragment::ModuleDebugLineFragment()
- : ModuleDebugFragment(ModuleDebugFragmentKind::Lines) {}
+ModuleDebugLineFragment::ModuleDebugLineFragment(
+ ModuleDebugFileChecksumFragment &Checksums, StringTable &Strings)
+ : ModuleDebugFragment(ModuleDebugFragmentKind::Lines), Checksums(Checksums),
+ Strings(Strings) {}
-void ModuleDebugLineFragment::createBlock(uint32_t ChecksumBufferOffset) {
- Blocks.emplace_back(ChecksumBufferOffset);
+void ModuleDebugLineFragment::createBlock(StringRef FileName) {
+ uint32_t Offset = Checksums.mapChecksumOffset(FileName);
+
+ Blocks.emplace_back(Offset);
}
void ModuleDebugLineFragment::addLineInfo(uint32_t Offset,
diff --git a/llvm/lib/DebugInfo/CodeView/StringTable.cpp b/llvm/lib/DebugInfo/CodeView/StringTable.cpp
index f496854ffaf..21f11204686 100644
--- a/llvm/lib/DebugInfo/CodeView/StringTable.cpp
+++ b/llvm/lib/DebugInfo/CodeView/StringTable.cpp
@@ -63,3 +63,9 @@ Error StringTable::commit(BinaryStreamWriter &Writer) const {
}
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;
+}
OpenPOWER on IntegriCloud