def run_exec(statement, debug_opts=None, start_opts=None, globals_=None, locals_=None): """Execute the statement (given as a string) under debugger control starting with the statement subsequent to the place that this run_call appears in your program. This is a wrapper to Debugger.run_exec(), so see that. The debugger prompt appears before any code is executed; you can set breakpoints and type 'continue', or you can step through the statement using 'step' or 'next' The optional globals_ and locals_ arguments specify the environment in which the code is executed; by default the dictionary of the module __main__ is used.""" dbg = Trepan(opts=debug_opts) try: return dbg.run_exec(statement, start_opts=start_opts, globals_=globals_, locals_=locals_) except: uncaught_exception(dbg) pass return
def run_eval( expression, debug_opts=None, start_opts=None, globals_=None, locals_=None, tb_fn=None, ): """Evaluate the expression (given as a string) under debugger control starting with the statement subsequent to the place that this appears in your program. This is a wrapper to Debugger.run_eval(), so see that. When run_eval() returns, it returns the value of the expression. Otherwise this function is similar to run(). """ dbg = Trepan(opts=debug_opts) try: return dbg.run_eval(expression, start_opts=start_opts, globals_=globals_, locals_=locals_) except: dbg.core.trace_hook_suspend = True if start_opts and "tb_fn" in start_opts: tb_fn = start_opts["tb_fn"] uncaught_exception(dbg, tb_fn) finally: dbg.core.trace_hook_suspend = False return
def run_call(func, *args, **kwds): """Call the function (a function or method object, not a string) with the given arguments starting with the statement subsequent to the place that this appears in your program. When run_call() returns, it returns whatever the function call returned. The debugger prompt appears as soon as the function is entered.""" dbg = Trepan() try: return dbg.run_call(func, *args, **kwds) except: uncaught_exception(dbg) pass return
exec(code_obj, obj.locals, obj.globals) except SystemExit: raise except: obj.showtraceback() else: if code.softspace(sys.stdout, 0): print() pass pass return if __name__ == "__main__": from trepan.debugger import Trepan d = Trepan() command = IPythonCommand(d.core.processor) command.proc.frame = sys._getframe() command.proc.setup() if len(sys.argv) > 1: print("Type Python commands and exit to quit.") print(sys.argv[1]) if sys.argv[1] == "-d": print(command.run(["bpython", "-d"])) else: print(command.run(["bpython"])) pass pass pass