From 864d8a19b3a4e3927c8c61a4ddd5f56dfd3acbe6 Mon Sep 17 00:00:00 2001 From: Anselm Kruis Date: Tue, 22 Nov 2016 22:32:24 +0100 Subject: [PATCH] Issue #101: Support debugging Stackless Python with gdb Enhance Tools/gdb/libpython.py to also support Stackless Python. https://bitbucket.org/stackless-dev/stackless/issues/101 (grafted from 0dcb4381fdc89601fcb56527805ec387926d3098) --- Stackless/changelog.txt | 7 ++++++- Tools/gdb/libpython.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Stackless/changelog.txt b/Stackless/changelog.txt index 98a886be913ee5..c9729cb161d940 100644 --- a/Stackless/changelog.txt +++ b/Stackless/changelog.txt @@ -9,8 +9,13 @@ What's New in Stackless 3.X.X? *Release date: 20XX-XX-XX* +- https://bitbucket.org/stackless-dev/stackless/issues/101 + Enhance Tools/gdb/libpython.py to support debugging Stackless Python. + You can now debug Stackless Python with gdb. Unfortunately gdb still + does not know about inactive tasklets and their frames. + - https://bitbucket.org/stackless-dev/stackless/issues/99 - On UNIX like systems you can use the command + On UNIX like systems you can use the command $ make teststackless to run the Stackless unit tests. Previously the command required some non POSIX commands. diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py index 1c2c3cb5d27790..bdf0c2243aa4ee 100755 --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -86,6 +86,10 @@ ENCODING = locale.getpreferredencoding() +# name of the evalframeex function. It CPython and Stackless Python +# use different names +EVALFRAMEEX_FUNCTION_NAME = None + class NullPyObjectPtr(RuntimeError): pass @@ -1426,7 +1430,17 @@ def is_python_frame(self): def is_evalframeex(self): '''Is this a PyEval_EvalFrameEx frame?''' - if self._gdbframe.name() == 'PyEval_EvalFrameEx': + global EVALFRAMEEX_FUNCTION_NAME + if EVALFRAMEEX_FUNCTION_NAME is None: + try: + gdb.lookup_type("PyCFrameObject") + # it is Stackless Python + EVALFRAMEEX_FUNCTION_NAME = 'PyEval_EvalFrame_value' + except gdb.error: + # regular CPython + EVALFRAMEEX_FUNCTION_NAME = 'PyEval_EvalFrameEx' + + if self._gdbframe.name() == EVALFRAMEEX_FUNCTION_NAME: ''' I believe we also need to filter on the inline struct frame_id.inline_depth, only regarding frames with