提交 148d6083 编写于 作者: E epipho 提交者: Derek Parker

Adding info sources

上级 623ec5e5
......@@ -9,6 +9,8 @@ import (
"io"
"os"
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
......@@ -52,6 +54,7 @@ func DebugCommands() *Commands {
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{"print", "p"}, cmdFn: printVar, helpMsg: "Evaluate a variable."},
command{aliases: []string{"info"}, cmdFn: info, helpMsg: "Provides list of source files with symbols."},
command{aliases: []string{"exit"}, cmdFn: nullCommand, helpMsg: "Exit the debugger."},
}
......@@ -258,6 +261,42 @@ func printVar(p *proctl.DebuggedProcess, args ...string) error {
return nil
}
func info(p *proctl.DebuggedProcess, args ...string) error {
if len(args) == 0 {
return fmt.Errorf("not enough arguments")
}
// Allow for optional regex
var filter *regexp.Regexp
if len(args) >= 2 {
var err error
if filter, err = regexp.Compile(args[1]); err != nil {
return fmt.Errorf("invalid filter argument: %s", err.Error())
}
}
switch args[0] {
case "sources":
files := make([]string, 0, len(p.GoSymTable.Files))
for f := range p.GoSymTable.Files {
if filter == nil || filter.Match([]byte(f)) {
files = append(files, f)
}
}
sort.Sort(sort.StringSlice(files))
for _, f := range files {
fmt.Printf("%s\n", f)
}
default:
return fmt.Errorf("unsupported info type, must be sources")
}
return nil
}
func printcontext(p *proctl.DebuggedProcess) error {
var context []string
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册