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: libpython.py: nicer py-bt output
Type: Stage:
Components: Demos and Tools Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: dmalcolm, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2011-05-04 09:08 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
gdb.patch vstinner, 2011-05-04 09:08 review
Messages (4)
msg135102 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-04 09:08
py-bt is too much verbose, I'm unable to read it.

Example:
--------------------
$ gdb -args ./python -c 'import time, threading; threading.Thread(target=lambda:time.sleep(3)).start()'
...
[New Thread 0x7ffff69d9700 (LWP 17193)]
^C
Program received signal SIGINT, Interrupt.
sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:86
86	../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Aucun fichier ou dossier de ce type.
	in ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
(gdb) py-bt
#6 Frame 0xc52620, for file /home/haypo/prog/HG/cpython/Lib/threading.py, line 237, in wait (self=<_Condition(release=<built-in method release of _thread.lock object at remote 0xc1f1e0>, acquire=<built-in method acquire of _thread.lock object at remote 0xc1f1e0>, _lock=<_thread.lock at remote 0xc1f1e0>, _waiters=[<_thread.lock at remote 0xafb590>], _verbose=False) at remote 0xc1cbe0>, timeout=None, waiter=<_thread.lock at remote 0xafb590>, saved_state=None)
                waiter.acquire()
#10 Frame 0xbbb580, for file /home/haypo/prog/HG/cpython/Lib/threading.py, line 851, in join (self=<Thread(_target=<function at remote 0xbb5d30>, _block=<_Condition(release=<built-in method release of _thread.lock object at remote 0xc1f1e0>, acquire=<built-in method acquire of _thread.lock object at remote 0xc1f1e0>, _lock=<_thread.lock at remote 0xc1f1e0>, _waiters=[<_thread.lock at remote 0xafb590>], _verbose=False) at remote 0xc1cbe0>, _args=(), _initialized=True, _name='Thread-1', _daemonic=False, _kwargs={}, _stderr=<_io.TextIOWrapper at remote 0xac15a0>, _ident=140737330910976, _started=<_Event(_flag=True, _cond=<_Condition(release=<built-in method release of _thread.lock object at remote 0xad7e00>, acquire=<built-in method acquire of _thread.lock object at remote 0xad7e00>, _lock=<_thread.lock at remote 0xad7e00>, _waiters=[], _verbose=False) at remote 0xc1ce40>, _verbose=False) at remote 0xaec980>, _stopped=False, _verbose=False) at remote 0xc2fb70>, timeout=None)
                    self._block.wait()
#14 Frame 0xc42eb0, for file /home/haypo/prog/HG/cpython/Lib/threading.py, line 965, in _exitfunc (self=<_MainThread(_target=None, _block=<_Condition(release=<built-in method release of _thread.lock object at remote 0xc66290>, acquire=<built-in method acquire of _thread.lock object at remote 0xc66290>, _lock=<_thread.lock at remote 0xc66290>, _waiters=[], _verbose=False) at remote 0xc66110>, _args=(), _initialized=True, _name='MainThread', _daemonic=False, _kwargs={}, _stderr=<_io.TextIOWrapper at remote 0xac15a0>, _ident=140737353987840, _started=<_Event(_flag=True, _cond=<_Condition(release=<built-in method release of _thread.lock object at remote 0xc62fe0>, acquire=<built-in method acquire of _thread.lock object at remote 0xc62fe0>, _lock=<_thread.lock at remote 0xc62fe0>, _waiters=[], _verbose=False) at remote 0xc65d20>, _verbose=False) at remote 0xc65840>, _stopped=True, _verbose=False) at remote 0xc64c90>, t=<Thread(_target=<function at remote 0xbb5d30>, _block=<_Condition(release=<built-in method release o...(truncated)
            t.join()
--------------------

Attached patch uses a syntax closer to classic Python tracebacks:
--------------------
$ gdb -args ./python -c 'import time, threading; (gdb) run
...
[New Thread 0x7ffff69d9700 (LWP 17193)]
^C
Program received signal SIGINT, Interrupt.
sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:86
86	../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Aucun fichier ou dossier de ce type.
	in ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
(gdb) py-bt
Traceback (most recent call first):
  File "/home/haypo/prog/HG/cpython/Lib/threading.py", line 237, in wait
  File "/home/haypo/prog/HG/cpython/Lib/threading.py", line 851, in join
  File "/home/haypo/prog/HG/cpython/Lib/threading.py", line 965, in _exitfunc
