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

pdb docs need to contain a statement on threads/multithreaded debugging #67352

Open
krichter mannequin opened this issue Jan 4, 2015 · 7 comments
Open

pdb docs need to contain a statement on threads/multithreaded debugging #67352

krichter mannequin opened this issue Jan 4, 2015 · 7 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@krichter
Copy link
Mannequin

krichter mannequin commented Jan 4, 2015

BPO 23163
Nosy @blueyed, @xdegaye, @bharel, @pablogsal
Files
  • pdb_thread.py
  • 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 = None
    created_at = <Date 2015-01-04.10:21:23.812>
    labels = ['type-feature', 'library']
    title = 'pdb docs need to contain a statement on threads/multithreaded debugging'
    updated_at = <Date 2020-09-19.19:01:34.616>
    user = 'https://bugs.python.org/krichter'

    bugs.python.org fields:

    activity = <Date 2020-09-19.19:01:34.616>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2015-01-04.10:21:23.812>
    creator = 'krichter'
    dependencies = []
    files = ['37668']
    hgrepos = []
    issue_num = 23163
    keywords = []
    message_count = 7.0
    messages = ['233409', '233816', '233819', '233860', '233861', '286377', '376467']
    nosy_count = 6.0
    nosy_names = ['blueyed', 'xdegaye', 'krichter', 'bar.harel', 'Attila-Mihaly Balazs', 'pablogsal']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23163'
    versions = ['Python 3.5']

    @krichter
    Copy link
    Mannequin Author

    krichter mannequin commented Jan 4, 2015

    Due to the fact that pdb currently simply ignores breakpoints which are set and hit in another than the main thread the docs need to contain a statement on behavior in a multithreaded environment.

    @krichter krichter mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jan 4, 2015
    @xdegaye
    Copy link
    Mannequin

    xdegaye mannequin commented Jan 10, 2015

    pdb does not ignore breakpoints which are set and hit in a non-main thread.
    For example with the attached script:

    $ python pdb_thread.py
    > pdb_thread.py(5)foo()
    -> lineno = 5
    (Pdb) break 6
    Breakpoint 1 at pdb_thread.py:6
    (Pdb) continue
    > pdb_thread.py(6)foo()
    -> lineno = 6
    (Pdb) threading.current_thread().name
    'fooThread'
    (Pdb)

    @xdegaye
    Copy link
    Mannequin

    xdegaye mannequin commented Jan 10, 2015

    The pdb documentation could make an explicit reference to the documentation of sys.settrace() where it is explained that the function is thread specific.

    @krichter
    Copy link
    Mannequin Author

    krichter mannequin commented Jan 11, 2015

    My initial description was imprecise. Clearification: The fact that in

    #!/usr/bin/python
    
        import threading
    
        def debugging():
            def __a_thread__():
                print("2")
            a_thread = threading.Thread(target=__a_thread__)
            print("1")
    
        if __name__ == "__main__":
            debugging()

    when invoked with python -m pdb the breakpoint at line 7 is ignored, like in

        $ python -m pdb multithreaded_debugging.py 
        > /mnt/DATA/richter/examples/python/multithreaded_debugging/multithreaded_debugging.py(3)<module>()
        -> import threading
        (Pdb) break 7
        Breakpoint 1 at /mnt/DATA/richter/examples/python/multithreaded_debugging/multithreaded_debugging.py:7
        (Pdb) c
        1
        The program finished and will be restarted
        > /mnt/DATA/richter/examples/python/multithreaded_debugging/multithreaded_debugging.py(3)<module>()
        -> import threading
        (Pdb)

    @krichter
    Copy link
    Mannequin Author

    krichter mannequin commented Jan 11, 2015

    Sorry, I mean

    #!/usr/bin/python
    
        import threading
    
        def debugging():
            def __a_thread__():
                print("2")
            a_thread = threading.Thread(target=__a_thread__)
            a_thread.start()
            a_thread.join()
            print("1")
    
        if __name__ == "__main__":
            debugging()

    It's very uncommon to set the current debugging thread in the source.

    @Attila-MihalyBalazs
    Copy link
    Mannequin

    Attila-MihalyBalazs mannequin commented Jan 27, 2017

    Absolutely this. While it is good that there is at least some documentation (at sys.settrace), it is not very explicit nor is it self evident that one should look there (for example the PDB docs don't even mention settrace).

    @pablogsal
    Copy link
    Member

    See also https://bugs.python.org/issue41571

    @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
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    Status: No status
    Development

    No branches or pull requests

    1 participant