Index: pydb/gdb.py.in =================================================================== RCS file: /cvsroot/bashdb/pydb/pydb/gdb.py.in,v retrieving revision 1.41 diff -u -r1.41 gdb.py.in --- pydb/gdb.py.in 22 Jul 2006 22:39:18 -0000 1.41 +++ pydb/gdb.py.in 24 Jul 2006 16:53:11 -0000 @@ -258,7 +258,7 @@ self.showcmds.add('args', self.show_args) self.showcmds.add('basename', self.show_basename) self.showcmds.add('cmdtrace', self.show_cmdtrace, 2) - self.showcmds.add('commands', self.show_commands, 2) + self.showcmds.add('commands', self.show_commands, 2, False) self.showcmds.add('history', self.show_history) self.showcmds.add('interactive', self.show_interactive) self.showcmds.add('linetrace', self.show_linetrace, 3) @@ -1096,87 +1096,14 @@ get info about just that subcommand.""" if not arg: - self.help_info([]) + for subcommand in self.infocmds.list(): + self.msg_nocr("%s: " % subcommand) + self.do_info(subcommand) return - arglist = arg.split() - arg = arglist[0] - frame=self.curframe - if "args".startswith(arg): - if not self.curframe: - self.msg("No stack.") - return - self.info_args(None) - elif "break".startswith(arg): - # FIXME: Should split out the "info" part in args - self.do_L(None) - elif 'display'.startswith(arg): - if not self.display.displayAll(): - self.msg('There are no auto-display expressions now.') - elif "globals".startswith(arg): - if not frame: - self.msg("No frame selected.") - return - self.msg("\n".join(["%s = %s" - % (l, pprint.pformat(self.getval(l))) - for l in frame.f_globals])) - elif "line".startswith(arg) and len(arg) > 1: - #info line identifier - if not frame: - self.msg("No line number information available.") - return - if len(arglist) == 2: - # lineinfo returns (item, file, lineno) or (None,) - answer = self.lineinfo(arglist[1]) - if answer[0]: - item, file, lineno = answer - if not os.path.isfile(file): - file = search_file(file, self.search_path, - self.main_dirname) - self.msg('Line %s of "%s" <%s>' % - (lineno, file, item)) - return - #info line - file=self.canonic_filename(frame) - if not os.path.isfile(file): - file = search_file(file, self.search_path, self.main_dirname) - - self.msg('Line %d of \"%s\" at instruction %d' % - (inspect.getlineno(frame), - self.filename(self.canonic_filename(frame)), - self.curframe.f_lasti)) - elif "locals".startswith(arg) and len(arg) > 1: - if not frame: - self.msg("No frame selected.") - return - self.msg("\n".join(["%s = %s" - % (l, pprint.pformat(self.getval(l))) - for l in frame.f_locals])) - elif 'program'.startswith(arg): - if not frame: - self.msg("The program being debugged is not being run.") - return - if self.is_running(): - self.msg('Program stopped.') - if self.currentbp: - self.msg('It stopped at breakpoint %d.' % self.currentbp) - elif self.stop_reason == 'call': - self.msg('It stopped at a call.') - elif self.stop_reason == 'exception': - self.msg('It stopped as a result of an exception.') - elif self.stop_reason == 'return': - self.msg('It stopped at a return.') - else: - self.msg("It stopped after stepping, next'ing or initial start.") - return - elif "source".startswith(arg): - if not frame: - self.msg("No current source file.") - return - self.msg('Current Python file is %s' % - self.filename(self.canonic_filename(frame))) else: - self.undefined_cmd("info", arg) + args = arg.split() + self.infocmds.do(self, args[0], args) def info_break(self, arg): """info break @@ -1468,8 +1395,10 @@ if not arg: for subcommand in self.showcmds.list(): - self.msg_nocr("%s: " % subcommand) - self.do_show(subcommand) + # Only display commands that are 'in_list' + if self.showcmds.subcmds[subcommand]['in_list']: + self.msg_nocr("%s: " % subcommand) + self.do_show(subcommand) return if self._re_linetrace_delay.match(arg): Index: pydb/pydbcmd.py =================================================================== RCS file: /cvsroot/bashdb/pydb/pydb/pydbcmd.py,v retrieving revision 1.23 diff -u -r1.23 pydbcmd.py --- pydb/pydbcmd.py 22 Jul 2006 22:39:18 -0000 1.23 +++ pydb/pydbcmd.py 24 Jul 2006 16:53:11 -0000 @@ -6,7 +6,7 @@ of more oriented towards any gdb-like debugger. Also routines that need to be changed from cmd are here. """ -import cmd, linecache, os, sys, types +import cmd, linecache, os, pprint, sys, types from fns import * # Interaction prompt line will separate file and call info from code @@ -104,6 +104,10 @@ try: doc=getattr(self, 'do_' + first_arg).__doc__ if doc: + # We only print the first line, removing any periods + # if they are the last character on the line + doc = doc[:doc.find('\n')] + if doc[-1] == '.': doc = doc[:-1] self.msg("%s\n" % str(doc)) return except AttributeError: @@ -274,7 +278,7 @@ self.commands_doprompt[self.commands_bnum] = False self.cmdqueue = [] return 1 - return + return def info_args(self, arg): """Argument variables of current stack frame""" @@ -318,9 +322,9 @@ if not self.curframe: self.msg("No line number information available.") return - if len(arglist) == 2: + if len(arg) == 2: # lineinfo returns (item, file, lineno) or (None,) - answer = self.lineinfo(arglist[1]) + answer = self.lineinfo(arg[1]) if answer[0]: item, file, lineno = answer if not os.path.isfile(file): @@ -329,6 +333,14 @@ self.msg('Line %s of "%s" <%s>' % (lineno, file, item)) return + file=self.canonic_filename(self.curframe) + if not os.path.isfile(file): + file = search_file(file, self.search_path, self.main_dirname) + + self.msg('Line %d of \"%s\" at instruction %d' % + (inspect.getlineno(self.curframe), + self.filename(self.canonic_filename(self.curframe)), + self.curframe.f_lasti)) def info_locals(self, arg): """Local variables of current stack frame""" @@ -362,7 +374,7 @@ self.msg("No current source file.") return self.msg('Current Python file is %s' % - self.filename(self.canonic_filename(frame))) + self.filename(self.canonic_filename(self.curframe))) def msg(self, msg, out=None): """Common routine for reporting messages. Index: pydb/subcmd.py =================================================================== RCS file: /cvsroot/bashdb/pydb/pydb/subcmd.py,v retrieving revision 1.1 diff -u -r1.1 subcmd.py --- pydb/subcmd.py 22 Jul 2006 22:39:18 -0000 1.1 +++ pydb/subcmd.py 24 Jul 2006 16:53:12 -0000 @@ -17,14 +17,21 @@ return self.subcmds[subcmd_name] return None - def _subcmd_helper(self, subcmd_name, obj, label=False): + def _subcmd_helper(self, subcmd_name, obj, label=False, strip=False): """Show help for a single subcommand""" if label: obj.msg_nocr("%s %s --" % (self.name, subcmd_name)) entry=self.lookup(subcmd_name) if entry: - obj.msg(entry['doc']) + d = entry['doc'] + if strip: + # Limit the help message to one line (delimited by '\n') + if '\n' in d: + d = d[:d.find('\n')] + # If the last character is a period, remove it. + if d[-1] == '.': d = d[:d.find('.')] + obj.msg(d) return obj.undefined_cmd("help", subcmd_name) @@ -54,7 +61,7 @@ # Note: format of help is compatible with ddd. def help(self, obj, *args): - """help for subcommands""" + """help for subcommands.""" subcmd_prefix=args[0] if not subcmd_prefix or len(subcmd_prefix) == 0: @@ -63,7 +70,7 @@ List of %s subcommands: """ % (self.name)) for subcmd_name in self.list(): - self._subcmd_helper(subcmd_name, obj, True) + self._subcmd_helper(subcmd_name, obj, True, True) return entry=self.lookup(subcmd_prefix) @@ -75,6 +82,10 @@ def list(self): l=self.subcmds.keys() + for i in l: + # Remove subcmd if we don't want it displayed in the list + if not self.subcmds[i]['in_list']: + l.pop(l.index(i)) l.sort() return l Index: test/cmdparse.right =================================================================== RCS file: /cvsroot/bashdb/pydb/test/cmdparse.right,v retrieving revision 1.19 diff -u -r1.19 cmdparse.right --- test/cmdparse.right 22 Jul 2006 22:39:18 -0000 1.19 +++ test/cmdparse.right 24 Jul 2006 16:53:12 -0000 @@ -295,7 +295,6 @@ show args -- Show argument list to give debugged program on start show basename -- Show if we are to show short of long filenames show cmdtrace -- Show if we are to show debugger commands before running -show commands -- Show the history of commands you typed show history -- Generic command for showing command history parameters show interactive -- Show whether we are interactive show linetrace -- Show the line tracing status. Can also add 'delay'