mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 04:35:19 +08:00
pkg/terminal: clear erroneous name setting on postfix if (#3702)
When a breakpoint was set on the current line via `break if i ==3` style condition setting, we would erroneously set the breakpoint name to be 'if'.
This commit is contained in:
@ -1858,6 +1858,7 @@ func setBreakpoint(t *Term, ctx callContext, tracepoint bool, argstr string) ([]
|
|||||||
if findLocErr != nil {
|
if findLocErr != nil {
|
||||||
r := regexp.MustCompile(`^if | if `)
|
r := regexp.MustCompile(`^if | if `)
|
||||||
if match := r.FindStringIndex(argstr); match != nil {
|
if match := r.FindStringIndex(argstr); match != nil {
|
||||||
|
requestedBp.Name = ""
|
||||||
cond = argstr[match[1]:]
|
cond = argstr[match[1]:]
|
||||||
argstr = argstr[:match[0]]
|
argstr = argstr[:match[0]]
|
||||||
args = config.Split2PartsBySpace(argstr)
|
args = config.Split2PartsBySpace(argstr)
|
||||||
|
|||||||
@ -1438,8 +1438,12 @@ func TestCreateBreakpointByLocExpr(t *testing.T) {
|
|||||||
func TestCreateBreakpointWithCondition(t *testing.T) {
|
func TestCreateBreakpointWithCondition(t *testing.T) {
|
||||||
withTestTerminal("break", t, func(term *FakeTerminal) {
|
withTestTerminal("break", t, func(term *FakeTerminal) {
|
||||||
term.MustExec("break bp1 main.main:4 if i == 3")
|
term.MustExec("break bp1 main.main:4 if i == 3")
|
||||||
|
out := term.MustExec("breakpoints")
|
||||||
|
if !strings.Contains(out, "Breakpoint bp1") {
|
||||||
|
t.Fatal("incorrect breakpoint name")
|
||||||
|
}
|
||||||
listIsAt(t, term, "continue", 7, -1, -1)
|
listIsAt(t, term, "continue", 7, -1, -1)
|
||||||
out := term.MustExec("print i")
|
out = term.MustExec("print i")
|
||||||
t.Logf("%q", out)
|
t.Logf("%q", out)
|
||||||
if !strings.Contains(out, "3\n") {
|
if !strings.Contains(out, "3\n") {
|
||||||
t.Fatalf("wrong value of i")
|
t.Fatalf("wrong value of i")
|
||||||
@ -1451,8 +1455,12 @@ func TestCreateBreakpointWithCondition2(t *testing.T) {
|
|||||||
withTestTerminal("break", t, func(term *FakeTerminal) {
|
withTestTerminal("break", t, func(term *FakeTerminal) {
|
||||||
term.MustExec("continue main.main:4")
|
term.MustExec("continue main.main:4")
|
||||||
term.MustExec("break if i == 3")
|
term.MustExec("break if i == 3")
|
||||||
|
out := term.MustExec("breakpoints")
|
||||||
|
if strings.Contains(out, "Breakpoint if") {
|
||||||
|
t.Fatal("incorrect breakpoint name, should be ID")
|
||||||
|
}
|
||||||
listIsAt(t, term, "continue", 7, -1, -1)
|
listIsAt(t, term, "continue", 7, -1, -1)
|
||||||
out := term.MustExec("print i")
|
out = term.MustExec("print i")
|
||||||
t.Logf("%q", out)
|
t.Logf("%q", out)
|
||||||
if !strings.Contains(out, "3\n") {
|
if !strings.Contains(out, "3\n") {
|
||||||
t.Fatalf("wrong value of i")
|
t.Fatalf("wrong value of i")
|
||||||
|
|||||||
Reference in New Issue
Block a user