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

[llvm-context,solidity] Generate debug-info location information. #43

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

Conversation

wpt967
Copy link
Collaborator

@wpt967 wpt967 commented Sep 11, 2024

Generate source level debug information for the functions defined when generating LLVM-IR. This includes the deploy_code and runtime functions generated by the compiler.

Also generate debug-location information for other constructs that may appear.

Copy link
Member

@xermicus xermicus left a comment

Choose a reason for hiding this comment

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

Code wise looks good overall, thanks! However applying -g on the Baseline.sol contract invalidates the LLVM module. It might be a good idea to enable debug info generation by default when compiling integration tests with the revive_solidity::test_utils? This should give us reasonable test coverage.

I think it'd also be worthwhile to add a simple test case to explicitly test the information generated, just to be sure that the feature works as intended in principle. Doesn't have to be fancy, could be a rudimentary contract already in the integration test suite, where we just assert to find the correct line and object for some variable in a simply Solidity. WDYT?

@xermicus
Copy link
Member

Code wise looks good overall, thanks! However applying -g on the Baseline.sol contract invalidates the LLVM module.

Apparently only reproducible when the solc optimizer is disabled (-g --disable-solc-optimizer)

@wpt967
Copy link
Collaborator Author

wpt967 commented Sep 13, 2024

The problem seems to be with some debug locations getting out of sync with the function definitions they appear in.
There are also a couple of other related problems that will need to be fixed, to do with the generating debug scopes and locations in the right places.

@xermicus
Copy link
Member

xermicus commented Sep 13, 2024

I see, thanks for looking into this!

debug locations getting out of sync

Do you have any idea why this happens? Is it a bug in solc or is it some known limitation and we have to fix our configuration (see settings->optimizer in the JSON struct) when disabling the optimizer?

@wpt967 wpt967 force-pushed the debug-info branch 2 times, most recently from bded209 to 7deca70 Compare September 17, 2024 11:08
@wpt967 wpt967 force-pushed the debug-info branch 7 times, most recently from eff120f to 769abd9 Compare October 3, 2024 14:45
Add command line option '-g' to generate source level debug information
in the output code. This only works with the LLVM-IR code generator.

Add flag 'emit_debug_info' to the llvm-context optimizer/code-gen
settings structure, to record the setting of the '-g' CLI option.
@wpt967 wpt967 force-pushed the debug-info branch 5 times, most recently from a16de55 to 2f54c71 Compare October 4, 2024 14:53
When debug-info generation is enabled, construct a DebugInfo instance.

Add a namespace stack to the DebugInfo structure to keep track of the
names of named scopes, such as namespaces, objects and functions,
enclosing a construct.

Generate source level debug information for the functions defined when
YUL is lowered to LLVM-IR. This includes the deploy_code and runtime
functions generated by the compiler.

Generate debug-location information for other constructs that may appear
in a contract.
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