-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: debug info print with depth #5903
Conversation
@kripken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good with some comments, see the suggestion. Is what I wrote there correct?
@@ -170,6 +170,8 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { | |||
|
|||
std::vector<HeapType> heapTypes; | |||
|
|||
unsigned lastPrintIndent = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining the motivation for tracking the print indent, maybe with an example? I am imagining something like this:
// 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
// (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 worth annotating
// (nop)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually let me land this - I have a followup to this code, and there would just be merge conflicts etc. I'll add a comment in my PR.
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
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.
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 WebAssembly#5903
Split from #5547.
Focus on debug info print optimization.