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

Debugger: support step-over and step-out commands #2454

Open
ivan-mogilko opened this issue Jun 21, 2024 · 3 comments
Open

Debugger: support step-over and step-out commands #2454

ivan-mogilko opened this issue Jun 21, 2024 · 3 comments
Labels
context: debug related to logging, debugging, game diagnostics context: ui/ux what: editor related to the game editor what: engine related to the game engine

Comments

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Jun 21, 2024

Debugger (Editor) currently supports stepping line by line, strictly following script execution; that results in next break occuring inside nested function calls as well. But that's not always convenient in case of complex scripts.

I propose to add 2 more step commands:

  1. Step-over means that it will not step inside called functions, but wait until next line in the current function is reached. (proposed hotkey is F10)
  2. Step-out means that it will wait until current function returns, and breaks at the next line after its call. (proposed hotkey is Shift+F11)

I suppose this may be implemented either:

  • by adding more options to handle by the engine; this seems to be better long term.
  • or by using existing breakpoint mechanism in the editor, where editor would create a temporary hidden breakpoint in certain lines, and remove them when any break happens.
@ivan-mogilko ivan-mogilko added what: editor related to the game editor what: engine related to the game engine context: ui/ux context: debug related to logging, debugging, game diagnostics labels Jun 21, 2024
@ericoporto
Copy link
Member

Supposedly we have

function Bar()
{
  // there is a breakpoint here
}

function Foo()
{
  int a = 2; // debug cursor is here
  Bar();
  int b = 3;
}

A step over would then step over Bar or in this case that we set a breakpoint inside it would stop at that breakpoint (like if we had hit the "continue" like button)?

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Jul 1, 2024

It should break at the next found breakpoint along the execution, whether it's user's breakpoint or one added by another command. Yes, it must be consistent with "continue".

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Jul 2, 2024

In regards to implementation:
breaking is currently handled in this function in the engine:

ags/Engine/debug/debug.cpp

Lines 632 to 633 in de288ad

// allow LShift to single-step, RShift to pause flow
void scriptDebugHook (ccInstance *ccinst, int linenum) {

The variables that control behavior are:
breakpoints - array of breakpoints
break_on_next_script_step - tells to break at next execution step.

I suppose that these may be amended with more instructions. The question is mostly in which conditions to use for making a break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: debug related to logging, debugging, game diagnostics context: ui/ux what: editor related to the game editor what: engine related to the game engine
Projects
None yet
Development

No branches or pull requests

2 participants