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

Feature Request: Annotating Start and End Instructions for Solidity Statements to Enhance Interactive Stepping Semantics #40

Open
RaoulSchaffranek opened this issue Dec 1, 2023 · 0 comments

Comments

@RaoulSchaffranek
Copy link

Context

Our team is actively developing a Solidity debugger aimed at providing a more robust and intuitive debugging experience for Solidity developers. A key feature of any interactive debugger is the implementation of precise interactive stepping semantics, such as "step to the next statement."

Current Limitation

Our debugger currently relies on a heuristic approach to determine the boundaries of Solidity statements during debugging. This method checks whether the current instruction maps to a different statement than the preceding one. While this heuristic works in many cases, it fails to accurately handle more complex constructs, particularly function calls in Solidity.

Issue Illustrated with Function Calls

In Solidity's compiled code, function calls are typically divided into three sections:

  1. Argument Stack Preparation: The first section pushes arguments onto the stack and maps to the function call.
  2. Function Execution: The second section, encompassing JUMP instructions, corresponds to the statements inside the function body.
  3. Return Value Handling: The final section, which handles return values, maps back to the function call.

The challenge arises because the first and third sections are both mapped to the same function call. This leads to inaccuracies with our current heuristic method. For example, when the debugger is at the last statement of the function body and aims to "step to the next statement," it mistakenly steps back to the function call instead of moving beyond it.

Proposed Enhancement

To overcome this limitation, we suggest annotating the first and last instructions corresponding to the same Solidity statement. This additional information during compilation would allow debuggers to accurately identify each statement's start and end points, thereby improving the implementation of stepping semantics.

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

No branches or pull requests

1 participant