// InfoBreakpointSubcmd implements the debugger command: // info breakpoint // // This command shows status of user-settable breakpoints. If no // breakpoint numbers are given, the show all breakpoints. Otherwise // only those breakpoints listed are shown and the order given. // // The "Disp" column contains one of "keep", "del", the disposition of // the breakpoint after it gets hit. // // The "enb" column indicates whether the breakpoint is enabled. // // The "Where" column indicates where the breakpoint is located. // Status of user-settable breakpoints. func InfoBreakpointSubcmd(args []string) { if gub.IsBreakpointEmpty() { gub.Msg("No breakpoints set") return } bpLen := len(gub.Breakpoints) if bpLen-gub.BrkptsDeleted == 0 { gub.Msg("No breakpoints.") } if len(args) > 2 { headerShown := false for _, num := range args[2:] { if bpNum, err := gub.GetInt(num, "breakpoint number", 0, bpLen-1); err == nil { if bp := gub.BreakpointFindById(bpNum); bp != nil { if !headerShown { gub.Section("Num Type Disp Enb Where") headerShown = true } gub.Bpprint(*bp) } else { gub.Errmsg("Breakpoint %d not found.", bpNum) } } } } else { gub.Section("Num Type Disp Enb Where") for _, bp := range gub.Breakpoints { if bp.Deleted { continue } gub.Bpprint(*bp) } } }
func HelpCommand(args []string) { if len(args) == 1 { gub.Msg(gub.Cmds["help"].Help) } else { what := args[1] cmd := gub.LookupCmd(what) if what == "*" { var names []string for k, _ := range gub.Cmds { names = append(names, k) } gub.Section("All command names:") sort.Strings(names) opts := columnize.DefaultOptions() opts.DisplayWidth = gub.Maxwidth opts.LinePrefix = " " mems := strings.TrimRight(columnize.Columnize(names, opts), "\n") gub.Msg(mems) } else if what == "categories" { gub.Section("Categories") for k, _ := range gub.Categories { gub.Msg("\t %s", k) } } else if info := gub.Cmds[cmd]; info != nil { if len(args) > 2 { if info.SubcmdMgr != nil { gub.HelpSubCommand(info.SubcmdMgr, args) return } } gub.Msg(info.Help) if len(info.Aliases) > 0 { gub.Msg("Aliases: %s", strings.Join(info.Aliases, ", ")) } } else if cmds := gub.Categories[what]; len(cmds) > 0 { gub.Section("Commands in class: %s", what) sort.Strings(cmds) opts := columnize.DefaultOptions() opts.DisplayWidth = gub.Maxwidth mems := strings.TrimRight(columnize.Columnize(cmds, opts), "\n") gub.Msg(mems) } else { gub.Errmsg("Can't find help for %s", what) } } }
func InfoScopeSubcmd(args []string) { fr := gub.CurFrame() scope := fr.Scope() if scope == nil { gub.Errmsg("No scope recorded here") return } count := 0 if len(args) == 3 { var err error count, err = gub.GetInt(args[2], "count", 0, gub.MAXSTACKSHOW) if err != nil { return } } typescope := scope.Scope for i := 0; i < count; i++ { typescope = typescope.Parent() if typescope == nil { gub.Errmsg("There are only %d nested scopes", i) return } scope = fr.Fn().Pkg.TypeScope2Scope[typescope] if scope == nil { gub.Errmsg("No parent scope; There are only %d nested scopes", i) return } } gub.Section("scope number %d", scope.ScopeId()) gub.Msg("%s", typescope) }
// InfoPackageCommand implements the command: // info package [*name* ] // which show information about a package or lists all packages. func InfoPackageSubcmd(args []string) { if len(args) > 2 { for _, pkg_name := range args[2:len(args)] { if pkg := gub.Program().PackagesByName[pkg_name]; pkg != nil { gub.Msg("Package %s: \"%s\"", pkg_name, pkg.Object.Path()) gub.Section("Package members:") var names []string for k, _ := range pkg.Members { names = append(names, k) } sort.Strings(names) opts := columnize.DefaultOptions() opts.DisplayWidth = gub.Maxwidth opts.LinePrefix = " " mems := strings.TrimRight(columnize.Columnize(names, opts), "\n") gub.Msg(mems) } else { gub.Errmsg("Package %s not imported", pkg_name) } } } else { pkgNames := []string{} for pkg := range gub.Program().PackagesByName { pkgNames = append(pkgNames, pkg) } gub.PrintSorted("All imported packages", pkgNames) } }
func AliasCommand(args []string) { if len(args) == 1 { var names []string for k, _ := range gub.Aliases { names = append(names, k) } gub.Section("All aliases:") sort.Strings(names) opts := columnize.DefaultOptions() opts.DisplayWidth = gub.Maxwidth opts.LinePrefix = " " mems := strings.TrimRight(columnize.Columnize(names, opts), "\n") gub.Msg(mems) } else { cmd := args[1] if info := gub.Cmds[cmd]; info != nil { if len(info.Aliases) > 0 { gub.Msg("Aliases for %s: %s", cmd, strings.Join(info.Aliases, ", ")) } else { gub.Msg("No aliases for %s", cmd) } } else if realCmd := gub.Aliases[cmd]; realCmd != "" { gub.Msg("Alias %s is an alias for command %s", cmd, realCmd) } else { gub.Errmsg("Can't find command or alias %s", cmd) } } }