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

Improve stepping over opApply #294

Open
TurkeyMan opened this issue Mar 8, 2025 · 2 comments
Open

Improve stepping over opApply #294

TurkeyMan opened this issue Mar 8, 2025 · 2 comments

Comments

@TurkeyMan
Copy link

TurkeyMan commented Mar 8, 2025

There's a little usability issue that's always bugged me, but I never bothered to log an issue. It's like this:

foreach (x; collection) // <- place breakpoint here, press F10 (step-over)
{
  x.doSomething();
}
nextLine(); // <- cursor moves to here, completely skipping over the loop

In cases where collection has an opApply function to implement the foreach behaviour, if the cursor is at the foreach statement, and you press F10, instead of stepping into the first line of the loop inner as usual, since the opApply is essentially just a function call, the debugger steps-over the opApply and goes straight to nextLine().
This gives the false impression that the collection is empty; but actually, the reality is that because opApply was a function call, it just stepped over the entire loop. Since opApply is rare, it's easy to miss/forget this detail, and so I find myself constantly making the improper assumption that the collection was empty, which occasionally leads down a rabbit hole chasing other explanations for a problem...

I have no idea how to fix this; it seems like a hard problem... but I wonder if any creative solutions are possible?
Maybe a breakpoint could silently be placed at the entry to the loop-body lambda when the user presses step-over; but it's hard to imagine how to detect the conditions to enable a hack like that.

I guess there could be a solution that involves aggressive/forceful inlining of the opApply and the lambda?

@rainers
Copy link
Member

rainers commented Mar 8, 2025

Indeed not an easy problem. You can use "Step into specific" to get immediately to the loop body lambda (if you know which of the mangled symbols is the right one), maybe that can be automated somehow. But it doesn't get simpler when returning from the lambda: in normal cases with "Step over", you will probably not want to step through the opApply code but the next iteration inside the lambda or continue after the loop.

Inlining might help in some cases, but might also make it more difficult to detect opApply code that should be skipped when stepping over.

@TurkeyMan
Copy link
Author

Mmmm, it seems like a really hard problem. I wonder if any other languages have a similar situation that pops up often, and have any novel solutions for their cases...

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

2 participants