(gdb) info threads
  2 Thread 0x7ffff69d9700 (LWP 17193)  0x00007ffff72a0c73 in select () at ../sysdeps/unix/syscall-template.S:82
* 1 Thread 0x7ffff7fdb700 (LWP 17190)  sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:86
(gdb) thread 2
[Switching to thread 2 (Thread 0x7ffff69d9700 (LWP 17193))]#0  0x00007ffff72a0c73 in select ()
    at ../sysdeps/unix/syscall-template.S:82
82	../sysdeps/unix/syscall-template.S: Aucun fichier ou dossier de ce type.
	in ../sysdeps/unix/syscall-template.S
(gdb) py-bt
Traceback (most recent call first):
  File "<string>", line 1, in <lambda>
  File "/home/haypo/prog/HG/cpython/Lib/threading.py", line 690, in run
  File "/home/haypo/prog/HG/cpython/Lib/threading.py", line 737, in _bootstrap_inner
  File "/home/haypo/prog/HG/cpython/Lib/threading.py", line 710, in _bootstrap
--------------------
msg135103 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-04 09:11
I would also like a less verbose output for where, especially be able to hidden the value of the globals argument of PyEval_EvalCodeEx.

Example of where output:
-------------------
(gdb) where
#0  sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:86
#1  0x00000000004d5ff5 in PyThread_acquire_lock_timed (lock=0xc3bc50, microseconds=-1, intr_flag=1)
    at Python/thread_pthread.h:333
#2  0x00000000004db97e in acquire_timed (lock=0xc3bc50, microseconds=-1) at ./Modules/_threadmodule.c:66
#3  0x00000000004dbbc5 in lock_PyThread_acquire_lock (self=0xafb590, args=(), kwds=0x0) at ./Modules/_threadmodule.c:133
#4  0x00000000005931d6 in PyCFunction_Call (func=<built-in method acquire of _thread.lock object at remote 0xafb590>, arg=(), 
    kw=0x0) at Objects/methodobject.c:84
#5  0x0000000000489c6d in call_function (pp_stack=0x7fffffffb738, oparg=0) at Python/ceval.c:3859
#6  0x0000000000484791 in PyEval_EvalFrameEx (f=
    Frame 0xc52620, for file /home/haypo/prog/HG/cpython/Lib/threading.py, line 237, in wait (self=<_Condition(release=<built-in method release of _thread.lock object at remote 0xc1f1e0>, acquire=<built-in method acquire of _thread.lock object at remote 0xc1f1e0>, _lock=<_thread.lock at remote 0xc1f1e0>, _waiters=[<_thread.lock at remote 0xafb590>], _verbose=False) at remote 0xc1cbe0>, timeout=None, waiter=<_thread.lock at remote 0xafb590>, saved_state=None), throwflag=0) at Python/ceval.c:2657
#7  0x0000000000487db4 in PyEval_EvalCodeEx (_co=<code at remote 0xc32cd0>, globals=
    {'current_thread': <function at remote 0xc64170>, '_BoundedSemaphore': <type at remote 0xc503d0>, '_Semaphore': <type at remote 0xc4fc50>, '_Timer': <type at remote 0xc62a90>, '_format_exc': <function at remote 0xb7ca70>, 'Semaphore': <function at remote 0xc553a0>, 'activeCount': <function at remote 0xc64a30>, '_profile_hook': None, '_sleep': <built-in method sleep of module object at remote 0xc25e70>, '_trace_hook': None, 'ThreadError': <type at remote 0x865c00>, '_enumerate': <function at remote 0xc64ad0>, '_start_new_thread': <built-in method start_new_thread of module object at remote 0xa97150>, '_CRLock': <type at remote 0x83df80>, 'BoundedSemaphore': <function at remote 0xc4e710>, 'currentThread': <function at remote 0xc64170>, '__all__': ['active_count', 'Condition', 'current_thread', 'enumerate', 'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', 'Barrier', 'Timer', 'setprofile', 'settrace', 'local', 'stack_size'], '_Event': <type at remote 0xc43300>, '_PyRLock': <type at remote 0xc4...(truncated), locals=0x0, args=0xbbb728, argcount=1, kws=0xbbb730, kwcount=0, defs=0xc4ec28, defcount=1, kwdefs=0x0, 
    closure=0x0) at Python/ceval.c:3295
