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.

Author pablogsal
Recipients pablogsal
Date 2020-08-18.03:08:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1597720104.88.0.241487518656.issue41571@roundup.psfhosted.org>
In-reply-to
Content
* Displaying all threads is trivial.

* Stopping all threads is trivial because of the GIL. When pdb runs in a thread all other threads cannot execute python code. They can execute native code bit there is not much we can do about it.

* Switching threads is the interesting one. The easiest way is to set the pdb trace function in the target thread and run until they thread executes python code. This has the following considerations:

  - All PSB commands will automatically work on that thread once the trace function is executed.
  - There will be a delay between the command and the thread being switched. This is due to the fact that we do not control what thread will run and we need to wait until the thread executes Python code.
  - Switching to a thread that is blocked on something (on a lock or on C code) will hang.

For this reason, this method can work only for setting breakpoints on threads, not for 'switching threads'. The breakpoint will work because that's the expected behaviour: the day and the possibility of not hitting it is justified on the nature of the breakpoint.

For switching threads, the best way would be to 'virtually switch threads'. This means that somehow we switch internally to the thread stack but we keep executing on the main thread, we merely switch our internal context.
History
Date User Action Args
2020-08-18 03:08:24pablogsalsetrecipients: + pablogsal
2020-08-18 03:08:24pablogsalsetmessageid: <1597720104.88.0.241487518656.issue41571@roundup.psfhosted.org>
2020-08-18 03:08:24pablogsallinkissue41571 messages
2020-08-18 03:08:24pablogsalcreate