Esempio n. 1
0
            pass
        return False

if __name__ == '__main__':

    # FIXME: make sure the below is in a unit test
    def doit(cmd, args):
        proc = cmd.proc
        proc.current_command = ' '.join(args)
        cmd.run(args)


    from trepan.processor.command import mock as Mmock
    from trepan.processor.cmdproc import CommandProcessor
    d = Mmock.MockDebugger()
    cmdproc = CommandProcessor(d.core)
    cmdproc.frame = sys._getframe()
    cmdproc.setup()
    lcmd = ListCommand(cmdproc)

    print('--' * 10)
    # doit(lcmd, ['list'])

    # doit(lcmd, ['list', __file__ + ':10'])
    # print('--' * 10)

    # doit(lcmd, ['list', 'os:10'])
    # print('--' * 10)

    # doit(lcmd, ['list', '.'])
    # print('--' * 10)
Esempio n. 2
0
                last = first + listsize
            elif last < first:
                # Treat as a count rather than an absolute location
                last = first + last

            return location.path, first, first_is_addr, last, last_is_addr, location.method
        pass
    return

# Demo it
if __name__=='__main__':
    from trepan.processor.command import mock as Mmock
    from trepan.processor.cmdproc import CommandProcessor
    import sys
    d = Mmock.MockDebugger()
    cmdproc = CommandProcessor(d.core)
    # print '-' * 10
    # print_source_line(sys.stdout.write, 100, 'source_line_test.py')
    # print '-' * 10
    cmdproc.frame = sys._getframe()
    cmdproc.setup()

    def five():
        return 5
    import os
    for cmd in (
            # "disasm",
            # "disasm +",
            # "disasm -",
            "disasm *5, *10",
            "disasm *15, 10",
Esempio n. 3
0
        except (KeyError, AttributeError):
            return []
        pre_prefix = ".".join(dotted[:-1]) + "."
        return [pre_prefix + n for n in dir(obj) if n.startswith(dotted[-1])]
    else:
        # Complete a simple name.
        return Mcomplete.complete_token(ns.keys(), prefix)


def complete_id_and_builtins(cmd, prefix):
    if not cmd.proc.curframe:
        return [None]
    items = list(cmd.proc.curframe.f_builtins.keys()) + complete_identifier(cmd, prefix)
    return Mcomplete.complete_token(items, prefix)


if __name__ == "__main__":
    import inspect
    from trepan.processor.cmdproc import CommandProcessor
    from trepan.processor.command.mock import MockDebugger
    from trepan.processor.command.base_cmd import DebuggerCommand

    d = MockDebugger()
    cmdproc = CommandProcessor(d.core)
    cmdproc.curframe = inspect.currentframe()
    cmd = DebuggerCommand(cmdproc)
    print(complete_identifier(cmd, ""))
    print(complete_identifier(cmd, "M"))
    print(complete_id_and_builtins(cmd, "M"))
    pass
Esempio n. 4
0
        else:
            self.list_object = None
            pass
        # if self.execRcLines()==1: return True

        # FIXME:  do we want to save self.list_lineno a second place
        # so that we can do 'list .' and go back to the first place we listed?
        return False


# Demo it
if __name__ == "__main__":
    from trepan.processor.command import mock as Mmock

    d = Mmock.MockDebugger()
    cmdproc = CommandProcessor(d.core)
    print("commands:")
    commands = list(cmdproc.commands.keys())
    commands.sort()
    print(commands)
    print("aliases:")
    aliases = list(cmdproc.aliases.keys())
    aliases.sort()
    print(aliases)
    print(resolve_name(cmdproc, "quit"))
    print(resolve_name(cmdproc, "q"))
    print(resolve_name(cmdproc, "info"))
    print(resolve_name(cmdproc, "i"))
    # print '-' * 10
    # print_source_line(sys.stdout.write, 100, 'source_line_test.py')
    # print '-' * 10