Skip to content

Commit

Permalink
service/debugger: allow setting a breakpoint with a specific ID (go-d…
Browse files Browse the repository at this point in the history
…elve#3185)

Before 4c5b111 it was possible for a client to create a breakpoint
with a specific logical ID, restore this ability for backwards
compatibility.
  • Loading branch information
aarzilli authored Nov 8, 2022
1 parent 350dd6a commit 2c10bb3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions service/debugger/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,14 +772,16 @@ func (d *Debugger) ConvertThreadBreakpoint(thread proc.Thread) *api.Breakpoint {
func createLogicalBreakpoint(d *Debugger, requestedBp *api.Breakpoint, setbp *proc.SetBreakpoint, suspended bool) (*api.Breakpoint, error) {
id := requestedBp.ID

var lbp *proc.LogicalBreakpoint
if id <= 0 {
d.breakpointIDCounter++
id = d.breakpointIDCounter
lbp = &proc.LogicalBreakpoint{LogicalID: id, HitCount: make(map[int64]uint64), Enabled: true}
d.target.LogicalBreakpoints[id] = lbp
} else {
d.breakpointIDCounter = id
}

lbp := &proc.LogicalBreakpoint{LogicalID: id, HitCount: make(map[int64]uint64), Enabled: true}
d.target.LogicalBreakpoints[id] = lbp

err := copyLogicalBreakpointInfo(lbp, requestedBp)
if err != nil {
return nil, err
Expand Down
17 changes: 17 additions & 0 deletions service/test/integration2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2961,3 +2961,20 @@ func TestPluginSuspendedBreakpoint(t *testing.T) {
cont("Continue 4", "plugin2.go", 9)
})
}

func TestClientServer_createBreakpointWithID(t *testing.T) {
protest.AllowRecording(t)
withTestClient2("continuetestprog", t, func(c service.Client) {
bp, err := c.CreateBreakpoint(&api.Breakpoint{ID: 2, FunctionName: "main.main", Line: 1})
assertNoError(err, t, "CreateBreakpoint()")
if bp.ID != 2 {
t.Errorf("wrong ID for breakpoint %d", bp.ID)
}

bp2, err := c.CreateBreakpoint(&api.Breakpoint{FunctionName: "main.main", Line: 2})
assertNoError(err, t, "CreateBreakpoint()")
if bp2.ID != 3 {
t.Errorf("wrong ID for breakpoint %d", bp2.ID)
}
})
}

0 comments on commit 2c10bb3

Please sign in to comment.