Re: Debugging of native extensions on windows

Steve Dower <[email protected]> Tue, 14 Mar 2023 21:10:35 +0000
Newsgroups gmane.comp.python.devel
Message-ID <[email protected]>
On 3/14/2023 7:13 AM, Rokas Kupstys wrote:
 > Still, i think there can be an improvement in this area, and it would
 > likely be quite cheap. The biggest problem is people being unaware what
 > is going on. IsDebuggerPresent()/CheckRemoteDebuggerPresent() could be
 > used for checking debugger presence and when debugging state of main
 > process and child process do not match, launcher could print some link
 > to documentation describing what is going on and how situation could be
 > solved. I am just not sure about any possible race conditions (no idea
 > how fast debuggers attack to child processes).

Detecting when a debugger is attached and printing a debug message on 
exit from the launcher might be a neat idea. Care to submit a bug at 
https://github.com/python/cpython?

The change would likely have to go into PC\launcher.c (for venvs) as 
well as PC\launcher2.c right now (for py.exe).

Native debuggers usually hook process creation, so they should attach 
immediately with no risk of missing anything.

Cheers,
Steve