-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proc: expose breakpoint hitcounts in expressions
Expose breakpoint hitcounts in the expression language through the special variable runtime.bphitcount: runtime.bphitcount[1] runtime.bphitcount["bpname"] will evaluate respectively to the hitcount of breakpoint with id == 1 and to the hitcount of the breakpoint named "bpname". This is intended to be used in breakpoint conditions and allows breakpoints to be chained such that one breakpoint is only hit after a different is hit first. A few optimizations are implemented so that chained breakpoints are evaluated efficiently.
- Loading branch information
Showing
15 changed files
with
459 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Breakpoint conditions | ||
|
||
Breakpoints have two conditions: | ||
|
||
* The normal condition, which is specified using the command `cond <breakpoint> <expr>` (or by setting the Cond field when amending a breakpoint via the API), is any [expression](expr.md) which evaluates to true or false. | ||
* The hitcount condition, which is specified `cond <breakpoint> -hitcount <operator> <number>` (or by setting the HitCond field when amending a breakpoint via the API), is a constraint on the number of times the breakpoint has been hit. | ||
|
||
When a breakpoint location is encountered during the execution of the program, the debugger will: | ||
|
||
* Evaluate the normal condition | ||
* Stop if there is an error while evaluating the normal condition | ||
* If the normal condition evaluates to true the hit count is incremented | ||
* Evaluate the hitcount condition | ||
* If the hitcount condition is also satisfied stop the execution at the breakpoint | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func breakfunc1() { | ||
fmt.Println("breakfunc1") | ||
} | ||
|
||
func breakfunc2() { | ||
fmt.Println("breakfunc2") | ||
} | ||
|
||
func breakfunc3() { | ||
fmt.Println("breakfunc3") | ||
} | ||
|
||
func main() { | ||
breakfunc2() | ||
breakfunc3() | ||
|
||
breakfunc1() // hit | ||
breakfunc3() | ||
breakfunc1() | ||
|
||
breakfunc2() // hit | ||
breakfunc1() | ||
|
||
breakfunc3() // hit | ||
breakfunc1() | ||
breakfunc2() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def command_chain(args): | ||
v = args.split(" ") | ||
|
||
bp = get_breakpoint(int(v[0]), "").Breakpoint | ||
bp.HitCond = "== 1" | ||
amend_breakpoint(bp) | ||
|
||
for i in range(1, len(v)): | ||
bp = get_breakpoint(int(v[i]), "").Breakpoint | ||
if i != len(v)-1: | ||
bp.HitCond = "== 1" | ||
bp.Cond = "runtime.bphitcount[" + v[i-1] + "] > 0" | ||
amend_breakpoint(bp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.