Skip to content
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

Json debug in phase stats #876

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

elegios
Copy link
Contributor

@elegios elegios commented Nov 20, 2024

This is based on #738 until it is merged.

This PR adds a new flag --debug-phase <phase> that uses mexpr/json-debug.mc to dump the AST at a named phase, which is specified with endPhaseStats in the code. The option can be given multiple times to print multiple phases. No spell-checking is done, since we don't have a data structure that stores the existing phases, so you'd typically use this by running with --debug-phases first (note the plural) then with the appropriate --debug-phase (or looking in the code of course).

I also add a new function in json.mc for printing the json representation directly, because building the interim string was very prohibitive. I suppose this is something of a known thing performance-wise, but it might also be relevant for pprint.mc when it's used during compilation, maybe we could make compilation faster if we could change this.

@marten-voorberg
Copy link
Contributor

I love this!

I think it might be nice to have a pretty print option too. So you can choose whether you want your debug information as a pprint or as a JSON.

I have some changes on one of my branches making it so the debugPhases works on the MLangProgram type as well by the way. So these changes will conflict when we eventually merge but the conflict should be minor.

@elegios elegios force-pushed the json-debug-in-phase-stats branch 7 times, most recently from 2ed2f2d to 07a2dbe Compare November 25, 2024 15:52
@elegios elegios force-pushed the json-debug-in-phase-stats branch 2 times, most recently from d24f509 to c5c73e2 Compare December 6, 2024 12:32
@elegios elegios force-pushed the json-debug-in-phase-stats branch 2 times, most recently from a72951c to 4a30c57 Compare January 7, 2025 11:32
@elegios elegios force-pushed the json-debug-in-phase-stats branch from 4a30c57 to c647fb8 Compare January 15, 2025 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants