Skip to content

Commit e56a123

Browse files
authored
bpo-37362: test_gdb now ignores stderr (GH-14287)
test_gdb no longer fails if it gets an "unexpected" message on stderr: it now ignores stderr. The purpose of test_gdb is to test that python-gdb.py commands work as expected, not to test gdb.
1 parent 8b2aa1f commit e56a123

2 files changed

Lines changed: 16 additions & 34 deletions

File tree

Lib/test/test_gdb.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -214,43 +214,22 @@ def get_stack_trace(self, source=None, script=None,
214214
elif script:
215215
args += [script]
216216

217-
# print args
218-
# print (' '.join(args))
219-
220217
# Use "args" to invoke gdb, capturing stdout, stderr:
221218
out, err = run_gdb(*args, PYTHONHASHSEED=PYTHONHASHSEED)
222219

223-
errlines = err.splitlines()
224-
unexpected_errlines = []
225-
226-
# Ignore some benign messages on stderr.
227-
ignore_patterns = (
228-
'Function "%s" not defined.' % breakpoint,
229-
'Do you need "set solib-search-path" or '
230-
'"set sysroot"?',
231-
# BFD: /usr/lib/debug/(...): unable to initialize decompress
232-
# status for section .debug_aranges
233-
'BFD: ',
234-
# ignore all warnings
235-
'warning: ',
236-
)
237-
for line in errlines:
238-
if not line:
239-
continue
240-
# bpo34007: Sometimes some versions of the shared libraries that
241-
# are part of the traceback are compiled in optimised mode and the
242-
# Program Counter (PC) is not present, not allowing gdb to walk the
243-
# frames back. When this happens, the Python bindings of gdb raise
244-
# an exception, making the test impossible to succeed.
245-
if "PC not saved" in line:
246-
raise unittest.SkipTest("gdb cannot walk the frame object"
247-
" because the Program Counter is"
248-
" not present")
249-
if not line.startswith(ignore_patterns):
250-
unexpected_errlines.append(line)
251-
252-
# Ensure no unexpected error messages:
253-
self.assertEqual(unexpected_errlines, [])
220+
for line in err.splitlines():
221+
print(line, file=sys.stderr)
222+
223+
# bpo-34007: Sometimes some versions of the shared libraries that
224+
# are part of the traceback are compiled in optimised mode and the
225+
# Program Counter (PC) is not present, not allowing gdb to walk the
226+
# frames back. When this happens, the Python bindings of gdb raise
227+
# an exception, making the test impossible to succeed.
228+
if "PC not saved" in err:
229+
raise unittest.SkipTest("gdb cannot walk the frame object"
230+
" because the Program Counter is"
231+
" not present")
232+
254233
return out
255234

256235
def get_gdb_repr(self, source,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test_gdb no longer fails if it gets an "unexpected" message on stderr: it now
2+
ignores stderr. The purpose of test_gdb is to test that python-gdb.py commands
3+
work as expected, not to test gdb.

0 commit comments

Comments
 (0)