Skip to content
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

libpython.py: nicer py-bt output #56205

Closed
vstinner opened this issue May 4, 2011 · 4 comments
Closed

libpython.py: nicer py-bt output #56205

vstinner opened this issue May 4, 2011 · 4 comments

Comments

@vstinner
Copy link
Member

vstinner commented May 4, 2011

BPO 11996
Nosy @vstinner, @davidmalcolm
Files
  • gdb.patch
  • 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:

    assignee = None
    closed_at = <Date 2011-05-13.16:09:44.187>
    created_at = <Date 2011-05-04.09:08:15.101>
    labels = []
    title = 'libpython.py: nicer py-bt output'
    updated_at = <Date 2011-05-13.16:09:44.186>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2011-05-13.16:09:44.186>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-05-13.16:09:44.187>
    closer = 'vstinner'
    components = ['Demos and Tools']
    creation = <Date 2011-05-04.09:08:15.101>
    creator = 'vstinner'
    dependencies = []
    files = ['21878']
    hgrepos = []
    issue_num = 11996
    keywords = ['patch']
    message_count = 4.0
    messages = ['135102', '135103', '135921', '135922']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'dmalcolm', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue11996'
    versions = ['Python 3.3']

    @vstinner
    Copy link
    Member Author

    vstinner commented May 4, 2011

    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

    @vstinner
    Copy link
    Member Author

    vstinner commented May 4, 2011

    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
    -------------------

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 13, 2011

    New changeset b340d1577dc5 by Victor Stinner in branch '3.2':
    Issue bpo-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 bpo-11996: libpython (gdb), replace "py-bt" command by
    http://hg.python.org/cpython/rev/804abc2c60de

    @vstinner
    Copy link
    Member Author

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant