mirror of
https://github.com/go-delve/delve.git
synced 2025-11-02 12:59:01 +08:00
Add command to print active breakpoints
This commit is contained in:
@ -50,6 +50,7 @@ func DebugCommands() *Commands {
|
||||
command{aliases: []string{"threads"}, cmdFn: threads, helpMsg: "Print out info for every traced thread."},
|
||||
command{aliases: []string{"clear"}, cmdFn: clear, helpMsg: "Deletes breakpoint."},
|
||||
command{aliases: []string{"goroutines"}, cmdFn: goroutines, helpMsg: "Print out info for every goroutine."},
|
||||
command{aliases: []string{"breakpoints", "bp"}, cmdFn: breakpoints, helpMsg: "Print out info for active breakpoints."},
|
||||
command{aliases: []string{"print", "p"}, cmdFn: printVar, helpMsg: "Evaluate a variable."},
|
||||
command{aliases: []string{"info"}, cmdFn: info, helpMsg: "Provides info about args, funcs, locals, sources, or vars."},
|
||||
command{aliases: []string{"exit"}, cmdFn: nullCommand, helpMsg: "Exit the debugger."},
|
||||
@ -165,6 +166,37 @@ func clear(p *proctl.DebuggedProcess, args ...string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type ById []*proctl.BreakPoint
|
||||
|
||||
func (a ById) Len() int { return len(a) }
|
||||
func (a ById) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ById) Less(i, j int) bool { return a[i].ID < a[j].ID }
|
||||
|
||||
func breakpoints(p *proctl.DebuggedProcess, args ...string) error {
|
||||
bps := make([]*proctl.BreakPoint, 0, len(p.BreakPoints)+4)
|
||||
|
||||
for _, bp := range p.HWBreakPoints {
|
||||
if bp == nil {
|
||||
continue
|
||||
}
|
||||
bps = append(bps, bp)
|
||||
}
|
||||
|
||||
for _, bp := range p.BreakPoints {
|
||||
if bp.Temp {
|
||||
continue
|
||||
}
|
||||
bps = append(bps, bp)
|
||||
}
|
||||
|
||||
sort.Sort(ById(bps))
|
||||
for _, bp := range bps {
|
||||
fmt.Println(bp)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func breakpoint(p *proctl.DebuggedProcess, args ...string) error {
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("not enough arguments")
|
||||
|
||||
Reference in New Issue
Block a user