Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions dap/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/docker/docker v28.5.2+incompatible
github.com/docker/go-units v0.5.0
github.com/gofrs/flock v0.13.0
github.com/google/go-dap v0.12.0
github.com/google/go-dap v0.12.1-0.20250904181021-d7a2259b058b
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.6.0
github.com/hashicorp/go-cty-funcs v0.0.0-20250818135842-6aab67130928
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnL
github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/go-dap v0.12.0 h1:rVcjv3SyMIrpaOoTAdFDyHs99CwVOItIJGKLQFQhNeM=
github.com/google/go-dap v0.12.0/go.mod h1:tNjCASCm5cqePi/RVXXWEVqtnNLV1KTWtYOqu6rZNzc=
github.com/google/go-dap v0.12.1-0.20250904181021-d7a2259b058b h1:m+yLjBIoXaMKk6pwd1IJYYgM76+mwcy7J9+cuY7LqmQ=
github.com/google/go-dap v0.12.1-0.20250904181021-d7a2259b058b/go.mod h1:tNjCASCm5cqePi/RVXXWEVqtnNLV1KTWtYOqu6rZNzc=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 h1:EEHtgt9IwisQ2AZ4pIsMjahcegHh6rmhqxzIRQIyepY=
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6/go.mod h1:I6V7YzU0XDpsHqbsyrghnFZLO1gwK6NPTNvmetQIk9U=
Expand Down
51 changes: 51 additions & 0 deletions tests/dap_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var dapBuildTests = []func(t *testing.T, sb integration.Sandbox){
testDapBuild,
testDapBuildStopOnEntry,
testDapBuildSetBreakpoints,
testDapBuildVerifiedBreakpoints,
testDapBuildStepIn,
testDapBuildStepNext,
testDapBuildStepOut,
Expand Down Expand Up @@ -199,6 +200,56 @@ func testDapBuildSetBreakpoints(t *testing.T, sb integration.Sandbox) {
require.NoError(t, done(false))
}

func testDapBuildVerifiedBreakpoints(t *testing.T, sb integration.Sandbox) {
dir := createTestProject(t)
client, done, err := dapBuildCmd(t, sb, withArgs(dir))
require.NoError(t, err)

interruptCh := pollInterruptEvents(client)

var actual []dap.BreakpointEventBody
client.RegisterEvent("breakpoint", func(em dap.EventMessage) {
e := em.(*dap.BreakpointEvent)
actual = append(actual, e.Body)
})

doLaunch(t, client, commands.LaunchConfig{
Dockerfile: path.Join(dir, "Dockerfile"),
ContextPath: dir,
},
dap.SourceBreakpoint{Line: 2},
dap.SourceBreakpoint{Line: 10},
)

stopped := waitForInterrupt[*dap.StoppedEvent](t, interruptCh)
require.NotNil(t, stopped)

assert.Equal(t, []dap.BreakpointEventBody{
{
Reason: "changed",
Breakpoint: dap.Breakpoint{
Id: 1,
Line: 2,
EndLine: 2,
Verified: true,
},
},
{
Reason: "changed",
Breakpoint: dap.Breakpoint{
Id: 2,
Line: 10,
EndLine: 10,
Verified: false,
Reason: "failed",
},
},
}, actual)

var exitErr *exec.ExitError
require.ErrorAs(t, done(true), &exitErr)
}

func testDapBuildStepIn(t *testing.T, sb integration.Sandbox) {
dir := createTestProject(t)
client, done, err := dapBuildCmd(t, sb, withArgs(dir))
Expand Down
Loading