mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 04:35:19 +08:00
@ -41,6 +41,8 @@ type Commands struct {
|
|||||||
client service.Client
|
client service.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var exitAliases = []string{"exit", "quit", "q"}
|
||||||
|
|
||||||
// Returns a Commands struct with default commands defined.
|
// Returns a Commands struct with default commands defined.
|
||||||
func DebugCommands(client service.Client) *Commands {
|
func DebugCommands(client service.Client) *Commands {
|
||||||
c := &Commands{client: client}
|
c := &Commands{client: client}
|
||||||
@ -61,13 +63,22 @@ func DebugCommands(client service.Client) *Commands {
|
|||||||
{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: printVar, helpMsg: "Evaluate a variable."},
|
{aliases: []string{"print", "p"}, cmdFn: printVar, helpMsg: "Evaluate a variable."},
|
||||||
{aliases: []string{"info"}, cmdFn: info, helpMsg: "Subcommands: args, funcs, locals, sources, vars, or regs."},
|
{aliases: []string{"info"}, cmdFn: info, helpMsg: "Subcommands: args, funcs, locals, sources, vars, or regs."},
|
||||||
{aliases: []string{"exit"}, cmdFn: nullCommand, helpMsg: "Exit the debugger."},
|
{aliases: exitAliases, cmdFn: nullCommand, helpMsg: "Exit the debugger."},
|
||||||
{aliases: []string{"stack"}, cmdFn: stackCommand, helpMsg: "stack [<depth> [<goroutine id>]]. Prints stack."},
|
{aliases: []string{"stack", "bt"}, cmdFn: stackCommand, helpMsg: "stack [<depth> [<goroutine id>]]. Prints stack."},
|
||||||
}
|
}
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isExitCommand(cmdstr string) bool {
|
||||||
|
for _, a := range exitAliases {
|
||||||
|
if a == cmdstr {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Register custom commands. Expects cf to be a func of type cmdfunc,
|
// Register custom commands. Expects cf to be a func of type cmdfunc,
|
||||||
// returning only an error.
|
// returning only an error.
|
||||||
func (c *Commands) Register(cmdstr string, cf cmdfunc, helpMsg string) {
|
func (c *Commands) Register(cmdstr string, cf cmdfunc, helpMsg string) {
|
||||||
|
|||||||
@ -84,7 +84,7 @@ func (t *Term) Run() (error, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmdstr, args := parseCommand(cmdstr)
|
cmdstr, args := parseCommand(cmdstr)
|
||||||
if cmdstr == "exit" {
|
if isExitCommand(cmdstr) {
|
||||||
err, status = handleExit(t.client, t)
|
err, status = handleExit(t.client, t)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user