summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm/wasm-debug.cpp10
-rw-r--r--third_party/llvm-project/dwarf2yaml.cpp2
-rw-r--r--third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h1
3 files changed, 11 insertions, 2 deletions
diff --git a/src/wasm/wasm-debug.cpp b/src/wasm/wasm-debug.cpp
index 867f4b14b..60e97a27e 100644
--- a/src/wasm/wasm-debug.cpp
+++ b/src/wasm/wasm-debug.cpp
@@ -629,6 +629,11 @@ struct LocationUpdater {
// Given an offset in .debug_loc, get the old and new compile unit bases.
OldToNew getCompileUnitBasesForLoc(size_t offset) const {
+ if (locToUnitMap.count(offset) == 0) {
+ // There is no compile unit for this loc. It doesn't matter what we set
+ // here.
+ return OldToNew{0, 0};
+ }
auto index = locToUnitMap.at(offset);
auto iter = compileUnitBases.find(index);
if (iter != compileUnitBases.end()) {
@@ -754,11 +759,12 @@ static void updateDebugLines(llvm::DWARFYAML::Data& data,
// debug_line section.
std::vector<size_t> computedLengths;
llvm::DWARFYAML::ComputeDebugLine(data, computedLengths);
- BinaryLocation oldLocation = 0, newLocation = 0;
+ BinaryLocation newLocation = 0;
for (size_t i = 0; i < data.DebugLines.size(); i++) {
auto& table = data.DebugLines[i];
+ auto oldLocation = table.Position;
locationUpdater.debugLineMap[oldLocation] = newLocation;
- oldLocation += table.Length.getLength() + AddressSize;
+ table.Position = newLocation;
newLocation += computedLengths[i] + AddressSize;
table.Length.setLength(computedLengths[i]);
}
diff --git a/third_party/llvm-project/dwarf2yaml.cpp b/third_party/llvm-project/dwarf2yaml.cpp
index eed340964..6ba73d1ec 100644
--- a/third_party/llvm-project/dwarf2yaml.cpp
+++ b/third_party/llvm-project/dwarf2yaml.cpp
@@ -325,6 +325,8 @@ void dumpDebugLines(DWARFContext &DCtx, DWARFYAML::Data &Y) {
DataExtractor LineData(DCtx.getDWARFObj().getLineSection().Data,
DCtx.isLittleEndian(), CU->getAddressByteSize());
uint64_t Offset = *StmtOffset;
+ DebugLines.Position = Offset;
+
dumpInitialLength(LineData, Offset, DebugLines.Length);
uint64_t LineTableLength = DebugLines.Length.getLength();
uint64_t SizeOfPrologueLength = DebugLines.Length.isDWARF64() ? 8 : 4;
diff --git a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
index 510610123..bb66565a5 100644
--- a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
+++ b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
@@ -151,6 +151,7 @@ struct LineTableOpcode {
};
struct LineTable {
+ uint64_t Position; // XXX BINARYEN: the binary location in .debug_line
InitialLength Length;
uint16_t Version;
uint64_t PrologueLength;