summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-08-29 11:22:53 -0700
committerGitHub <noreply@github.com>2023-08-29 11:22:53 -0700
commitb29cdd4e63bedcfbd357b0ad49ce4301cb94bb87 (patch)
tree7b3b33da6a00090f506d8fea7af110e86da391d7 /src/passes/Print.cpp
parent65eb4219396e32aa76fca59226f523b8dfe01bcb (diff)
downloadbinaryen-b29cdd4e63bedcfbd357b0ad49ce4301cb94bb87.tar.gz
binaryen-b29cdd4e63bedcfbd357b0ad49ce4301cb94bb87.tar.bz2
binaryen-b29cdd4e63bedcfbd357b0ad49ce4301cb94bb87.zip
Print all debug annotations when BINARYEN_PRINT_FULL (#5904)
In general, full print mode should print out all the things to avoid confusion. It already did so for blocks (that the text format sometimes elides), types, etc. Doing it for debug info can avoid confusion when debugging (in fact, this was one of the main reasons I've been confused about how source maps work in Binaryen...). Also add a comment to the code just landed in #5903
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 3ae7b6899..7ceb4393a 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -170,6 +170,25 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
std::vector<HeapType> heapTypes;
+ // Track the print indent so that we can see when it changes. That affects how
+ // we print debug annotations. In particular, we don't want to print repeated
+ // debug locations for children, like this:
+ //
+ // ;;@ file.cpp:20:4
+ // (block
+ // ;; no need to annotate here; children have the parent's location by
+ // ;; default anyhow
+ // (nop)
+ //
+ // But we do want to print an annotation even if it repeats if it is not a
+ // child:
+ //
+ // ;;@ file.cpp:20:4
+ // (block)
+ // ;;@ file.cpp:20:4 - this is clearer to annotate, to avoid confusion with
+ // the case where there is no debug info on the nop
+ // (nop)
+ //
unsigned lastPrintIndent = 0;
// Print type names by saved name or index if we have a module, or otherwise
@@ -2377,7 +2396,9 @@ std::ostream& PrintSExpression::printPrefixedTypes(const char* prefix,
void PrintSExpression::printDebugLocation(
const Function::DebugLocation& location) {
- if (lastPrintedLocation == location && indent > lastPrintIndent) {
+ // Do not skip repeated debug info in full mode, for less-confusing debugging:
+ // full mode prints out everything in the most verbose manner.
+ if (lastPrintedLocation == location && indent > lastPrintIndent && !full) {
return;
}
lastPrintedLocation = location;