#8  0x000000000048a26b in fast_function (func=<function at remote 0xc4eb60>, pp_stack=0x7fffffffc418, n=1, na=1, nk=0)
    at Python/ceval.c:3957
#9  0x0000000000489e43 in call_function (pp_stack=0x7fffffffc418, oparg=0) at Python/ceval.c:3880
#10 0x0000000000484791 in PyEval_EvalFrameEx (f=
    Frame 0xbbb580, for file /home/haypo/prog/HG/cpython/Lib/threading.py, line 851, in join (self=<Thread(_target=<function at remote 0xbb5d30>, _block=<_Condition(release=<built-in method release of _thread.lock object at remote 0xc1f1e0>, acquire=<built-in method acquire of _thread.lock object at remote 0xc1f1e0>, _lock=<_thread.lock at remote 0xc1f1e0>, _waiters=[<_thread.lock at remote 0xafb590>], _verbose=False) at remote 0xc1cbe0>, _args=(), _initialized=True, _name='Thread-1', _daemonic=False, _kwargs={}, _stderr=<_io.TextIOWrapper at remote 0xac15a0>, _ident=140737330910976, _started=<_Event(_flag=True, _cond=<_Condition(release=<built-in method release of _thread.lock object at remote 0xad7e00>, acquire=<built-in method acquire of _thread.lock object at remote 0xad7e00>, _lock=<_thread.lock at remote 0xad7e00>, _waiters=[], _verbose=False) at remote 0xc1ce40>, _verbose=False) at remote 0xaec980>, _stopped=False, _verbose=False) at remote 0xc2fb70>, timeout=None), throwflag=0) at Python/ceval.c:2657
#11 0x0000000000487db4 in PyEval_EvalCodeEx (_co=<code at remote 0xc282d0>, globals=
    {'current_thread': <function at remote 0xc64170>, '_BoundedSemaphore': <type at remote 0xc503d0>, '_Semaphore': <type at remote 0xc4fc50>, '_Timer': <type at remote 0xc62a90>, '_format_exc': <function at remote 0xb7ca70>, 'Semaphore': <function at remote 0xc553a0>, 'activeCount': <function at remote 0xc64a30>, '_profile_hook': None, '_sleep': <built-in method sleep of module object at remote 0xc25e70>, '_trace_hook': None, 'ThreadError': <type at remote 0x865c00>, '_enumerate': <function at remote 0xc64ad0>, '_start_new_thread': <built-in method start_new_thread of module object at remote 0xa97150>, '_CRLock': <type at remote 0x83df80>, 'BoundedSemaphore': <function at remote 0xc4e710>, 'currentThread': <function at remote 0xc64170>, '__all__': ['active_count', 'Condition', 'current_thread', 'enumerate', 'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', 'Barrier', 'Timer', 'setprofile', 'settrace', 'local', 'stack_size'], '_Event': <type at remote 0xc43300>, '_PyRLock': <type at remote 0xc4...(truncated), locals=0x0, args=0xc43048, argcount=1, kws=0xc43050, kwcount=0, defs=0xc457a8, defcount=1, kwdefs=0x0, 
    closure=0x0) at Python/ceval.c:3295
#12 0x000000000048a26b in fast_function (func=<function at remote 0xc61e00>, pp_stack=0x7fffffffd0f8, n=1, na=1, nk=0)
    at Python/ceval.c:3957
-------------------

Without python-gdb.py:
-------------------
(gdb) where
#0  sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:86
#1  0x00000000004d5ff5 in PyThread_acquire_lock_timed (lock=0xc3bc50, microseconds=-1, intr_flag=1)
    at Python/thread_pthread.h:333
#2  0x00000000004db97e in acquire_timed (lock=0xc3bc50, microseconds=-1) at ./Modules/_threadmodule.c:66
#3  0x00000000004dbbc5 in lock_PyThread_acquire_lock (self=0xafb590, args=0x8977a0, kwds=0x0) at ./Modules/_threadmodule.c:133
#4  0x00000000005931d6 in PyCFunction_Call (func=0xc670d0, arg=0x8977a0, kw=0x0) at Objects/methodobject.c:84
#5  0x0000000000489c6d in call_function (pp_stack=0x7fffffffb738, oparg=0) at Python/ceval.c:3859
#6  0x0000000000484791 in PyEval_EvalFrameEx (f=0xc52620, throwflag=0) at Python/ceval.c:2657
#7  0x0000000000487db4 in PyEval_EvalCodeEx (_co=0xc32cd0, globals=0xb86dd0, locals=0x0, args=0xbbb728, argcount=1, 
    kws=0xbbb730, kwcount=0, defs=0xc4ec28, defcount=1, kwdefs=0x0, closure=0x0) at Python/ceval.c:3295
#8  0x000000000048a26b in fast_function (func=0xc4eb60, pp_stack=0x7fffffffc418, n=1, na=1, nk=0) at Python/ceval.c:3957
#9  0x0000000000489e43 in call_function (pp_stack=0x7fffffffc418, oparg=0) at Python/ceval.c:3880
#10 0x0000000000484791 in PyEval_EvalFrameEx (f=0xbbb580, throwflag=0) at Python/ceval.c:2657
#11 0x0000000000487db4 in PyEval_EvalCodeEx (_co=0xc282d0, globals=0xb86dd0, locals=0x0, args=0xc43048, argcount=1, 
    kws=0xc43050, kwcount=0, defs=0xc457a8, defcount=1, kwdefs=0x0, closure=0x0) at Python/ceval.c:3295
#12 0x000000000048a26b in fast_function (func=0xc61e00, pp_stack=0x7fffffffd0f8, n=1, na=1, nk=0) at Python/ceval.c:3957
#13 0x0000000000489e43 in call_function (pp_stack=0x7fffffffd0f8, oparg=0) at Python/ceval.c:3880
#14 0x0000000000484791 in PyEval_EvalFrameEx (f=0xc42eb0, throwflag=0) at Python/ceval.c:2657
#15 0x0000000000487db4 in PyEval_EvalCodeEx (_co=0xc2f6b0, globals=0xb86dd0, locals=0x0, args=0xc2fe78, argcount=1, kws=0x0, 
    kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0) at Python/ceval.c:3295
#16 0x0000000000574aa5 in function_call (func=0xc63c70, arg=0xc2fe50, kw=0x0) at Objects/funcobject.c:629
#17 0x000000000053dd47 in PyObject_Call (func=0xc63c70, arg=0xc2fe50, kw=0x0) at Objects/abstract.c:2149
#18 0x000000000055a0ea in method_call (func=0xc63c70, arg=0xc2fe50, kw=0x0) at Objects/classobject.c:319
#19 0x000000000053dd47 in PyObject_Call (func=0xb0cde0, arg=0x8977a0, kw=0x0) at Objects/abstract.c:2149
#20 0x000000000053ded4 in call_function_tail (callable=0xb0cde0, args=0x8977a0) at Objects/abstract.c:2181
#21 0x000000000053e306 in PyObject_CallMethod (o=0xc52f40, name=0x5d57ba "_shutdown", format=0x5d4c3d "")
    at Objects/abstract.c:2258
#22 0x00000000004bfbc3 in wait_for_thread_shutdown () at Python/pythonrun.c:2208
#23 0x00000000004bad56 in Py_Finalize () at Python/pythonrun.c:386
#24 0x00000000004d92e9 in Py_Main (argc=3, argv=0x896010) at Modules/main.c:712
#25 0x0000000000419327 in main (argc=3, argv=0x7fffffffe1e8) at ./Modules/python.c:59
-------------------
msg135921 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-13 15:53
New changeset b340d1577dc5 by Victor Stinner in branch '3.2':
Issue #11996: libpython (gdb), replace "py-bt" command by "py-bt-full" and add
http://hg.python.org/cpython/rev/b340d1577dc5

New changeset 804abc2c60de by Victor Stinner in branch 'default':
(Merge 3.2) Issue #11996: libpython (gdb), replace "py-bt" command by
http://hg.python.org/cpython/rev/804abc2c60de
msg135922 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-13 16:09
Without any reaction from Dave Malcolm, I kept its name under the name "py-bt-full".

> I would also like a less verbose output for where, especially
> be able to hidden the value of the globals argument of
> PyEval_EvalCodeEx.

Well, I will maybe open a new issue for this one. But I consider that the work is done on this issue so I close it.
History
Date User Action Args
2022-04-11 14:57:16adminsetgithub: 56205
2011-05-13 16:09:44vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg135922
2011-05-13 15:53:27python-devsetnosy: + python-dev
messages: + msg135921
2011-05-04 09:11:15vstinnersetmessages: + msg135103
2011-05-04 09:08:15vstinnercreate