homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_gdb can fail with compiler opts
Type: behavior Stage: commit review
Components: Demos and Tools, Tests Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: dmalcolm Nosy List: dmalcolm, loewis, pitrou, vstinner
Priority: normal Keywords: patch

Created on 2010年05月03日 16:14 by pitrou, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
gdbopts.patch pitrou, 2010年05月05日 19:09
Messages (8)
msg104852 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010年05月03日 16:14
I now get the following failures in test_gdb:
======================================================================
FAIL: test_pyup_command (test.test_gdb.StackNavigationTests)
Verify that the "py-up" command works
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 599, in test_pyup_command
 $''')
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 163, in assertMultilineMatches
 msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 at 0x4508a0: file Objects/object.c, line 330.\n\nBreakpoint 1, PyObject_Print (op=42, fp=0x7ffff7535780, flags=1) at Objects/object.c:330\n330\t\treturn internal_print(op, fp, flags, 0);\n#7 (unable to read python frame information)\n' did not match '^.*\n#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \\(a=1, b=2, c=3\\)\n baz\\(a, b, c\\)\n$'
======================================================================
FAIL: test_up_at_top (test.test_gdb.StackNavigationTests)
Verify handling of "py-up" at the top of the stack
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 613, in test_up_at_top
 cmds_after_breakpoint=['py-up'] * 4)
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 129, in get_stack_trace
 self.assertEquals(err, '')
AssertionError: 'Error occurred in Python command.\nError occurred in Python command.\n' != ''
======================================================================
FAIL: test_up_then_down (test.test_gdb.StackNavigationTests)
Verify "py-up" followed by "py-down"
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 628, in test_up_then_down
 $''')
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 163, in assertMultilineMatches
 msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 at 0x4508a0: file Objects/object.c, line 330.\n\nBreakpoint 1, PyObject_Print (op=42, fp=0x7ffff7535780, flags=1) at Objects/object.c:330\n330\t\treturn internal_print(op, fp, flags, 0);\n#7 (unable to read python frame information)\n#3 Frame 0x805700, for file /home/antoine/cpython/__svn__/Lib/test/gdb_sample.py, line 10, in baz (args=(1, 2, 3))\n print(42)\n' did not match '^.*\n#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \\(a=1, b=2, c=3\\)\n baz\\(a, b, c\\)\n#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \\(args=\\(1, 2, 3\\)\\)\n print\\(42\\)\n$'
======================================================================
FAIL: test_basic_command (test.test_gdb.PyBtTests)
Verify that the "py-bt" command works
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 634, in test_basic_command
 cmds_after_breakpoint=['py-bt'])
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 129, in get_stack_trace
 self.assertEquals(err, '')
AssertionError: 'Error occurred in Python command.\n' != ''
======================================================================
FAIL: test_print_after_up (test.test_gdb.PyPrintTests)
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 658, in test_print_after_up
 r".*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*")
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 163, in assertMultilineMatches
 msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 at 0x4508a0: file Objects/object.c, line 330.\n\nBreakpoint 1, PyObject_Print (op=42, fp=0x7ffff7535780, flags=1) at Objects/object.c:330\n330\t\treturn internal_print(op, fp, flags, 0);\n#7 (unable to read python frame information)\nUnable to read information on python frame\nUnable to read information on python frame\nUnable to read information on python frame\n' did not match ".*\\nlocal 'c' = 3\\nlocal 'b' = 2\\nlocal 'a' = 1\\n.*"
======================================================================
FAIL: test_locals_after_up (test.test_gdb.PyLocalsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 684, in test_locals_after_up
 r".*\na = 1\nb = 2\nc = 3\n.*")
 File "/home/antoine/cpython/__svn__/Lib/test/test_gdb.py", line 163, in assertMultilineMatches
 msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 at 0x4508a0: file Objects/object.c, line 330.\n\nBreakpoint 1, PyObject_Print (op=42, fp=0x7ffff7535780, flags=1) at Objects/object.c:330\n330\t\treturn internal_print(op, fp, flags, 0);\n#7 (unable to read python frame information)\nUnable to read information on python frame\n' did not match '.*\\na = 1\\nb = 2\\nc = 3\\n.*'
