mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 09:46:56 +08:00
proc: Update help for new goroutines flags & minor cleanup
This commit is contained in:
@ -487,7 +487,7 @@ func (dbp *Process) GoroutinesInfo() ([]*G, error) {
|
|||||||
}
|
}
|
||||||
g.thread = thread
|
g.thread = thread
|
||||||
// Prefer actual thread location information.
|
// Prefer actual thread location information.
|
||||||
g.Current = *loc
|
g.CurrentLoc = *loc
|
||||||
}
|
}
|
||||||
if g.Status != Gdead {
|
if g.Status != Gdead {
|
||||||
allg = append(allg, g)
|
allg = append(allg, g)
|
||||||
|
|||||||
@ -73,7 +73,7 @@ type G struct {
|
|||||||
Status uint64
|
Status uint64
|
||||||
|
|
||||||
// Information on goroutine location
|
// Information on goroutine location
|
||||||
Current Location
|
CurrentLoc Location
|
||||||
|
|
||||||
// PC of entry to top-most deferred function.
|
// PC of entry to top-most deferred function.
|
||||||
DeferPC uint64
|
DeferPC uint64
|
||||||
@ -291,7 +291,7 @@ func parseG(thread *Thread, gaddr uint64, deref bool) (*G, error) {
|
|||||||
GoPC: gopc,
|
GoPC: gopc,
|
||||||
PC: pc,
|
PC: pc,
|
||||||
SP: sp,
|
SP: sp,
|
||||||
Current: Location{PC: pc, File: f, Line: l, Fn: fn},
|
CurrentLoc: Location{PC: pc, File: f, Line: l, Fn: fn},
|
||||||
WaitReason: waitreason,
|
WaitReason: waitreason,
|
||||||
DeferPC: deferPC,
|
DeferPC: deferPC,
|
||||||
Status: atomicStatus,
|
Status: atomicStatus,
|
||||||
@ -313,7 +313,7 @@ func (g *G) UserCurrent() Location {
|
|||||||
if g.thread != nil {
|
if g.thread != nil {
|
||||||
regs, err := g.thread.Registers()
|
regs, err := g.thread.Registers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return g.Current
|
return g.CurrentLoc
|
||||||
}
|
}
|
||||||
pc, sp = regs.PC(), regs.SP()
|
pc, sp = regs.PC(), regs.SP()
|
||||||
}
|
}
|
||||||
@ -325,7 +325,7 @@ func (g *G) UserCurrent() Location {
|
|||||||
return frame.Call
|
return frame.Call
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return g.Current
|
return g.CurrentLoc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *G) Go() Location {
|
func (g *G) Go() Location {
|
||||||
|
|||||||
@ -81,10 +81,10 @@ func ConvertFunction(fn *gosym.Func) *Function {
|
|||||||
// convertGoroutine converts an internal Goroutine to an API Goroutine.
|
// convertGoroutine converts an internal Goroutine to an API Goroutine.
|
||||||
func ConvertGoroutine(g *proc.G) *Goroutine {
|
func ConvertGoroutine(g *proc.G) *Goroutine {
|
||||||
return &Goroutine{
|
return &Goroutine{
|
||||||
ID: g.Id,
|
ID: g.Id,
|
||||||
Current: ConvertLocation(g.Current),
|
CurrentLoc: ConvertLocation(g.CurrentLoc),
|
||||||
UserCurrent: ConvertLocation(g.UserCurrent()),
|
UserCurrentLoc: ConvertLocation(g.UserCurrent()),
|
||||||
Go: ConvertLocation(g.Go()),
|
GoStatementLoc: ConvertLocation(g.Go()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -115,11 +115,11 @@ type Goroutine struct {
|
|||||||
// ID is a unique identifier for the goroutine.
|
// ID is a unique identifier for the goroutine.
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
// Current location of the goroutine
|
// Current location of the goroutine
|
||||||
Current Location
|
CurrentLoc Location `json:"currentLoc"`
|
||||||
// Current location of the goroutine, excluding calls inside runtime
|
// Current location of the goroutine, excluding calls inside runtime
|
||||||
UserCurrent Location
|
UserCurrentLoc Location `json:"userCurrentLoc"`
|
||||||
// Location of the go instruction that started this goroutine
|
// Location of the go instruction that started this goroutine
|
||||||
Go Location
|
GoStatementLoc Location `json:"goStatementLoc"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DebuggerCommand is a command which changes the debugger's execution state.
|
// DebuggerCommand is a command which changes the debugger's execution state.
|
||||||
|
|||||||
@ -63,7 +63,7 @@ func DebugCommands(client service.Client) *Commands {
|
|||||||
{aliases: []string{"thread", "tr"}, cmdFn: thread, helpMsg: "Switch to the specified thread."},
|
{aliases: []string{"thread", "tr"}, cmdFn: thread, helpMsg: "Switch to the specified thread."},
|
||||||
{aliases: []string{"clear"}, cmdFn: clear, helpMsg: "Deletes breakpoint."},
|
{aliases: []string{"clear"}, cmdFn: clear, helpMsg: "Deletes breakpoint."},
|
||||||
{aliases: []string{"clearall"}, cmdFn: clearAll, helpMsg: "clearall [<linespec>]. Deletes all breakpoints. If <linespec> is provided, only matching breakpoints will be deleted."},
|
{aliases: []string{"clearall"}, cmdFn: clearAll, helpMsg: "clearall [<linespec>]. Deletes all breakpoints. If <linespec> is provided, only matching breakpoints will be deleted."},
|
||||||
{aliases: []string{"goroutines"}, cmdFn: goroutines, helpMsg: "Print out info for every goroutine."},
|
{aliases: []string{"goroutines"}, cmdFn: goroutines, helpMsg: "goroutines [-u (default: user location)|-r (runtime location)|-g (go statement location)] Print out info for every goroutine."},
|
||||||
{aliases: []string{"goroutine"}, cmdFn: goroutine, helpMsg: "Sets current goroutine."},
|
{aliases: []string{"goroutine"}, cmdFn: goroutine, helpMsg: "Sets current goroutine."},
|
||||||
{aliases: []string{"breakpoints", "bp"}, cmdFn: breakpoints, helpMsg: "Print out info for active breakpoints."},
|
{aliases: []string{"breakpoints", "bp"}, cmdFn: breakpoints, helpMsg: "Print out info for active breakpoints."},
|
||||||
{aliases: []string{"print", "p"}, cmdFn: g0f0(printVar), helpMsg: "Evaluate a variable."},
|
{aliases: []string{"print", "p"}, cmdFn: g0f0(printVar), helpMsg: "Evaluate a variable."},
|
||||||
@ -414,13 +414,13 @@ func formatGoroutine(g *api.Goroutine, fgl formatGoroutineLoc) string {
|
|||||||
switch fgl {
|
switch fgl {
|
||||||
case fglRuntimeCurrent:
|
case fglRuntimeCurrent:
|
||||||
locname = "Runtime"
|
locname = "Runtime"
|
||||||
loc = g.Current
|
loc = g.CurrentLoc
|
||||||
case fglUserCurrent:
|
case fglUserCurrent:
|
||||||
locname = "User"
|
locname = "User"
|
||||||
loc = g.UserCurrent
|
loc = g.UserCurrentLoc
|
||||||
case fglGo:
|
case fglGo:
|
||||||
locname = "Go"
|
locname = "Go"
|
||||||
loc = g.Go
|
loc = g.GoStatementLoc
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%d - %s: %s", g.ID, locname, formatLocation(loc))
|
return fmt.Sprintf("%d - %s: %s", g.ID, locname, formatLocation(loc))
|
||||||
}
|
}
|
||||||
@ -428,9 +428,9 @@ func formatGoroutine(g *api.Goroutine, fgl formatGoroutineLoc) string {
|
|||||||
func writeGoroutineLong(w io.Writer, g *api.Goroutine, prefix string) {
|
func writeGoroutineLong(w io.Writer, g *api.Goroutine, prefix string) {
|
||||||
fmt.Fprintf(w, "%sGoroutine %d:\n%s\tRuntime: %s\n%s\tUser: %s\n%s\tGo: %s\n",
|
fmt.Fprintf(w, "%sGoroutine %d:\n%s\tRuntime: %s\n%s\tUser: %s\n%s\tGo: %s\n",
|
||||||
prefix, g.ID,
|
prefix, g.ID,
|
||||||
prefix, formatLocation(g.Current),
|
prefix, formatLocation(g.CurrentLoc),
|
||||||
prefix, formatLocation(g.UserCurrent),
|
prefix, formatLocation(g.UserCurrentLoc),
|
||||||
prefix, formatLocation(g.Go))
|
prefix, formatLocation(g.GoStatementLoc))
|
||||||
}
|
}
|
||||||
|
|
||||||
func restart(t *Term, args ...string) error {
|
func restart(t *Term, args ...string) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user