diff options
author | Derek Schuff <dschuff@chromium.org> | 2017-04-13 15:12:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 15:12:48 -0700 |
commit | ec66e273e350c3d48df0ccaaf73c53b14485848f (patch) | |
tree | feb2c5369686faf7a4a170df550e0ce18229b39c /src/asm2wasm.h | |
parent | 57a2bb96c7b8a98433446828aca845a9e9be8c3d (diff) | |
download | binaryen-ec66e273e350c3d48df0ccaaf73c53b14485848f.tar.gz binaryen-ec66e273e350c3d48df0ccaaf73c53b14485848f.tar.bz2 binaryen-ec66e273e350c3d48df0ccaaf73c53b14485848f.zip |
Replace text annotations with explicit file/line for debug info (#967)
Rather than storing debug info as text annotations, store explicit file and line information. This will make it easier to experiment with outputting other serializations or representations (e.g. source maps), and will allow outputting debug info for binaries as well.
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 5adf82762..ada026176 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1171,6 +1171,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { if (runOptimizationPasses) { optimizingBuilder->finish(); } + wasm.debugInfoFileNames = std::move(preprocessor.debugInfoFileNames); // second pass. first, function imports @@ -1306,11 +1307,12 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // this is a debuginfo node. turn it into an annotation on the last stack auto* last = lastExpression; lastExpression = nullptr; - auto& annotations = getFunction()->annotations; + auto& debugLocations = getFunction()->debugLocations; if (last) { - auto fileIndex = call->operands[0]->cast<Const>()->value.geti32(); - auto lineNumber = call->operands[1]->cast<Const>()->value.geti32(); - annotations[last] = parent->preprocessor.debugInfoFileNames[fileIndex] + ":" + std::to_string(lineNumber); + uint32_t fileIndex = call->operands[0]->cast<Const>()->value.geti32(); + assert(getModule()->debugInfoFileNames.size() > fileIndex); + uint32_t lineNumber = call->operands[1]->cast<Const>()->value.geti32(); + debugLocations[last] = {fileIndex, lineNumber}; } // eliminate the debug info call ExpressionManipulator::nop(curr); |