Skip to content

Commit

Permalink
Issue python#101: Support debugging Stackless Python with gdb
Browse files Browse the repository at this point in the history
Enhance Tools/gdb/libpython.py to also support Stackless Python.

https://bitbucket.org/stackless-dev/stackless/issues/101
(grafted from 0dcb4381fdc89601fcb56527805ec387926d3098)
  • Loading branch information
Anselm Kruis committed Nov 22, 2016
1 parent ed7a02f commit 864d8a1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Stackless/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 15 additions & 1 deletion Tools/gdb/libpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 864d8a1

Please sign in to comment.