diff options
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 9b1f24a0f..8d42fb9f4 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -160,7 +160,8 @@ void WasmBinaryWriter::finishSection(int32_t start) { // We are relative to the section start. auto totalAdjustment = adjustmentForLEBShrinking + body; for (auto& pair : binaryLocations.expressions) { - pair.second -= totalAdjustment; + pair.second.start -= totalAdjustment; + pair.second.end -= totalAdjustment; } for (auto& pair : binaryLocations.functions) { pair.second.start -= totalAdjustment; @@ -339,7 +340,9 @@ void WasmBinaryWriter::writeFunctions() { for (auto* curr : binaryLocationTrackedExpressionsForFunc) { // We added the binary locations, adjust them: they must be relative // to the code section. - binaryLocations.expressions[curr] -= adjustmentForLEBShrinking; + auto& span = binaryLocations.expressions[curr]; + span.start -= adjustmentForLEBShrinking; + span.end -= adjustmentForLEBShrinking; } } if (!binaryLocationTrackedExpressionsForFunc.empty()) { @@ -708,11 +711,20 @@ void WasmBinaryWriter::writeDebugLocation(Expression* curr, Function* func) { // If this is an instruction in a function, and if the original wasm had // binary locations tracked, then track it in the output as well. if (func && !func->expressionLocations.empty()) { - binaryLocations.expressions[curr] = o.size(); + binaryLocations.expressions[curr] = + BinaryLocations::Span{uint32_t(o.size()), 0}; binaryLocationTrackedExpressionsForFunc.push_back(curr); } } +void WasmBinaryWriter::writeDebugLocationEnd(Expression* curr, Function* func) { + if (func && !func->expressionLocations.empty()) { + auto& span = binaryLocations.expressions.at(curr); + assert(span.end == 0); + span.end = o.size(); + } +} + void WasmBinaryWriter::writeInlineString(const char* name) { int32_t size = strlen(name); o << U32LEB(size); @@ -2293,7 +2305,9 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { currFunction->debugLocations[curr] = *currDebugLocation.begin(); } if (DWARF && currFunction) { - currFunction->expressionLocations[curr] = startPos - codeSectionLocation; + currFunction->expressionLocations[curr] = + BinaryLocations::Span{uint32_t(startPos - codeSectionLocation), + uint32_t(pos - codeSectionLocation)}; } } BYN_TRACE("zz recurse from " << depth-- << " at " << pos << std::endl); |