mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 04:35:19 +08:00
terminal,service: better printing of suspended breakpoints (#3415)
Show the location expression that will be used to set a suspended breakpoint in the breakpoints list. Also change 'target' called without arguments to print a better error message and 'target follow-exec' without the last argument to print the state of follow-exec.
This commit is contained in:
committed by
GitHub
parent
c1482ca911
commit
db0bc26949
@ -1018,6 +1018,7 @@ type SetBreakpoint struct {
|
||||
File string
|
||||
Line int
|
||||
Expr func(*Target) []uint64
|
||||
ExprString string
|
||||
PidAddrs []PidAddr
|
||||
}
|
||||
|
||||
|
||||
@ -1702,8 +1702,15 @@ func breakpoints(t *Term, ctx callContext, args string) error {
|
||||
enabled := "(enabled)"
|
||||
if bp.Disabled {
|
||||
enabled = "(disabled)"
|
||||
} else if bp.ExprString != "" {
|
||||
enabled = "(suspended)"
|
||||
}
|
||||
fmt.Fprintf(t.stdout, "%s %s", formatBreakpointName(bp, true), enabled)
|
||||
if bp.ExprString != "" {
|
||||
fmt.Fprintf(t.stdout, " at %s\n", bp.ExprString)
|
||||
} else {
|
||||
fmt.Fprintf(t.stdout, " at %v (%d)\n", t.formatBreakpointLocation(bp), bp.TotalHitCount)
|
||||
}
|
||||
fmt.Fprintf(t.stdout, "%s %s at %v (%d)\n", formatBreakpointName(bp, true), enabled, t.formatBreakpointLocation(bp), bp.TotalHitCount)
|
||||
|
||||
attrs := formatBreakpointAttrs("\t", bp, false)
|
||||
|
||||
@ -3277,7 +3284,12 @@ func target(t *Term, ctx callContext, args string) error {
|
||||
return nil
|
||||
case "follow-exec":
|
||||
if len(argv) == 1 {
|
||||
return errors.New("not enough arguments")
|
||||
if t.client.FollowExecEnabled() {
|
||||
fmt.Fprintf(t.stdout, "Follow exec is enabled.\n")
|
||||
} else {
|
||||
fmt.Fprintf(t.stdout, "Follow exec is disabled.\n")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
argv = config.Split2PartsBySpace(argv[1])
|
||||
switch argv[0] {
|
||||
@ -3316,6 +3328,8 @@ func target(t *Term, ctx callContext, args string) error {
|
||||
return fmt.Errorf("could not find target %d", pid)
|
||||
}
|
||||
return nil
|
||||
case "":
|
||||
return errors.New("not enough arguments for 'target'")
|
||||
default:
|
||||
return fmt.Errorf("unknown command 'target %s'", argv[0])
|
||||
}
|
||||
|
||||
@ -54,8 +54,11 @@ func ConvertLogicalBreakpoint(lbp *proc.LogicalBreakpoint) *Breakpoint {
|
||||
}
|
||||
|
||||
// ConvertPhysicalBreakpoints adds informations from physical breakpoints to an API breakpoint.
|
||||
func ConvertPhysicalBreakpoints(b *Breakpoint, pids []int, bps []*proc.Breakpoint) {
|
||||
func ConvertPhysicalBreakpoints(b *Breakpoint, lbp *proc.LogicalBreakpoint, pids []int, bps []*proc.Breakpoint) {
|
||||
if len(bps) == 0 {
|
||||
if lbp != nil {
|
||||
b.ExprString = lbp.Set.ExprString
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -92,6 +92,8 @@ type Breakpoint struct {
|
||||
// FunctionName is the name of the function at the current breakpoint, and
|
||||
// may not always be available.
|
||||
FunctionName string `json:"functionName,omitempty"`
|
||||
// ExprString is the string that will be used to set a suspended breakpoint.
|
||||
ExprString string
|
||||
|
||||
// Breakpoint condition
|
||||
Cond string
|
||||
|
||||
@ -1961,7 +1961,7 @@ func (s *Session) stoppedOnBreakpointGoroutineID(state *api.DebuggerState) (int6
|
||||
return goid, nil
|
||||
}
|
||||
abp := api.ConvertLogicalBreakpoint(bp.Breakpoint.Logical)
|
||||
api.ConvertPhysicalBreakpoints(abp, []int{0}, []*proc.Breakpoint{bp.Breakpoint})
|
||||
api.ConvertPhysicalBreakpoints(abp, bp.Breakpoint.Logical, []int{0}, []*proc.Breakpoint{bp.Breakpoint})
|
||||
return goid, abp
|
||||
}
|
||||
|
||||
|
||||
@ -617,7 +617,7 @@ func (d *Debugger) state(retLoadCfg *proc.LoadConfig, withBreakpointInfo bool) (
|
||||
for t.Next() {
|
||||
for _, bp := range t.Breakpoints().WatchOutOfScope {
|
||||
abp := api.ConvertLogicalBreakpoint(bp.Logical)
|
||||
api.ConvertPhysicalBreakpoints(abp, []int{t.Pid()}, []*proc.Breakpoint{bp})
|
||||
api.ConvertPhysicalBreakpoints(abp, bp.Logical, []int{t.Pid()}, []*proc.Breakpoint{bp})
|
||||
state.WatchOutOfScope = append(state.WatchOutOfScope, abp)
|
||||
}
|
||||
}
|
||||
@ -744,6 +744,7 @@ func (d *Debugger) CreateBreakpoint(requestedBp *api.Breakpoint, locExpr string,
|
||||
}
|
||||
return locs[0].PCs
|
||||
}
|
||||
setbp.ExprString = locExpr
|
||||
}
|
||||
|
||||
id := requestedBp.ID
|
||||
@ -805,7 +806,7 @@ func (d *Debugger) convertBreakpoint(lbp *proc.LogicalBreakpoint) *api.Breakpoin
|
||||
}
|
||||
}
|
||||
}
|
||||
api.ConvertPhysicalBreakpoints(abp, pids, bps)
|
||||
api.ConvertPhysicalBreakpoints(abp, lbp, pids, bps)
|
||||
return abp
|
||||
}
|
||||
|
||||
@ -1039,7 +1040,7 @@ func (d *Debugger) Breakpoints(all bool) []*api.Breakpoint {
|
||||
} else {
|
||||
abp = &api.Breakpoint{}
|
||||
}
|
||||
api.ConvertPhysicalBreakpoints(abp, []int{t.Pid()}, []*proc.Breakpoint{bp})
|
||||
api.ConvertPhysicalBreakpoints(abp, bp.Logical, []int{t.Pid()}, []*proc.Breakpoint{bp})
|
||||
abp.VerboseDescr = bp.VerboseDescr()
|
||||
abps = append(abps, abp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user