Skip to content

Commit ef0a7b3

Browse files
authored
Merge pull request #3581 from jsternberg/dap-breakpoint-reason
dap: fill in breakpoint reason for being unverified
2 parents 59bc181 + 8ad75dc commit ef0a7b3

File tree

6 files changed

+173
-42
lines changed

6 files changed

+173
-42
lines changed

dap/adapter.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ func (b *breakpointMap) Set(fname string, sbps []dap.SourceBreakpoint) (breakpoi
589589
EndLine: sbp.Line,
590590
Column: sbp.Column,
591591
EndColumn: sbp.Column,
592+
Reason: "pending",
592593
}
593594
}
594595
breakpoints = append(breakpoints, bp)
@@ -608,6 +609,27 @@ func (b *breakpointMap) Intersect(ctx Context, src *pb.Source, ws string) map[di
608609
digests[digest.Digest(dgst)] = id
609610
}
610611
}
612+
613+
// Mark unverified breakpoints as failed at this point since we couldn't find an area
614+
// in the source where they applied.
615+
for _, info := range src.Infos {
616+
fname := filepath.Join(ws, info.Filename)
617+
618+
bps := b.byPath[fname]
619+
for _, bp := range bps {
620+
if !bp.Verified && bp.Reason != "failed" {
621+
bp.Reason = "failed"
622+
623+
ctx.C() <- &dap.BreakpointEvent{
624+
Event: dap.Event{Event: "breakpoint"},
625+
Body: dap.BreakpointEventBody{
626+
Reason: "changed",
627+
Breakpoint: bp,
628+
},
629+
}
630+
}
631+
}
632+
}
611633
return digests
612634
}
613635

@@ -651,6 +673,7 @@ func (b *breakpointMap) intersect(ctx Context, src *pb.Source, locs *pb.Location
651673
bp.Column = int(r.Start.Character)
652674
bp.EndColumn = int(r.End.Character)
653675
bp.Verified = true
676+
bp.Reason = ""
654677

655678
ctx.C() <- &dap.BreakpointEvent{
656679
Event: dap.Event{Event: "breakpoint"},

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
github.com/docker/docker v28.5.2+incompatible
2222
github.com/docker/go-units v0.5.0
2323
github.com/gofrs/flock v0.13.0
24-
github.com/google/go-dap v0.12.0
24+
github.com/google/go-dap v0.12.1-0.20250904181021-d7a2259b058b
2525
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
2626
github.com/google/uuid v1.6.0
2727
github.com/hashicorp/go-cty-funcs v0.0.0-20250818135842-6aab67130928

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnL
155155
github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
156156
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
157157
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
158-
github.com/google/go-dap v0.12.0 h1:rVcjv3SyMIrpaOoTAdFDyHs99CwVOItIJGKLQFQhNeM=
159-
github.com/google/go-dap v0.12.0/go.mod h1:tNjCASCm5cqePi/RVXXWEVqtnNLV1KTWtYOqu6rZNzc=
158+
github.com/google/go-dap v0.12.1-0.20250904181021-d7a2259b058b h1:m+yLjBIoXaMKk6pwd1IJYYgM76+mwcy7J9+cuY7LqmQ=
159+
github.com/google/go-dap v0.12.1-0.20250904181021-d7a2259b058b/go.mod h1:tNjCASCm5cqePi/RVXXWEVqtnNLV1KTWtYOqu6rZNzc=
160160
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
161161
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 h1:EEHtgt9IwisQ2AZ4pIsMjahcegHh6rmhqxzIRQIyepY=
162162
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6/go.mod h1:I6V7YzU0XDpsHqbsyrghnFZLO1gwK6NPTNvmetQIk9U=

tests/dap_build.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ var dapBuildTests = []func(t *testing.T, sb integration.Sandbox){
7777
testDapBuild,
7878
testDapBuildStopOnEntry,
7979
testDapBuildSetBreakpoints,
80+
testDapBuildVerifiedBreakpoints,
8081
testDapBuildStepIn,
8182
testDapBuildStepNext,
8283
testDapBuildStepOut,
@@ -199,6 +200,56 @@ func testDapBuildSetBreakpoints(t *testing.T, sb integration.Sandbox) {
199200
require.NoError(t, done(false))
200201
}
201202

203+
func testDapBuildVerifiedBreakpoints(t *testing.T, sb integration.Sandbox) {
204+
dir := createTestProject(t)
205+
client, done, err := dapBuildCmd(t, sb, withArgs(dir))
206+
require.NoError(t, err)
207+
208+
interruptCh := pollInterruptEvents(client)
209+
210+
var actual []dap.BreakpointEventBody
211+
client.RegisterEvent("breakpoint", func(em dap.EventMessage) {
212+
e := em.(*dap.BreakpointEvent)
213+
actual = append(actual, e.Body)
214+
})
215+
216+
doLaunch(t, client, commands.LaunchConfig{
217+
Dockerfile: path.Join(dir, "Dockerfile"),
218+
ContextPath: dir,
219+
},
220+
dap.SourceBreakpoint{Line: 2},
221+
dap.SourceBreakpoint{Line: 10},
222+
)
223+
224+
stopped := waitForInterrupt[*dap.StoppedEvent](t, interruptCh)
225+
require.NotNil(t, stopped)
226+
227+
assert.Equal(t, []dap.BreakpointEventBody{
228+
{
229+
Reason: "changed",
230+
Breakpoint: dap.Breakpoint{
231+
Id: 1,
232+
Line: 2,
233+
EndLine: 2,
234+
Verified: true,
235+
},
236+
},
237+
{
238+
Reason: "changed",
239+
Breakpoint: dap.Breakpoint{
240+
Id: 2,
241+
Line: 10,
242+
EndLine: 10,
243+
Verified: false,
244+
Reason: "failed",
245+
},
246+
},
247+
}, actual)
248+
249+
var exitErr *exec.ExitError
250+
require.ErrorAs(t, done(true), &exitErr)
251+
}
252+
202253
func testDapBuildStepIn(t *testing.T, sb integration.Sandbox) {
203254
dir := createTestProject(t)
204255
client, done, err := dapBuildCmd(t, sb, withArgs(dir))

0 commit comments

Comments
 (0)