----------------------------------------------------------------------
Basically, it seems the Python API for gdb is a bit unstable or changing. Here is what manually trying the new commands produces:
(gdb) py-bt 
#4 (unable to read python frame information)
Traceback (most recent call last):
 File "/home/antoine/cpython/__svn__/python-gdb.py", line 1341, in invoke
 frame.print_summary()
 File "/home/antoine/cpython/__svn__/python-gdb.py", line 1195, in print_summary
 pyop = self.get_pyop()
 File "/home/antoine/cpython/__svn__/python-gdb.py", line 1168, in get_pyop
 return PyFrameObjectPtr.from_pyobject_ptr(f)
 File "/home/antoine/cpython/__svn__/python-gdb.py", line 349, in from_pyobject_ptr
 return cls(gdbval)
TypeError: __init__() takes exactly 3 arguments (2 given)
Error occurred in Python command.
(gdb) py-up 
Traceback (most recent call last):
 File "/home/antoine/cpython/__svn__/python-gdb.py", line 1309, in invoke
 move_in_stack(move_up=True)
 File "/home/antoine/cpython/__svn__/python-gdb.py", line 1289, in move_in_stack
 iter_frame.print_summary()
 File "/home/antoine/cpython/__svn__/python-gdb.py", line 1195, in print_summary
 pyop = self.get_pyop()
 File "/home/antoine/cpython/__svn__/python-gdb.py", line 1168, in get_pyop
 return PyFrameObjectPtr.from_pyobject_ptr(f)
 File "/home/antoine/cpython/__svn__/python-gdb.py", line 349, in from_pyobject_ptr
 return cls(gdbval)
TypeError: __init__() takes exactly 3 arguments (2 given)
Error occurred in Python command.
$ gdb --version
GNU gdb (GDB) 7.1-1mdv2010.1 (Mandriva Linux release 2010.1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-mandriva-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
msg104868 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010年05月03日 19:21
See #8482 for the "Unable to read information on python frame" issue.
msg105069 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010年05月05日 18:51
My intuition about an API problem seems to be mistaken. If I compile Python in debug mode without any optimizations ("CFLAGS='' ./configure --with-pydebug"), all tests pass. The default builds of Python use -O2 nowadays, even in debug mode (issue8625), which makes some of the tests fail.
Perhaps test_gdb, or some of its tests, should be skipped when compiler optimizations were enabled. Now we have to find out how to get that information.
msg105075 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010年05月05日 19:09
Here is a patch which skips test_gdb when Python was built with something else than -O0.
msg109424 - (view) Author: Dave Malcolm (dmalcolm) (Python committer) Date: 2010年07月06日 20:34
Thanks. The patch looks good to me, and appears to also fix issue 8482 and issue 9163: compiler optimization across all different compilers and configurations can somewhat arbitrarily break the ability for the debugger to work, and skipping the test in the face of optimization seems the sanest course of action.
Minor nit: given that final_opt is set to "" at the start of the loop, the first conditional in:
 if final_opt and final_opt != '-O0':
appears to be redundant.
Setting "Stage" to "commit review" - I'd commit it (modulo the above nit), but I don't have rights to do so; looking for a committer to review this.
msg109472 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010年07月07日 13:09
> Minor nit: given that final_opt is set to "" at the start of the loop, > the first conditional in:
> if final_opt and final_opt != '-O0':
> appears to be redundant.
I don't think it is (the empty string is false, but "" != "-O0" is true).
msg109478 - (view) Author: Dave Malcolm (dmalcolm) (Python committer) Date: 2010年07月07日 14:26
Oops, my bad. Patch looks good as is.
msg109567 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010年07月08日 18:54
Patch committed in 82647 (3.2) and 82648 (2.7). Thanks!
History
Date User Action Args
2022年04月11日 14:57:00adminsetgithub: 52851
2010年07月08日 18:54:43pitrousetstatus: open -> closed
resolution: fixed
messages: + msg109567
2010年07月07日 14:26:17dmalcolmsetmessages: + msg109478
2010年07月07日 13:09:04pitrousetnosy: + loewis
messages: + msg109472
2010年07月06日 20:34:27dmalcolmsetmessages: + msg109424
stage: needs patch -> commit review
2010年05月05日 19:09:56pitrousetfiles: + gdbopts.patch
keywords: + patch
messages: + msg105075

title: gdb API issues -> test_gdb can fail with compiler opts
2010年05月05日 18:51:07pitrousetmessages: + msg105069
2010年05月03日 19:21:32vstinnersetnosy: + vstinner
messages: + msg104868
2010年05月03日 16:14:51pitroucreate

AltStyle によって変換されたページ (->オリジナル) /