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
Enhancements to gdb 7 debugging hooks #56814
Comments
I'm attaching patches to handle some more "events" in the gdb7 debugging hooks for CPython (aka Tools/gdb/libpython.py). Currently, the hooks only care about C frames that are the bytecode interpreter (i.e. PyEval_EvalFrameEx) This patch changes this, dividing C frames into:
so that the "py-bt", "py-up" and "py-down" commands will now work on the other kinds of "python" frames, in addition to the bytecode frames. Specifically, the following new kinds of C frame are displayed:
This should assist when debugging multithreaded crashes, to more easily get a sense of what every thread is doing. Examples: (gdb) py-bt-full Showing an invocation of "time.sleep()": Showing multiple threads, where all but one are waiting for the GIL: Thread 5 (Thread 0x7fffeb5fe700 (LWP 10716)):
Traceback (most recent call first):
Waiting for the GIL
File "<string>", line 10, in run
File "/home/david/coding/python-hg/cpython-more-gdb/build-debug/../Lib/threading.py", line 737, in _bootstrap_inner
self.run()
File "/home/david/coding/python-hg/cpython-more-gdb/build-debug/../Lib/threading.py", line 710, in _bootstrap
self._bootstrap_inner()
Thread 4 (Thread 0x7fffebfff700 (LWP 10715)):
Traceback (most recent call first):
Waiting for the GIL
File "<string>", line 10, in run
File "/home/david/coding/python-hg/cpython-more-gdb/build-debug/../Lib/threading.py", line 737, in _bootstrap_inner
self.run()
File "/home/david/coding/python-hg/cpython-more-gdb/build-debug/../Lib/threading.py", line 710, in _bootstrap
self._bootstrap_inner()
Thread 3 (Thread 0x7ffff0dea700 (LWP 10714)):
Traceback (most recent call first):
Waiting for the GIL
File "<string>", line 10, in run
File "/home/david/coding/python-hg/cpython-more-gdb/build-debug/../Lib/threading.py", line 737, in _bootstrap_inner
self.run()
File "/home/david/coding/python-hg/cpython-more-gdb/build-debug/../Lib/threading.py", line 710, in _bootstrap
self._bootstrap_inner()
Thread 2 (Thread 0x7ffff17eb700 (LWP 10713)):
Traceback (most recent call first):
Waiting for the GIL
File "<string>", line 10, in run
File "/home/david/coding/python-hg/cpython-more-gdb/build-debug/../Lib/threading.py", line 737, in _bootstrap_inner
self.run()
File "/home/david/coding/python-hg/cpython-more-gdb/build-debug/../Lib/threading.py", line 710, in _bootstrap
self._bootstrap_inner()
Thread 1 (Thread 0x7ffff7fdb700 (LWP 10709)):
Traceback (most recent call first):
File "<string>", line 18, in <module> |
(On 2.7, I needed import_site=True to get the new tests to work from a fresh build: "import time" wasn't being found otherwise) |
The improvements are welcome, but I'm not sure they're ok for 3.2 or 2.7, since they're technically a new feature. |
Better debuggability FTW! This is an update to Tools/gdb/ as such I'd like to see this make it into 3.3. It doesn't touch the runtime or stdlib so I personally wouldn't consider this "adding a feature" and thus preventing its inclusion with 3.3 despite the beta process having started. It'd the release manager's call. I'm bumping to release blocker for a decision from Georg. :) |
I'm +1 on adding this in general, +0 on adding this to 3.3, and -0 on adding it to 2.7 right away. I agree that the usual reasoning against new features doesn't apply here, since it's not a new Python (language or library) feature. However, one concern is that it is a large change, and I predict that it will introduce some breakage regardless of what amount of code review goes into it. If the breakage can be detected during the betas, fine, but we need to consider that it may cause breakage of the entire python-gdb feature for some people after the release (which probably wouldn't be that terrible). Hence the +0 for 3.3. For 2.7, it should only be added if it has survived in a prerelease branch for some time, hence the -0. |
Agreed with Martin, can't say I'm +1 on 3.3 either. But I've just reviewed the patch, and it looks correct to me, so go ahead and I'll take the blame. |
Got the following error on Mageia 1: ====================================================================== Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/test/test_gdb.py", line 697, in test_threads
cmds_after_breakpoint=['thread apply all py-bt'])
File "/home/antoine/cpython/default/Lib/test/test_gdb.py", line 153, in get_stack_trace
self.assertEqual(err, '')
AssertionError: "Error occurred in Python command: 'NoneType' object has no attribute 'startswit [truncated]... != ''
- Error occurred in Python command: 'NoneType' object has no attribute 'startswith' |
I believe this was due to this line: I've changed it to: I've also bulletproofed against the --without-threads case by simply Tested successfully on a Fedora 15 x86_64 box (gdb-7.3-43.fc15.x86_64)
(Note that because of issue bpo-14774 I have to regenerate |
New changeset abcd29c9a791 by David Malcolm in branch 'default': |
Dave, test_gdb fails consistently on the ARM buildbot: ====================================================================== Traceback (most recent call last):
File "/var/lib/buildbot/buildarea/3.x.warsaw-ubuntu-arm/build/Lib/test/test_gdb.py", line 706, in test_threads
self.assertIn('Waiting for the GIL', gdb_output)
AssertionError: 'Waiting for the GIL' not found in 'Breakpoint 1 at 0x9e36a: file Python/bltinmodule.c, line 962.\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library "/lib/arm-linux-gnueabi/libthread_db.so.1".\n[New Thread 0x2b2b2470 (LWP 8779)]\n[New Thread 0x2b5ff470 (LWP 8780)]\n[New Thread 0x2b8ff470 (LWP 8781)]\n[New Thread 0x2baff470 (LWP 8782)]\n\nBreakpoint 1, builtin_id (self=<module at remote 0x2aca5638>, v=42) at Python/bltinmodule.c:962\n962\t return PyLong_FromVoidPtr(v);\n\nThread 5 (Thread 0x2baff470 (LWP 8782)):\nTraceback (most recent call first):\n File "<string>", line 10, in run\n File "/var/lib/buildbot/buildarea/3.x.warsaw-ubuntu-arm/build/Lib/threading.py", line 639, in _bootstrap_inner\n self.run()\n File "/var/lib/buildbot/buildarea/3.x.warsaw-ubuntu-arm/build/Lib/threading.py", line 616, in _bootstrap\n self._bootstrap_inner()\n\nThread 4 (Thread 0x2b8ff470 (LWP 8781)):\nTraceback (most recent call first):\n File "<string>", line 10, in run\n File "/var/lib/buildbot/buildarea/3.x.warsaw-ubuntu-arm/build/Lib/threading.py", line 639, in _bootstrap_inner\n self.run()\n File "/var/lib/buildbot/buildarea/3.x.warsaw-ubuntu-arm/build/Lib/threading.py", line 616, in _bootstrap\n self._bootstrap_inner()\n\nThread 3 (Thread 0x2b5ff470 (LWP 8780)):\nTraceback (most recent call first):\n File "<string>", line 10, in run\n File "/var/lib/buildbot/buildarea/3.x.warsaw-ubuntu-arm/build/Lib/threading.py", line 639, in _bootstrap_inner\n self.run()\n File "/var/lib/buildbot/buildarea/3.x.warsaw-ubuntu-arm/build/Lib/threading.py", line 616, in _bootstrap\n self._bootstrap_inner()\n\nThread 2 (Thread 0x2b2b2470 (LWP 8779)):\nTraceback (most recent call first):\n File "<string>", line 10, in run\n File "/var/lib/buildbot/buildarea/3.x.warsaw-ubuntu-arm/build/Lib/threading.py", line 639, in _bootstrap_inner\n self.run()\n File "/var/lib/buildbot/buildarea/3.x.warsaw-ubuntu-arm/build/Lib/threading.py", line 616, in _bootstrap\n self._bootstrap_inner()\n\nThread 1 (Thread 0x2aac5300 (LWP 8776)):\nTraceback (most recent call first):\n File "<string>", line 18, in <module>\n' |
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: