proc: allow breakpoint conditions to contain a single boolean variable
Fixes a bug where breakpoint condition evaluation would never load the value if the breakpoint condition consisted of just a single variable. Fix #1264
This commit is contained in:
parent
2309f728c1
commit
0c15ca5f19
10
_fixtures/issue1264.go
Normal file
10
_fixtures/issue1264.go
Normal file
@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
for i := 0; i < 4; i++ {
|
||||
equalsTwo := i == 2
|
||||
fmt.Printf("i: %d -> equalsTwo: %t \n", i, equalsTwo) // :8
|
||||
}
|
||||
}
|
@ -181,12 +181,13 @@ func evalBreakpointCondition(thread Thread, cond ast.Expr) (bool, error) {
|
||||
if err != nil {
|
||||
return true, fmt.Errorf("error evaluating expression: %v", err)
|
||||
}
|
||||
if v.Unreadable != nil {
|
||||
return true, fmt.Errorf("condition expression unreadable: %v", v.Unreadable)
|
||||
}
|
||||
if v.Kind != reflect.Bool {
|
||||
return true, errors.New("condition expression not boolean")
|
||||
}
|
||||
v.loadValue(loadFullValue)
|
||||
if v.Unreadable != nil {
|
||||
return true, fmt.Errorf("condition expression unreadable: %v", v.Unreadable)
|
||||
}
|
||||
return constant.BoolVal(v.Value), nil
|
||||
}
|
||||
|
||||
|
@ -3862,3 +3862,14 @@ func TestOptimizationCheck(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssue1264(t *testing.T) {
|
||||
// It should be possible to set a breakpoint condition that consists only
|
||||
// of evaluating a single boolean variable.
|
||||
withTestProcess("issue1264", t, func(p proc.Process, fixture protest.Fixture) {
|
||||
bp := setFileBreakpoint(p, t, fixture, 8)
|
||||
bp.Cond = &ast.Ident{Name: "equalsTwo"}
|
||||
assertNoError(proc.Continue(p), t, "Continue()")
|
||||
assertLineNumber(p, t, 8, "after continue")
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user