Skip to content

Commit 4b749ba

Browse files
[3.12] gh-91960: Skip test_gdb if gdb cannot retrive Python frames (GH-108999) (#109010)
gh-91960: Skip test_gdb if gdb cannot retrive Python frames (GH-108999) Skip test_gdb if gdb is unable to retrieve Python frame objects: if a frame is "<optimized out>". When Python is built with "clang -Og", gdb can fail to retrive the 'frame' parameter of _PyEval_EvalFrameDefault(). In this case, tests like py_bt() are likely to fail. Without getting access to Python frames, python-gdb.py is mostly clueless on retrieving the Python traceback. Moreover, test_gdb is no longer skipped on macOS if Python is built with Clang. (cherry picked from commit fbce43a) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 9441005 commit 4b749ba

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Diff for: Lib/test/test_gdb.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ def get_gdb_version():
5555
if not sysconfig.is_python_build():
5656
raise unittest.SkipTest("test_gdb only works on source builds at the moment.")
5757

58-
if 'Clang' in platform.python_compiler() and sys.platform == 'darwin':
59-
raise unittest.SkipTest("test_gdb doesn't work correctly when python is"
60-
" built with LLVM clang")
61-
6258
if ((sysconfig.get_config_var('PGO_PROF_USE_FLAG') or 'xxx') in
6359
(sysconfig.get_config_var('PY_CORE_CFLAGS') or '')):
6460
raise unittest.SkipTest("test_gdb is not reliable on PGO builds")
@@ -247,6 +243,9 @@ def get_stack_trace(self, source=None, script=None,
247243
for pattern in (
248244
'(frame information optimized out)',
249245
'Unable to read information on python frame',
246+
# gh-91960: On Python built with "clang -Og", gdb gets
247+
# "frame=<optimized out>" for _PyEval_EvalFrameDefault() parameter
248+
'(unable to read python frame information)',
250249
):
251250
if pattern in out:
252251
raise unittest.SkipTest(f"{pattern!r} found in gdb output")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Skip ``test_gdb`` if gdb is unable to retrieve Python frame objects: if a
2+
frame is ``<optimized out>``. When Python is built with "clang -Og", gdb can
3+
fail to retrive the *frame* parameter of ``_PyEval_EvalFrameDefault()``. In
4+
this case, tests like ``py_bt()`` are likely to fail. Without getting access
5+
to Python frames, ``python-gdb.py`` is mostly clueless on retrieving the
6+
Python traceback. Moreover, ``test_gdb`` is no longer skipped on macOS if
7+
Python is built with Clang. Patch by Victor Stinner.

0 commit comments

Comments
 (0)