dap: fill in breakpoint reason for being unverified

When a breakpoint fails to be verified, it will switch the reason to
"failed". It starts off the reason as "pending".

The `reason` field for a breakpoint was added some time after the last
release of `go-dap` which has only been updated once in the last year so
this uses the `main` branch version which contains the field.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
Jonathan A. Sternberg
2026-01-08 15:21:54 -06:00
parent 8037f199db
commit 8ad75dc485
6 changed files with 173 additions and 42 deletions
+23
View File
@@ -589,6 +589,7 @@ func (b *breakpointMap) Set(fname string, sbps []dap.SourceBreakpoint) (breakpoi
EndLine: sbp.Line,
Column: sbp.Column,
EndColumn: sbp.Column,
Reason: "pending",
}
}
breakpoints = append(breakpoints, bp)
@@ -608,6 +609,27 @@ func (b *breakpointMap) Intersect(ctx Context, src *pb.Source, ws string) map[di
digests[digest.Digest(dgst)] = id
}
}
// Mark unverified breakpoints as failed at this point since we couldn't find an area
// in the source where they applied.
for _, info := range src.Infos {
fname := filepath.Join(ws, info.Filename)
bps := b.byPath[fname]
for _, bp := range bps {
if !bp.Verified && bp.Reason != "failed" {
bp.Reason = "failed"
ctx.C() <- &dap.BreakpointEvent{
Event: dap.Event{Event: "breakpoint"},
Body: dap.BreakpointEventBody{
Reason: "changed",
Breakpoint: bp,
},
}
}
}
}
return digests
}
@@ -651,6 +673,7 @@ func (b *breakpointMap) intersect(ctx Context, src *pb.Source, locs *pb.Location
bp.Column = int(r.Start.Character)
bp.EndColumn = int(r.End.Character)
bp.Verified = true
bp.Reason = ""
ctx.C() <- &dap.BreakpointEvent{
Event: dap.Event{Event: "breakpoint"},