From 71ce17dd74cdf4b9189a0ac3aa0237fe406a9907 Mon Sep 17 00:00:00 2001 From: Mark Florisson Date: Sat, 13 Nov 2010 12:24:42 +0100 Subject: [PATCH] Added 'cy select' command --- Cython/Debugger/libcython.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Cython/Debugger/libcython.py b/Cython/Debugger/libcython.py index 1299abaa..f02817bd 100644 --- a/Cython/Debugger/libcython.py +++ b/Cython/Debugger/libcython.py @@ -598,6 +598,7 @@ class CyCy(CythonCommand): finish = CyFinish.register(), up = CyUp.register(), down = CyDown.register(), + select = CySelect.register(), bt = CyBacktrace.register(), list = CyList.register(), print_ = CyPrint.register(), @@ -949,6 +950,32 @@ class CyDown(CyUp): _command = 'down' +class CySelect(CythonCodeStepper): + """ + Select a frame. Use frame numbers as listed in `cy backtrace`. + This command is useful because `cy backtrace` prints a reversed backtrace. + """ + + name = 'cy select' + + def invoke(self, stackno, from_tty): + try: + stackno = int(stackno) + except ValueError: + raise gdb.GdbError("Not a valid number: %r" % (stackno,)) + + frame = gdb.selected_frame() + while frame.newer(): + frame = frame.newer() + + stackdepth = self._stackdepth(frame) + + try: + gdb.execute('select %d' % (stackdepth - stackno - 1,)) + except RuntimeError, e: + raise gdb.GdbError(*e.args) + + class CyBacktrace(CythonCommand): 'Print the Cython stack' -- 2.26.2