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
test_gdb must not fail on "unexpected" messages written into stderr #81543
Comments
Currently, test_gdb fails if gdb logs messages on stderr which are "unexpected". I don't understand the rationale for that: Python is not supposed to test gdb. It's only supposed to check that python-gdb.py commands work as expected: stderr should be ignored. In the past, I was lazy and just added more and more patterns to ignore on stderr, but this approach doesn't work in the long term: gdb evolves frequently, and there are always new messages. Attached PR modify test_gdb to ignore stderr, except of "PC not saved" pattern used to skip test_gdb on a special case: bpo-34007. # bpo34007: Sometimes some versions of the shared libraries that
# are part of the traceback are compiled in optimised mode and the
# Program Counter (PC) is not present, not allowing gdb to walk the
# frames back. When this happens, the Python bindings of gdb raise
# an exception, making the test impossible to succeed.
if "PC not saved" in err:
raise unittest.SkipTest("gdb cannot walk the frame object"
" because the Program Counter is"
" not present") |
A recent example: test_gdb fails on Fedora because a warning which should not prevent to test python-gdb.py commands: "Missing separate debuginfo for /lib/ld-linux-aarch64.so.1" Moreover, Fedora also suggests a command to install missing package in this case: "Try: dnf --enablerepo='*debug*' install ..." |
I think when I wrote this I was over-optimistically thinking that we could just add more patterns, but if it's becoming a pain, then your approach looks good to me. |
Well, I tried hard to fit into this approach: over the years, I added more and more patterns... but it's a painful work: first a CI break, I add more patterns and then I have to backport the change to all branches. As I wrote, I'm not convinced of the purpose of getting a failure in this case. Python doesn't get any benefit from this. Anyway, I merged my change. Thanks for your approval ;-) |
For the record, examples of ignored patterns: ignore_patterns = (
'Function "%s" not defined.' % breakpoint,
'Do you need "set solib-search-path" or '
'"set sysroot"?',
# BFD: /usr/lib/debug/(...): unable to initialize decompress
# status for section .debug_aranges
'BFD: ',
# ignore all warnings
'warning: ',
) Enjoy the older list before I chose to ignore "warning: " :-) # Ignore some benign messages on stderr.
ignore_patterns = (
'Function "%s" not defined.' % breakpoint,
"warning: no loadable sections found in added symbol-file"
" system-supplied DSO",
"warning: Unable to find libthread_db matching"
" inferior's thread library, thread debugging will"
" not be available.",
"warning: Cannot initialize thread debugging"
" library: Debugger service failed",
'warning: Could not load shared library symbols for '
'linux-vdso.so',
'warning: Could not load shared library symbols for '
'linux-gate.so',
'warning: Could not load shared library symbols for '
'linux-vdso64.so',
'Do you need "set solib-search-path" or '
'"set sysroot"?',
'warning: Source file is more recent than executable.',
# Issue python/cpython#63952: missing symbols on System Z
'Missing separate debuginfo for ',
'Try: zypper install -C ',
) Oh strange, "Missing separate debuginfo for " message was ignored! commit f4a4898
But I removed it in: commit 904f5de
|
I closed the issue. test_gdb now ignores stderr in all branches. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: