Skip to content

Breakpoint and Step Over with multithreading #515

Closed

Description

@pub-pub

there's an issue with debugging python code that utilizes multithreading.
i set a breakpoint, start debugging, execution pauses as expected, but when i press 'Step Over' (F10) debugger does not go to the next expression (line) in the current thread, but jumps to some random locations in other running threads, and i have to 'Step Over' again and again until i return to my current thread.

'Step Over' feature must be limited the current (paused) thread.

the same issue was reported for Visual Studio a couple of years ago https://developercommunity.visualstudio.com/t/make-the-debugger-stick-to-the-current-thread-inst/351390

Activity

  1. added
    triage-needed
    on Dec 9, 2024
  2. karthiknadig commented on Dec 9, 2024

    @karthiknadig
    Member

    pub-pub in debugpy the library there is a setting for this. Try adding this to the launch config: "steppingResumesAllThreads": false

  3. pub-pub commented on Dec 9, 2024

    @pub-pub
    Author

    @pub-pub in debugpy the library there is a setting for this. Try adding this to the launch config: "steppingResumesAllThreads": false

    thanks a lot, Karthik Nadig (@karthiknadig)
    it's working great

    but i had to hardcode False into pydevd_process_net_command_json.py because i don't know where exactly i should put "steppingResumesAllThreads": false in launch.json. can you, please, explain it to me?

    and one more thing: maybe there's also a parameter that keeps me Stepping Over inside my thread without pausing all other threads?

  4. karthiknadig commented on Dec 9, 2024

    @karthiknadig
    Member

    maybe there's also a parameter that keeps me Stepping Over inside my thread without pausing all other threads?

    pub-pub debugpy has lot more control over this, but I am not sure if there is a stop only current option yet. This might be a feature request on debugpy. You can ask for it here https://github.com/microsoft/debugpy

  5. karthiknadig commented on Dec 9, 2024

    @karthiknadig
    Member

    but i had to hardcode False into pydevd_process_net_command_json.py because i don't know where exactly i should put "steppingResumesAllThreads": false in launch.json. can you, please, explain it to me?

           {
                "name": "Python Debugger: Current File",
                "type": "debugpy",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal",
                "steppingResumesAllThreads": false
            }
    

    Even though it has the yellow line it should work.

  6. maor-outrival commented on Mar 19, 2025

    @maor-outrival

    Karthik Nadig (@karthiknadig) the same thing happens in a subprocess and using "steppingResumesAllThreads": false doesn't work. Any suggestions there?

  7. karthiknadig commented on Mar 19, 2025

    @karthiknadig
    Member

    Rich Chiodo (@rchiodo) Can you help with above?

    Maor Azoulay (@maor-outrival) Each subprocess is a separate debugger session but still a sub-session. I don't think this is supported by debugpy.

  8. rchiodo commented on Mar 19, 2025

    @rchiodo
    Contributor

    This should have been fixed. It was a bug in debugpy in 3.12 and above. The jumping between threads when stepping that is.

    What's your version of debugpy (or debugger extension)? Debugpy 1.8.12 should have the fix for this.

    See this debugpy bug:
    microsoft/debugpy#1765

  9. maor-outrival commented on Mar 19, 2025

    @maor-outrival

    Karthik Nadig (@karthiknadig) You are correct that it's a separate debugger but that behavior is not what is expected even from a separate debugger.

    I finally figured it out for a subprocess. It is a bug with the current version in debugpy, other users reported it as well.
    Downgrading to 2024.10.0 solved the issue.

  10. rchiodo commented on Mar 19, 2025

    @rchiodo
    Contributor

    It is a bug with the current version in debugpy, other users reported it as well. Downgrading to 2024.10.0 solved the issue.

    Which bug? This should be fixed in our latest bits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions