Skip to content

Commit 864d8a1

Browse files
author
Anselm Kruis
committed
Issue python#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)
1 parent ed7a02f commit 864d8a1

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Stackless/changelog.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ What's New in Stackless 3.X.X?
99

1010
*Release date: 20XX-XX-XX*
1111

12+
- https://bitbucket.org/stackless-dev/stackless/issues/101
13+
Enhance Tools/gdb/libpython.py to support debugging Stackless Python.
14+
You can now debug Stackless Python with gdb. Unfortunately gdb still
15+
does not know about inactive tasklets and their frames.
16+
1217
- https://bitbucket.org/stackless-dev/stackless/issues/99
13-
On UNIX like systems you can use the command
18+
On UNIX like systems you can use the command
1419
$ make teststackless
1520
to run the Stackless unit tests. Previously the command required some non
1621
POSIX commands.

Tools/gdb/libpython.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686

8787
ENCODING = locale.getpreferredencoding()
8888

89+
# name of the evalframeex function. It CPython and Stackless Python
90+
# use different names
91+
EVALFRAMEEX_FUNCTION_NAME = None
92+
8993
class NullPyObjectPtr(RuntimeError):
9094
pass
9195

@@ -1426,7 +1430,17 @@ def is_python_frame(self):
14261430

14271431
def is_evalframeex(self):
14281432
'''Is this a PyEval_EvalFrameEx frame?'''
1429-
if self._gdbframe.name() == 'PyEval_EvalFrameEx':
1433+
global EVALFRAMEEX_FUNCTION_NAME
1434+
if EVALFRAMEEX_FUNCTION_NAME is None:
1435+
try:
1436+
gdb.lookup_type("PyCFrameObject")
1437+
# it is Stackless Python
1438+
EVALFRAMEEX_FUNCTION_NAME = 'PyEval_EvalFrame_value'
1439+
except gdb.error:
1440+
# regular CPython
1441+
EVALFRAMEEX_FUNCTION_NAME = 'PyEval_EvalFrameEx'
1442+
1443+
if self._gdbframe.name() == EVALFRAMEEX_FUNCTION_NAME:
14301444
'''
14311445
I believe we also need to filter on the inline
14321446
struct frame_id.inline_depth, only regarding frames with

0 commit comments

Comments
 (0)