Skip to content

bpo-46600: Fix test_gdb.test_pycfunction() for clang -Og #31058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions Lib/test/test_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,15 +897,19 @@ def test_gc(self):
# to suppress these. See also the comment in DebuggerTests.get_stack_trace
def test_pycfunction(self):
'Verify that "py-bt" displays invocations of PyCFunction instances'
# bpo-46600: If the compiler inlines _null_to_none() in meth_varargs()
# (ex: clang -Og), _null_to_none() is the frame #1. Otherwise,
# meth_varargs() is the frame #1.
expected_frame = r'#(1|2)'
# Various optimizations multiply the code paths by which these are
# called, so test a variety of calling conventions.
for func_name, args, expected_frame in (
('meth_varargs', '', 1),
('meth_varargs_keywords', '', 1),
('meth_o', '[]', 1),
('meth_noargs', '', 1),
('meth_fastcall', '', 1),
('meth_fastcall_keywords', '', 1),
for func_name, args in (
('meth_varargs', ''),
('meth_varargs_keywords', ''),
('meth_o', '[]'),
('meth_noargs', ''),
('meth_fastcall', ''),
('meth_fastcall_keywords', ''),
):
for obj in (
'_testcapi',
Expand Down Expand Up @@ -945,10 +949,9 @@ def bar():
# defined.' message in stderr.
ignore_stderr=True,
)
self.assertIn(
f'#{expected_frame} <built-in method {func_name}',
gdb_output,
)
regex = expected_frame
regex += re.escape(f' <built-in method {func_name}')
self.assertRegex(gdb_output, regex)

@unittest.skipIf(python_is_optimized(),
"Python was compiled with optimizations")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix test_gdb.test_pycfunction() for Python built with ``clang -Og``.
Tolerate inlined functions in the gdb traceback. Patch by Victor Stinner.