Skip to content

Add support for breakpoint hit count #298

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

Closed
rkeithhill opened this issue Nov 1, 2016 · 7 comments
Closed

Add support for breakpoint hit count #298

rkeithhill opened this issue Nov 1, 2016 · 7 comments
Assignees
Labels
Issue-Enhancement A feature request (enhancement).
Milestone

Comments

@rkeithhill
Copy link
Contributor

Just saw this in the 1.7 insider's release notes. Sounds like debugger extensions must be modified to support this. I suspect this should be easy to support.

@rkeithhill rkeithhill added the Issue-Enhancement A feature request (enhancement). label Nov 1, 2016
@rkeithhill rkeithhill added this to the 0.8.0 milestone Nov 1, 2016
@rkeithhill rkeithhill self-assigned this Nov 1, 2016
@daviwil
Copy link
Contributor

daviwil commented Nov 3, 2016

Sounds good! That will be a nice addition.

@rkeithhill
Copy link
Contributor Author

Investigated and ran into a snag. Enh request for PowerShell here: PowerShell/PowerShell#2594

Initial work is committed to my fork: rkeithhill@f56a683

Might be able to track the conditional break count ourselves and get this done. Need to think on it some.

@daviwil
Copy link
Contributor

daviwil commented Nov 3, 2016

Even if this improves in PowerShell 6.0+, we'd still have to make it work for older versions. I think we'll have to do it ourselves for now. Maybe we can augment the user's condition code if it helps?

@rkeithhill
Copy link
Contributor Author

True enough. I'll experiment with maintaining the hit count in a global variable. Do we have a naming convention for globals created by the debugger? Maybe something like __psEditorServices_hitCount?

@rkeithhill
Copy link
Contributor Author

rkeithhill commented Nov 4, 2016

OK, this seems to work although it does inject a global into the debug session. I think that should be OK.

if (<user expression>) { if (++$global:__psEditorServices_BreakHitCounter_1 -eq <user hit count>) { break } }

Note that I maintain a static "breakpointHitCounter" that gets incremented each time a breakpoint like this is set. So the next hit count breakpoint would look like this:

if (<user expression>) { if (++$global:__psEditorServices_BreakHitCounter_2 -eq <user hit count>) { break } }

Where the global variable has a different name $global:__psEditorServices_BreakHitCounter_2 than the previous global variable.

Not done with this yet. If there is no "condition" then we won't need to create a global. We can use the breakpoint's HitCount property e.g.:

if ($_.HitCount -eq <user hit count>) {  break  }

I hope to check this in by Saturday.

@daviwil
Copy link
Contributor

daviwil commented Nov 28, 2016

This is done right? Should we close it?

@rkeithhill
Copy link
Contributor Author

Yes, it has been implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

2 participants