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

Enable breakpoints on branching expressions (conditional and short-circuiting) #43092

Open
jnm2 opened this issue Apr 5, 2020 · 6 comments
Open

Comments

@jnm2
Copy link
Contributor

jnm2 commented Apr 5, 2020

This would be in the same vein as #22016 which added breakpoints for the arms of a switch expression. Filed as asked by @gafter.

Please add sequence points to enable setting breakpoints on:

  • Either branch of a conditional expression
  • The right operand of &&, ||, and ??
  • The remainder of the expression after ?. and ?[

When you're in the middle of debugging, it's too late to refactor expressions to statements. Sometimes you can set a breakpoint on the whole statement and duplicate the effective condition using the breakpoint condition feature, but this expression may be nested inside other expressions. It's frustrating to put together even when you can duplicate the condition without side effects.

A benefit of more granular expression sequence points is that code coverage tools will begin to recognize conditional expressions and short-circuiting operators as branches. All the code coverage tools that I've looked into or heard from are dependent on debugger sequence points. I'm hoping for a world where things like && and ?. are tracked as branching by Live Unit Testing and third-party tools.

@steevcoco
Copy link

This is an absolutely excellent suggestion; that at minimum holds up the future outlook! 🤓 Granular progress on branches!

Very nice sir!
Be safe!

@gafter
Copy link
Member

gafter commented Apr 6, 2020

The potential downside of doing this is that single-stepping may have many more intermediate steps. I'm proposing to implement this as an experimental compiler feature (enabled with a feature flag) to gather some experience with it.

@steevcoco
Copy link

steevcoco commented Apr 6, 2020

The potential downside of doing this is that single-stepping may have many more intermediate steps. I'm proposing to implement this as an experimental compiler feature (enabled with a feature flag) to gather some experience with it.

Isn't experience better gathered by making the feature as available as possible? The agile world is long into the framework.

I felt that the configuration would be a type of hassle; and limit the casual usage arbitrarily too.

@gafter
Copy link
Member

gafter commented Apr 7, 2020

I don't think it would be a good idea to subject all of our customers to a possibly failing experiment. We'd prefer to keep our customers productive.

@gafter gafter removed this from the Compiler.Net5 milestone May 1, 2020
@gafter gafter added this to the Backlog milestone May 14, 2020
@gafter gafter removed their assignment Jun 26, 2020
@k15tfu
Copy link

k15tfu commented Nov 6, 2020

Linked issue: #21781 , also suggests using a new compiler flag for this and leave the default behavior as is.

@mnsc
Copy link

mnsc commented Aug 23, 2021

The potential downside of doing this is that single-stepping may have many more intermediate steps. I'm proposing to implement this as an experimental compiler feature (enabled with a feature flag) to gather some experience with it.

This is coming from a developer without any compiler/IL knowledge so this might very well be "rewrite everthing" land. But I looked at formal proposal in the linked issue (#21781) and instead of having a compiler switch to add more or less "sequence points", couldn't different types of sequence point be added at those levels? That would let the developer choose at debug time what kind of granularity they want to step by. For instance F10 would be stepping by the old kind of sequence points "coarse" and Ctrl+F10 would step by the new granularity "Fine" which will let the developer step into ternarys/lambdas/conditions/propinitalizers/whatnot. Combine that with a hotkey toggle that let you switch around the behaviour of F10 / Ctrl+F10 and I for one would be a happy camper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants