Example #1
0
See Also
--------

`vmstack pop`
"""

    in_list    = True
    min_abbrev = len('pu')
    min_args = 1
    max_args = 1
    need_stack = True
    short_help = "Pop a value off the VM evaluation stack"

    def run(self, args):
        if self.core.is_running():
            proc = self.proc

            text = args[0]
            proc.vm.push(eval(text))
            self.msg(f"VM pushed: {text}")

        return None

    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd.__demo_helper__ import demo_run

    demo_run(VmstackPush, ["abc"])
    pass
Example #2
0
--------

`set style`, `show highlight`
"""

    in_list = True
    min_abbrev = len('sty')
    short_help = 'Set the pygments style'

    def run(self, args):
        if len(args) != 0:
            self.errmsg("Expecting no args")
            return

        style = self.debugger.settings[self.name]
        if style:
            self.msg("Pygments style is %s" % style)
        else:
            self.msg("Pygments style not set")
        return

    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    sub = Mhelper.demo_run(ShowStyle)
    d = sub.proc.debugger
    sub.run([])
    pass
Example #3
0
            loglevel_level = logging.INFO
        else:
            level_str = self.get_loglevel_level(args[0])
            if not level_str:
                return
            if level_str in ("off", "critical"):
                loglevel_level = logging.CRITICAL
            elif level_str in ("info", "on") :
                loglevel_level = logging.INFO
            elif level_str in ("warn", "warning") :
                loglevel_level = logging.WARNING
            else:
                assert level_str == "debug"
                loglevel_level = logging.DEBUG
            pass

        # Remove all handlers associated with the root logger object.
        for handler in logging.root.handlers[:]:
            logging.root.removeHandler(handler)
            pass
        logging.basicConfig(level=loglevel_level)
        self.proc.commands["show"].run(["show", "loglevel"])
        return

    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd.__demo_helper__ import demo_run
    demo_run(SetLogLevel, [])
    pass
Example #4
0
replaced by the new one.

In the following example, suppose in a docker container /mnt/project is
the mount-point for /home/rocky/project. You are running the code
from the docker container, but debugging this from outside of that.

Example:
--------

    set patsub ^/mmt/project /home/rocky/project

    """

    in_list = True
    max_args = 2
    min_abbrev = len("pats")
    min_args = 2
    short_help = "Set pattern substitution rule"

    def run(self, args):
        self.proc.add_remap_pat(args[0], args[1])

    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper

    Mhelper.demo_run(SetPatSub)
    pass
Example #5
0
    python_cmd = None

    def run(self, args):
        Mcmdfns.run_set_bool(self, args)
        if self.settings["autopython"]:
            if self.python_cmd is None:
                self.python_cmd = self.proc.commands["python"].run
                pass
            self.proc.add_preloop_hook(self.run_python, -1)
        else:
            self.proc.remove_preloop_hook(self.run_python)
            pass
        Mcmdfns.run_show_bool(self)
        return

    def run_python(self, args):
        leave_loop = self.python_cmd(["python"])
        if not leave_loop:
            Mcmdproc.print_location(self.proc)
        return leave_loop

    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper

    Mhelper.demo_run(SetAutoPython)
    pass
Example #6
0
    max_args = 1
    need_stack = True
    short_help = "Pop a value off the VM evaluation stack"

    def run(self, args):
        if self.core.is_running():
            proc = self.proc

            n = len(args)
            if n == 1:
                # FIXME add popping n entries
                count = 1
            else:
                count = 1

            result = proc.vm.frame.stack.pop()
            self.msg(
                f"VM stack popped {count} items: {result}, type {type(result)}"
            )

        return None

    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd.__demo_helper__ import demo_run

    demo_run(VmstackPop, [])
    pass
Example #7
0
  NameError: name 'fdafds' is not defined

One other thing that trips people up is when setting autoeval is that
there are some short debugger commands that sometimes one wants to use
as a variable, such as in an assignment statement. For example:

  s = 5

which produces when *autoeval* is on:

  Command 'step' can take at most 1 argument(s); got 2.

because by default, `s` is an alias for the debugger `step`
command. It is possible to remove that alias if this causes constant
problem.

Another possibility is to go into a real Python shell via the `python`
or `ipython` commands.
"""

    short_help = "Evaluate unrecognized debugger commands."
    in_list    = True
    min_abbrev = len('autoe')
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetAutoEval)
    pass
Example #8
0
                self.list_offset = frame.f_lasti = offset
                frame.fallthrough = False
                self.list_lineno = frame.f_lineno = frame.line_number()
                self.msg("Execution set to resume at offset %d" % offset)
                self.return_status = "skip"
                return None
            else:
                self.errmsg("Oddly, a frame is not set - nothing done.")
                pass
        else:
            if mainfile:
                part1 = "Python program '%s'" % mainfile
                msg = "is not currently running. "
                self.msg(wrapped_lines(part1, msg, self.settings["width"]))
            else:
                self.msg("No Python program is currently running.")
                pass
            self.msg(self.core.execution_status)
            pass
        return None

    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd.__demo_helper__ import demo_run

    demo_run(SetPC, [0])
    pass
Example #9
0
            return "extended"
        if arg in choices:
            return arg
        else:
            self.errmsg("Expecting one of: %s; got: %s." %
                        (", ".join(choices), arg))
            return None
        pass

    def run(self, args):
        if len(args) == 0:
            self.section("disasembly style types: ")
            self.msg(self.columnize_commands(choices))
            return
        format_type = self.get_format_type(args[0])
        if not format_type:
            return
        self.debugger.settings[self.name] = format_type
        show_cmd = self.proc.commands["show"]
        show_cmd.run(["show", self.name])
        return

    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd.__demo_helper__ import demo_run

    demo_run(SetAsmFmt, ["classic"])
    pass
Example #10
0
from trepan.processor.command import base_subcmd as Mbase_subcmd
from trepan.processor import cmdfns as Mcmdfns


class SetListSize(Mbase_subcmd.DebuggerSubcommand):
    """**set listsize** *number-of-lines*

Set the number lines printed in a *list* command by default

See also:
---------

`show listsize`"""

    in_list = True
    min_abbrev = len('lis')  # Need at least "set lis"

    def run(self, args):
        Mcmdfns.run_set_int(self, ' '.join(args),
                            "The 'listsize' command requires a line count.", 0,
                            None)
        return

    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetListSize)
    pass
Example #11
0
#   Copyright (C) 2009, 2013, 2015 Rocky Bernstein
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Our local modules
from trepan.processor.command import base_subcmd as Mbase_subcmd


class SetFlush(Mbase_subcmd.DebuggerSetBoolSubcommand):
    """Set flushing output after each write"""
    in_list = True
    min_abbrev = len('flu')  # Need at least "set flu"
    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetFlush)
    pass
Example #12
0
            n = len(proc.vm.frame.stack)
            if n == 0:
                self.errmsg(
                    "VM evaluation stack is empty - nothing to peek at at")
                return

            if len(args) == 0:
                number = 0
            else:
                print(args)
                number = get_an_int(
                    self.errmsg, args[0],
                    "The 'peek' command requires an integer greater than 0.",
                    0, n - 1)
                if number is None:
                    return
            # FIXME: vm.peek seems to be 1 origin. It should have been 0 origin I think.
            result = proc.vm.peek(number + 1)
            self.msg(
                f"VM evaluation stack at {number}: {result} {type(result)}")
        return None

    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd.__demo_helper__ import demo_run

    demo_run(VmstackPeek, [])
    pass
Example #13
0
See also:
--------

`set style`, `show highlight`
"""

    in_list    = True
    min_abbrev = len('sty')
    short_help = 'Set the pygments style'

    def run(self, args):
        if len(args) != 0:
            self.errmsg("Expecting no args")
            return

        style = self.debugger.settings[self.name]
        if style:
            self.msg("Pygments style is %s" % style)
        else:
            self.msg("Pygments style not set")
        return
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    sub = Mhelper.demo_run(ShowStyle)
    d = sub.proc.debugger
    sub.run([])
    pass
Example #14
0
By default, the debugger traces all events possible including line,
exceptions, call and return events. Just this alone may mean that for
any given source line several consecutive stops at a given line may
occur. Independent of this, Python allows one to put several commands
in a single source line of code. When a programmer does this, it might
be because the programmer thinks of the line as one unit.

One of the challenges of debugging is getting the granualarity of
stepping comfortable. Because of the above, stepping all events can
often be too fine-grained and annoying. By setting different on you
can set a more coarse-level of stepping which often still is small
enough that you won't miss anything important.
Note that the `step` and `next` debugger commands have `+` and `-`
suffixes if you wan to override this setting on a per-command basis.

See also:
---------
`set trace` to change what events you want to filter.
`show trace`
"""
    in_list    = True
    min_abbrev = len('dif')    # Min is "set dif"
    short_help = "Set whether consecutive stops are different"
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetDifferent)
    pass
Example #15
0
# Our local modules
from trepan.processor.command import base_subcmd as Mbase_subcmd
from trepan.processor import cmdfns as Mcmdfns


class SetListSize(Mbase_subcmd.DebuggerSubcommand):
    """**set listsize** *number-of-lines*

Set the number lines printed in a *list* command by default

See also:
---------

`show listsize`"""

    in_list    = True
    min_abbrev = len('lis')  # Need at least "set lis"

    def run(self, args):
        Mcmdfns.run_set_int(self, ' '.join(args),
                            "The 'listsize' command requires a line count.",
                            0, None)
        return
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetListSize)
    pass
Example #16
0
Spaces in "filesnames" like <frozen importlib._bootstrap> messes up our normal shell
tokenization, so we have added a hack to ignore <frozen .. >.

So for frozen files like <frozen importlib._bootstrap>, use importlib._bootstrap

Examples:
--------

    set substitute importlib._bootstrap /usr/lib/python3.4/importlib/_bootstrap.py
    set substitute ./gcd.py /tmp/gcd.py

See also:
---------
`show substitute`"""

    in_list = True
    min_abbrev = len('sub')
    short_help = 'Set filename substitution'

    def run(self, args):
        pyficache.remap_file(args[1], args[0])

    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetSubstitute)
    pass
Example #17
0
    See also:
    --------

    `set tempdir`"""

    in_list = True
    min_abbrev = len("temp")
    min_args = 0
    max_args = 0
    short_help = "Set a directory for storing decompiled Python"

    def run(self, args):
        tempdir = self.debugger.settings.get(self.name, None)
        if tempdir:
            self.msg("tempdir is %s." % tempdir)
        else:
            self.msg("tempdir not set; Python default is used.")
        return

    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper

    sub = Mhelper.demo_run(ShowTempdir)
    d = sub.proc.debugger
    sub.run(["show"])
    pass
Example #18
0
    """**set width** *number*

    Set the number of characters the debugger thinks are in a line.

    See also:
    --------

    `show width`"""

    in_list = True
    min_abbrev = len("wid")
    short_help = "Set the width of the terminal"

    def run(self, args):
        run_set_int(self, " ".join(args),
                    "The 'width' command requires a line width", 0, None)
        return

    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd.__demo_helper__ import demo_run

    sub = demo_run(SetWidth, ["10"])
    d = sub.proc.debugger
    print(d.settings["width"])
    sub.run(["100"])
    print(d.settings["width"])
    pass
Example #19
0
    list_cmd = None

    def run(self, args):
        Mcmdfns.run_set_bool(self, args)
        if self.settings['autolist']:
            if self.list_cmd is None:
                self.list_cmd = self.proc.commands['list'].run
                pass
            self.proc.add_preloop_hook(self.run_list, 0)

        else:
            self.proc.remove_preloop_hook(self.run_list)
            pass
        Mcmdfns.run_show_bool(self, 'Show `list` on debugger entry')
        return

    def run_list(self, args):
        # Check if there is a "file" to show. Right now we just
        # handle the case of a string.
        # FIXME: generalize this so for other kinds of missing "files"
        # are not shown.
        filename = Mstack.frame2file(self.core, self.proc.curframe)
        if '<string>' != filename: self.list_cmd(['list'])
        return
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetAutoList)
    pass
Example #20
0
class SetSkip(Mbase_subcmd.DebuggerSetBoolSubcommand):
    """**set skip** [ **on** | **off** ]


    Set stopping before *def* or *class* (function or class) statements.

    Classes may have many methods and stand-alone programs may have many
    functions. Often there isn't much value to stopping before defining a
    new function or class into Python's symbol table. (More to the point,
    it can be an annoyance.) However if you do want this, for example
    perhaps you want to debug methods is over-writing one another, then
    set this off

    See also:
    ---------

    `show skip`"""

    in_list = True
    min_abbrev = len("sk")  # Min 'set sk'
    short_help = "Set stopping before def or class statements"
    # FIXME allow individual setting for class and skip.
    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper

    sub = Mhelper.demo_run(SetSkip)
    pass
Example #21
0
If a substitution rule was previously set for FROM, the old rule
is replaced by the new one.

Spaces in "filesnames" like <frozen importlib._bootstrap> messes up our normal shell
tokenization, so we have added a hack to ignore <frozen .. >.

So for frozen files like <frozen importlib._bootstrap>, use importlib._bootstrap

Examples:
--------

    set substitute importlib._bootstrap /usr/lib/python3.4/importlib/_bootstrap.py
    set substitute ./gcd.py /tmp/gcd.py

See also:
---------
`show substitute`"""

    in_list    = True
    min_abbrev = len('sub')
    short_help = 'Set filename substitution'

    def run(self, args):
        pyficache.remap_file(args[1], args[0])
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetSubstitute)
    pass
Example #22
0
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Our local modules
from trepan.processor.command import base_subcmd as Mbase_subcmd


class SetBasename(Mbase_subcmd.DebuggerSetBoolSubcommand):
    """Set basename (short filenames) in debugger output.

Setting this causes the debugger output to give just the basename for
filenames. This is useful in debugger testing or possibly showing
examples where you don't want to hide specific filesystem and
installation information."""

    in_list    = True
    min_abbrev = len('ba')
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetBasename)
    pass
Example #23
0
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Our local modules
from trepan.processor.command import base_subcmd as Mbase_subcmd


class SetBasename(Mbase_subcmd.DebuggerSetBoolSubcommand):
    """**set basename** [ **on** | **off** ]

    Set basename (short filenames) in debugger output.

    Setting this causes the debugger output to give just the basename for
    filenames. This is useful in debugger testing or possibly showing
    examples where you don't want to hide specific filesystem and
    installation information."""

    in_list = True
    min_abbrev = len("ba")
    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper

    Mhelper.demo_run(SetBasename)
    pass
Example #24
0
# Our local modules
from trepan.processor.command import base_subcmd as Mbase_subcmd


class SetTrace(Mbase_subcmd.DebuggerSetBoolSubcommand):
    """**set trace** [ **on** | **off** ]

    Set event tracing.

    See also:
    ---------

    `set events`, and `show trace`."""

    in_list = True
    min_abbrev = len("trace")  # Must use at least "set trace"
    short_help = "Set event tracing"
    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper

    sub = Mhelper.demo_run(SetTrace)
    d = sub.proc.debugger
    for args in (["on"], ["off"]):
        sub.run(args)
        print(d.settings["trace"])
        pass
    pass
Example #25
0
    ---------

    `set asmfmt`"""

    min_abbrev = len("asmf")
    short_help = "Show assembly format style"
    pass

    def run(self, args):
        if len(args) != 0:
            self.errmsg("Expecting no args")
            return

        style = self.debugger.settings[self.name]
        if style:
            self.msg("Assembly format style is %s" % style)
        else:
            self.msg("Assembly format style not set")
        return

    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper

    sub = Mhelper.demo_run(ShowAsmFmt, [])
    d = sub.proc.debugger
    sub.run(["invalid arg"])
    pass
Example #26
0
    min_abbrev = len('autol')

    list_cmd = None

    def run(self, args):
        Mcmdfns.run_set_bool(self, args)
        if self.settings['autolist']:
            if self.list_cmd is None:
                self.list_cmd = self.proc.commands['list'].run
                pass
            self.proc.add_preloop_hook(self.run_list, 0)
        else:
            self.proc.remove_preloop_hook(self.run_list)
            pass
        return

    def run_list(self, args):
        # Check if there is a "file" to show. Right now we just
        # handle the case of a string.
        # FIXME: generalize this so for other kinds of missing "files"
        # are not shown.
        filename = Mstack.frame2file(self.core, self.proc.curframe)
        if '<string>' != filename: self.list_cmd(['list'])
        return
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetAutoList)
    pass
Example #27
0
# Our local modules
from trepan.processor.command import base_subcmd as Mbase_subcmd


class SetTrace(Mbase_subcmd.DebuggerSetBoolSubcommand):

    """**set trace** [ **on** | **off** ]

Set event tracing.

See also:
---------

`set events`, and `show trace`.
"""

    in_list    = True
    min_abbrev = len('trace')  # Must use at least "set trace"
    short_help = "Set event tracing"
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    sub = Mhelper.demo_run(SetTrace)
    d = sub.proc.debugger
    for args in (['on'], ['off']):
        sub.run(args)
        print(d.settings['trace'])
        pass
    pass
Example #28
0
By default, the debugger traces all events possible including line,
exceptions, call and return events. Just this alone may mean that for
any given source line several consecutive stops at a given line may
occur. Independent of this, Python allows one to put several commands
in a single source line of code. When a programmer does this, it might
be because the programmer thinks of the line as one unit.

One of the challenges of debugging is getting the granualarity of
stepping comfortable. Because of the above, stepping all events can
often be too fine-grained and annoying. By setting different on you
can set a more coarse-level of stepping which often still is small
enough that you won't miss anything important.
Note that the `step` and `next` debugger commands have `+` and `-`
suffixes if you wan to override this setting on a per-command basis.

See also:
---------

`set trace` to change what events you want to filter.
`show trace`
"""
    in_list = True
    min_abbrev = len('dif')  # Min is "set dif"
    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetDifferent)
    pass
Example #29
0
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Our local modules
from trepan.processor.command import base_subcmd as Mbase_subcmd


class SetConfirm(Mbase_subcmd.DebuggerSetBoolSubcommand):
    """**set confirm** [ **on* | **off** ]

Set confirmation of potentially dangerous operations.

Some operations are a bit disruptive like terminating the program.
To guard against running this accidentally, by default we ask for
confirmation. Commands can also be exempted from confirmation by suffixing
them with an exclamation mark (!).

See Also:
---------

`show confirm`
"""

    in_list    = True
    min_abbrev = len('co')
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetConfirm)
    pass
Example #30
0
    Set the number lines printed in a *list* command by default

    See also:
    ---------

    `show listsize`"""

    in_list = True
    min_abbrev = len("lis")  # Need at least "set lis"

    def run(self, args):
        run_set_int(
            self,
            " ".join(args),
            "The 'listsize' command requires a line count.",
            0,
            None,
        )
        return

    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd.__demo_helper__ import demo_run

    demo_run(SetListSize, [])  # Invalid
    demo_run(SetListSize, ["5"])  # ok
    pass
Example #31
0
class SetWidth(Mbase_subcmd.DebuggerSubcommand):
    """**set width** *number*

Set the number of characters the debugger thinks are in a line.

See also:
--------

`show width`
"""

    in_list = True
    min_abbrev = len("wid")
    short_help = "Set the width of the terminal"

    def run(self, args):
        Mcmdfns.run_set_int(self, " ".join(args), "The 'width' command requires a line width", 0, None)
        return

    pass


if __name__ == "__main__":
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper

    sub = Mhelper.demo_run(SetWidth)
    d = sub.proc.debugger
    sub.run(["100"])
    print(d.settings["width"])
    pass
Example #32
0
# Our local modules
from trepan.processor.command import base_subcmd as Mbase_subcmd


class SetConfirm(Mbase_subcmd.DebuggerSetBoolSubcommand):
    """**set confirm** [ **on* | **off** ]

Set confirmation of potentially dangerous operations.

Some operations are a bit disruptive like terminating the program.
To guard against running this accidentally, by default we ask for
confirmation. Commands can also be exempted from confirmation by suffixing
them with an exclamation mark (!).

See Also:
---------

`show confirm`
"""

    in_list = True
    min_abbrev = len('co')
    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetConfirm)
    pass
Example #33
0
  NameError: name 'fdafds' is not defined

One other thing that trips people up is when setting autoeval is that
there are some short debugger commands that sometimes one wants to use
as a variable, such as in an assignment statement. For example:

  s = 5

which produces when *autoeval* is on:

  Command 'step' can take at most 1 argument(s); got 2.

because by default, `s` is an alias for the debugger `step`
command. It is possible to remove that alias if this causes constant
problem.

Another possibility is to go into a real Python shell via the `python`
or `ipython` commands.
"""

    short_help = "Evaluate unrecognized debugger commands."
    in_list    = True
    min_abbrev = len('autoe')
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetAutoEval)
    pass
Example #34
0
# -*- coding: utf-8 -*-
#   Copyright (C) 2009, 2013, 2015 Rocky Bernstein
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Our local modules
from trepan.processor.command import base_subcmd as Mbase_subcmd


class SetFlush(Mbase_subcmd.DebuggerSetBoolSubcommand):
    """Set flushing output after each write"""
    in_list    = True
    min_abbrev = len('flu')  # Need at least "set flu"
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetFlush)
    pass
Example #35
0

class SetSkip(Mbase_subcmd.DebuggerSetBoolSubcommand):
    """**set skip** [ **on** | **off** ]


Set stopping before *def* or *class* (function or class) statements.

Classes may have many methods and stand-alone programs may have many
functions. Often there isn't much value to stopping before defining a
new function or class into Python's symbol table. (More to the point,
it can be an annoyance.) However if you do want this, for example
perhaps you want to debug methods is over-writing one another, then
set this off.

See also:
---------

`show skip`"""

    in_list    = True
    min_abbrev = len('sk')    # Min 'set sk'
    short_help = "Set stopping before def or class statements"
    # FIXME allow individual setting for class and skip.
    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    sub = Mhelper.demo_run(SetSkip)
    pass
Example #36
0
    """**set width** *number*

Set the number of characters the debugger thinks are in a line.

See also:
--------

`show width`
"""

    in_list = True
    min_abbrev = len('wid')
    short_help = 'Set the width of the terminal'

    def run(self, args):
        Mcmdfns.run_set_int(self, ' '.join(args),
                            "The 'width' command requires a line width", 0,
                            None)
        return

    pass


if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    sub = Mhelper.demo_run(SetWidth)
    d = sub.proc.debugger
    sub.run(['100'])
    print(d.settings['width'])
    pass
Example #37
0
    in_list    = True
    min_abbrev = len('autopy')  # Need at least "set autopy"
    short_help = "Go into a python on debugger entry."

    python_cmd = None

    def run(self, args):
        Mcmdfns.run_set_bool(self, args)
        if self.settings['autopython']:
            if self.python_cmd is None:
                self.python_cmd = self.proc.commands['python'].run
                pass
            self.proc.add_preloop_hook(self.run_python, -1)
        else:
            self.proc.remove_preloop_hook(self.run_python)
            pass
        Mcmdfns.run_show_bool(self)
        return

    def run_python(self, args):
        leave_loop = self.python_cmd(['python'])
        if not leave_loop: Mcmdproc.print_location(self.proc)
        return leave_loop

    pass

if __name__ == '__main__':
    from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
    Mhelper.demo_run(SetAutoPython)
    pass