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

Add debug file dump #7375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

piohei
Copy link

@piohei piohei commented Mar 12, 2024

Motivation

It could be very helpful to be able to dump to a JSON file whole debugger context: calls, source code, refs, etc. It would allow then to do a post processing like for example creating heatmap for most costly lines in terms of gas usage.

Closes #7364

Solution

New --dump param is being added to forge debug and forge test --debug commands. It requires a path to file where to dump data and passing --debug flag same time. Debugger code is refactored to create abstraction over it. It is then used by two different presenters: TUI (interactive debugger) and file dumper. I also added to debugger data original path for the source file to allow figuring out where to make changes when debugging.

Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not too sure i am fond of this approach, ideally we'd move away from allocating a big chunk of memory for the debugger, i.e. ideally we'd move away from record/replay

@piohei
Copy link
Author

piohei commented Mar 12, 2024

Thanks for comment! Do you find the idea of changing record/replay approach as a new feature request or a blocker for that functionality? This record/replay could be also run only for the dumping or dump can be created on the fly and written to file. The main idea is to be able to use that output for post processing things. Other approach could be to create a plugin system and move things like that out of the core of foundry. What do you think?

@onbjerg
Copy link
Member

onbjerg commented Mar 12, 2024

hmm, thinking about this more, I think this is ok. if/when we move away from record/replay we can always change this as well

would like input from @DaniPopes iirc there are some coming changes to the debugger?

@piohei piohei force-pushed the add_debug_file_dump branch 6 times, most recently from a131d07 to 940393c Compare March 19, 2024 06:51
@piohei piohei closed this Mar 19, 2024
@piohei piohei reopened this Mar 19, 2024
@piohei piohei marked this pull request as ready for review March 19, 2024 07:57
@onbjerg
Copy link
Member

onbjerg commented Mar 19, 2024

ping @DaniPopes

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

would like input from @DaniPopes iirc there are some coming changes to the debugger?

No

@piohei
Copy link
Author

piohei commented Mar 19, 2024

Just fixed tests (clippy + fmt)

@piohei
Copy link
Author

piohei commented Mar 20, 2024

Fixed (again) - now using proper rust version locally. I don't know if this is intentional or not but in Cargo.toml there is rust-version = "1.76" while CI is using nightly version.

@piohei
Copy link
Author

piohei commented Mar 22, 2024

Any chances for merging this one? :) I don't want to mix same code and I could then work on fixing this #7292.

@mattsse
Copy link
Member

mattsse commented Apr 8, 2024

very sorry about this @piohei

this now has a few conflicts that must be resolved first, still supportive of that feature

@piohei
Copy link
Author

piohei commented Apr 8, 2024

No problem. I will fix them. :)

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.

Forge debugger should be able to dump all the steps (with state) to a file
4 participants