Пример #1
0
"""

    category      = 'data'
    min_args      = 0
    max_args      = None
    name          = osp.basename(__file__).split('.')[0]
    need_stack    = False
    short_help    = 'Modify parts of the debugger environment'

    def __init__(self, proc, name="set"):
        """Initialize show subcommands. Note: instance variable name
        has to be setcmds ('set' + 'cmds') for subcommand completion
        to work."""

        super().__init__(proc, name)
        new_cmdlist = []
        for subname in self.cmds.cmdlist:
            if subname in ("dbg_trepan", "events"):
                del self.cmds.subcmds[subname]
            else:
                new_cmdlist.append(subname)
        self.cmds.cmdlist = new_cmdlist
        self._load_debugger_subcommands(name, "trepanxpy")

if __name__ == '__main__':
    from trepan.processor.command import mock
    d, cp = mock.dbg_setup()
    command = SetCommand(cp, 'set')
    command.run(['set'])
    pass
Пример #2
0
import os

from trepan.processor.command import base_submgr


class SetCommand(base_submgr.SubcommandMgr):
    """**set** *set subcommand*

Modifies parts of the debugger environment.

You can give unique prefix of the name of a subcommand to get
information about just that subcommand.

Type `set` for a list of *set* subcommands and what they do.
Type `help set *` for just the list of *set* subcommands.
"""

    category      = 'data'
    min_args      = 0
    max_args      = None
    name          = os.path.basename(__file__).split('.')[0]
    need_stack    = False
    short_help    = 'Modify parts of the debugger environment'

if __name__ == '__main__':
    from trepan.processor.command import mock
    d, cp = mock.dbg_setup()
    command = SetCommand(cp, 'set')
    command.run(['set'])
    pass
Пример #3
0
        for arg in parms:
            if arg == '-v': opts['verbose'] = True
            elif arg == '-Y': opts['confirm_val'] = True
            elif arg == '-N': opts['confirm_val'] = False
            elif arg == '-c': opts['abort_on_error'] = False
            pass
        filename = args[-1]

        expanded_file = os.path.expanduser(filename)
        if not Mfile.readable(expanded_file):
            self.errmsg("Debugger command file '%s' is not a readable file" %
                        filename)
            return False

        # Push a new interface.
        script_intf = \
          Mscript.ScriptInterface(expanded_file, opts=opts,
                                  out=self.debugger.intf[-1].output)
        self.debugger.intf.append(script_intf)
        return False


# Demo it
if __name__ == '__main__':
    from trepan.processor.command import mock as Mmock
    d, cp = Mmock.dbg_setup()
    command = SourceCommand(cp)
    if len(sys.argv) > 1:
        command.run([sys.argv[1]])
    pass
Пример #4
0
def demo_setup():
    from trepan.processor.command import mock as Mmock, show as Mshow
    d, cp = Mmock.dbg_setup()
    mgr = Mshow.ShowCommand(cp)
    return mgr
def demo_setup():
    from trepan.processor.command import mock as Mmock, show as Mshow
    d, cp = Mmock.dbg_setup()
    mgr = Mshow.ShowCommand(cp)
    return mgr
Пример #6
0
class DebuggerShowIntSubcommand(DebuggerSubcommand):
    max_args = 0

    def run(self, args):
        if hasattr(self, "short_help"):
            short_help = self.short_help
        else:
            short_help = self.__doc__[5:].capitalize()
            pass
        run_show_int(self, short_help)
        return


class DebuggerShowBoolSubcommand(DebuggerSubcommand):
    max_args = 0

    def run(self, args):
        # Strip off ReStructuredText tags
        doc = re.sub("[*]", "", self.short_help)
        doc = doc[5:].capitalize().split("\n")[0].rstrip(".")
        run_show_bool(self, doc)
        return


if __name__ == "__main__":
    from trepan.processor.command.mock import dbg_setup

    d, cp = dbg_setup()
    dd = DebuggerSubcommand(cp.commands["quit"])
Пример #7
0
def demo_setup():
    from trepan.processor.command import mock as Mmock, set as Mset
    d, cp = Mmock.dbg_setup()
    mgr = Mset.SetCommand(cp)
    return mgr
Пример #8
0
            self.errmsg("Expecting a Python lambda expression; got %s" %
                        cmd_argstr)
            pass
        if proc_obj:
            if isinstance(proc_obj, types.FunctionType):
                self.proc.macros[cmd_name] = [proc_obj, cmd_argstr]
                self.msg("Macro \"%s\" defined." % cmd_name)
            else:
                self.errmsg("Expecting a Python lambda expression; got: %s" %
                            cmd_argstr)
                pass
            pass
        return

    pass


# Demo it
if __name__ == '__main__':
    from trepan.processor.command import mock as Mmock
    dbgr, cmd = Mmock.dbg_setup()
    command = MacroCommand(cmd)
    for cmdline in ["macro foo lambda a,y: x+y", "macro bad2 1+2"]:
        args = cmdline.split()
        cmd_argstr = cmdline[len(args[0]):].lstrip()
        cmd.cmd_argstr = cmd_argstr
        command.run(args)
        pass
    print(cmd.macros)
    pass
Пример #9
0
        except (SyntaxError, NameError, ValueError):
            self.errmsg("Expecting a Python lambda expression; got %s" %
                        cmd_argstr)
            pass
        if proc_obj:
            if isinstance(proc_obj, types.FunctionType):
                self.proc.macros[cmd_name] = [proc_obj, cmd_argstr]
                self.msg("Macro \"%s\" defined." % cmd_name)
            else:
                self.errmsg("Expecting a Python lambda expression; got: %s" %
                            cmd_argstr)
                pass
            pass
        return
    pass

# Demo it
if __name__ == '__main__':
    from trepan.processor.command import mock as Mmock
    dbgr, cmd = Mmock.dbg_setup()
    command = MacroCommand(cmd)
    for cmdline in ["macro foo lambda a,y: x+y",
                    "macro bad2 1+2"]:
        args = cmdline.split()
        cmd_argstr = cmdline[len(args[0]):].lstrip()
        cmd.cmd_argstr = cmd_argstr
        command.run(args)
        pass
    print(cmd.macros)
    pass
Пример #10
0
        try:
            m = inspect.getmodule(value)
            if m: self.msg("  module:\t%s" % m)
        except:
            try:
                f = inspect.getfile(value)
                self.msg("  file: %s" % f)
            except:
                pass
            pass
        return False

    pass

if __name__ == '__main__':
    from trepan.processor import cmdproc as Mcmdproc
    from trepan.processor.command import mock as Mmock
    d, cp       = Mmock.dbg_setup()
    command     = WhatisCommand(cp)
    cp.curframe = inspect.currentframe()
    cp.stack, cp.curindex = Mcmdproc.get_stack(cp.curframe, None, None,
                                               cp)

    words = '''5 1+2 thing len trepan os.path.basename WhatisCommand cp
               __name__ Mmock Mbase_cmd.DebuggerCommand'''.split()
    for thing in words:
        cp.cmd_argstr = thing
        command.run(['whatis', thing])
        print('-' * 10)
    pass