Add 'help' command

This commit is contained in:
Derek Parker
2014-10-20 12:06:36 -05:00
parent 15da4c2e89
commit 09ff60f1ab
2 changed files with 12 additions and 0 deletions

View File

@ -24,6 +24,7 @@ type Commands struct {
// Returns a Commands struct with default commands defined. // Returns a Commands struct with default commands defined.
func DebugCommands() *Commands { func DebugCommands() *Commands {
cmds := map[string]cmdfunc{ cmds := map[string]cmdfunc{
"help": help,
"continue": cont, "continue": cont,
"next": next, "next": next,
"break": breakpoint, "break": breakpoint,
@ -71,6 +72,16 @@ func nullCommand(p *proctl.DebuggedProcess, ars ...string) error {
return nil return nil
} }
func help(p *proctl.DebuggedProcess, ars ...string) error {
fmt.Println(`The following commands are available:
break - Set break point at the entry point of a function, or at a specific file/line. Example: break foo.go:13.
continue - Run until breakpoint or program termination.
step - Single step through program.
next - Step over to next source line.
print $var - Evaluate a variable.`)
return nil
}
func cont(p *proctl.DebuggedProcess, ars ...string) error { func cont(p *proctl.DebuggedProcess, ars ...string) error {
err := p.Continue() err := p.Continue()
if err != nil { if err != nil {

View File

@ -86,6 +86,7 @@ func main() {
} }
goreadline.LoadHistoryFromFile(historyFile) goreadline.LoadHistoryFromFile(historyFile)
fmt.Println("Type 'help' for list of commands.")
for { for {
cmdstr, err := t.promptForInput() cmdstr, err := t.promptForInput()