diff options
author | JesseChen <56120624+JesseCodeBones@users.noreply.github.com> | 2023-08-29 03:55:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-28 12:55:25 -0700 |
commit | 059893936ff1c44cf128b14a526fb7ed32a5f285 (patch) | |
tree | e75d1ec593204381c7b3eaac92a0274cddf9088d | |
parent | 0e5ee1cb368548f6890efcc05c980d5bb56f27d6 (diff) | |
download | binaryen-059893936ff1c44cf128b14a526fb7ed32a5f285.tar.gz binaryen-059893936ff1c44cf128b14a526fb7ed32a5f285.tar.bz2 binaryen-059893936ff1c44cf128b14a526fb7ed32a5f285.zip |
Improve debug info printing with depth (#5903)
Skip repeated identical debug info only of more-nested nodes. Before this PR we
skipped sibling nodes and even parent nodes, which could be confusing. After
this PR there is a more clear connection: child nodes have the same debug location
as the parent, by default, and so there is no need to print it again.
-rw-r--r-- | src/passes/Print.cpp | 5 | ||||
-rw-r--r-- | test/fib-dbg.wasm.fromBinary | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 7f06f8c17..3ae7b6899 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -170,6 +170,8 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { std::vector<HeapType> heapTypes; + unsigned lastPrintIndent = 0; + // Print type names by saved name or index if we have a module, or otherwise // by generating minimalist names. TODO: Handle conflicts between // user-provided names and the fallback indexed names. @@ -2375,10 +2377,11 @@ std::ostream& PrintSExpression::printPrefixedTypes(const char* prefix, void PrintSExpression::printDebugLocation( const Function::DebugLocation& location) { - if (lastPrintedLocation == location) { + if (lastPrintedLocation == location && indent > lastPrintIndent) { return; } lastPrintedLocation = location; + lastPrintIndent = indent; auto fileName = currModule->debugInfoFileNames[location.fileIndex]; o << ";;@ " << fileName << ":" << location.lineNumber << ":" << location.columnNumber << '\n'; diff --git a/test/fib-dbg.wasm.fromBinary b/test/fib-dbg.wasm.fromBinary index 3cfa1bc66..f36bd2250 100644 --- a/test/fib-dbg.wasm.fromBinary +++ b/test/fib-dbg.wasm.fromBinary @@ -133,6 +133,7 @@ (i32.const 0) ) ) + ;;@ fib.c:3:0 (if (local.get $6) (block @@ -156,6 +157,7 @@ ) ) ) + ;;@ fib.c:8:0 (loop $label$4 (block $label$5 ;;@ fib.c:4:0 @@ -172,12 +174,14 @@ (i32.const 1) ) ) + ;;@ fib.c:3:0 (local.set $7 (i32.eq (local.get $9) (local.get $0) ) ) + ;;@ fib.c:3:0 (if (local.get $7) (block @@ -201,6 +205,7 @@ ) ) ) + ;;@ fib.c:3:0 (br $label$4) ) ) |