diff --git a/_fixtures/issue1264.go b/_fixtures/issue1264.go new file mode 100644 index 00000000..8055e631 --- /dev/null +++ b/_fixtures/issue1264.go @@ -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 + } +} diff --git a/pkg/proc/breakpoints.go b/pkg/proc/breakpoints.go index 3b6cd615..0f5a2561 100644 --- a/pkg/proc/breakpoints.go +++ b/pkg/proc/breakpoints.go @@ -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 } diff --git a/pkg/proc/proc_test.go b/pkg/proc/proc_test.go index e1a14474..2fd6c1c7 100644 --- a/pkg/proc/proc_test.go +++ b/pkg/proc/proc_test.go @@ -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") + }) +}