proc: fix automatic breakpoints visibility (#3300)

Unrecovered-panic and fatal-throw were no longer part of the breakpoint
list because starting in 37e44bf they were created before the logical
breakpoints map was switched to the logical breakpoints map of the
target group.
This commit is contained in:
Alessandro Arzilli 2023-03-14 22:23:25 +01:00 committed by GitHub
parent 7a05a4326f
commit a9d699b581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

@ -193,6 +193,7 @@ func (grp *TargetGroup) newTarget(p ProcessInternal, pid int, currentThread Thre
g, _ := GetG(currentThread)
t.selectedGoroutine = g
t.Breakpoints().Logical = grp.LogicalBreakpoints
t.createUnrecoveredPanicBreakpoint()
t.createFatalThrowBreakpoint()
t.createPluginOpenBreakpoint()

@ -108,7 +108,6 @@ func (grp *TargetGroup) addTarget(p ProcessInternal, pid int, currentThread Thre
if grp.Selected == nil {
grp.Selected = t
}
t.Breakpoints().Logical = grp.LogicalBreakpoints
logger := logflags.DebuggerLogger()
for _, lbp := range grp.LogicalBreakpoints {
if lbp.LogicalID < 0 {

@ -23,6 +23,7 @@ import (
"github.com/go-delve/delve/pkg/goversion"
"github.com/go-delve/delve/pkg/logflags"
"github.com/go-delve/delve/pkg/proc"
"github.com/go-delve/delve/service"
"github.com/go-delve/delve/service/api"
"github.com/go-delve/delve/service/rpc2"
@ -2970,3 +2971,23 @@ func TestClientServer_createBreakpointWithID(t *testing.T) {
}
})
}
func TestClientServer_autoBreakpoints(t *testing.T) {
// Check that unrecoverd-panic and fatal-throw breakpoints are visible in
// the breakpoint list.
protest.AllowRecording(t)
withTestClient2("math", t, func(c service.Client) {
bps, err := c.ListBreakpoints(false)
assertNoError(err, t, "ListBreakpoints")
n := 0
for _, bp := range bps {
t.Log(bp)
if bp.Name == proc.UnrecoveredPanic || bp.Name == proc.FatalThrow {
n++
}
}
if n != 2 {
t.Error("automatic breakpoints not found")
}
})
}