Skip to content

Commit 6e506af

Browse files
JesseCodeBonesradekdoulik
authored andcommitted
Improve debug info printing with depth (WebAssembly#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.
1 parent 359392a commit 6e506af

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/passes/Print.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
170170

171171
std::vector<HeapType> heapTypes;
172172

173+
unsigned lastPrintIndent = 0;
174+
173175
// Print type names by saved name or index if we have a module, or otherwise
174176
// by generating minimalist names. TODO: Handle conflicts between
175177
// user-provided names and the fallback indexed names.
@@ -2375,10 +2377,11 @@ std::ostream& PrintSExpression::printPrefixedTypes(const char* prefix,
23752377

23762378
void PrintSExpression::printDebugLocation(
23772379
const Function::DebugLocation& location) {
2378-
if (lastPrintedLocation == location) {
2380+
if (lastPrintedLocation == location && indent > lastPrintIndent) {
23792381
return;
23802382
}
23812383
lastPrintedLocation = location;
2384+
lastPrintIndent = indent;
23822385
auto fileName = currModule->debugInfoFileNames[location.fileIndex];
23832386
o << ";;@ " << fileName << ":" << location.lineNumber << ":"
23842387
<< location.columnNumber << '\n';

test/fib-dbg.wasm.fromBinary

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
(i32.const 0)
134134
)
135135
)
136+
;;@ fib.c:3:0
136137
(if
137138
(local.get $6)
138139
(block
@@ -156,6 +157,7 @@
156157
)
157158
)
158159
)
160+
;;@ fib.c:8:0
159161
(loop $label$4
160162
(block $label$5
161163
;;@ fib.c:4:0
@@ -172,12 +174,14 @@
172174
(i32.const 1)
173175
)
174176
)
177+
;;@ fib.c:3:0
175178
(local.set $7
176179
(i32.eq
177180
(local.get $9)
178181
(local.get $0)
179182
)
180183
)
184+
;;@ fib.c:3:0
181185
(if
182186
(local.get $7)
183187
(block
@@ -201,6 +205,7 @@
201205
)
202206
)
203207
)
208+
;;@ fib.c:3:0
204209
(br $label$4)
205210
)
206211
)

0 commit comments

Comments
 (0)