Search code examples
c#python.netvisual-studiovisual-studio-debugging

Mixed mode Debugging Python/C# using Child Process Debugging Power Tool


I'm trying to debug (hit breakpoint) a python script which is executed through a new process from C#.

I have installed Child Process Debugging Power tool as that tool supposedly allows one to do that.

According to its documentation it requires two things:

  1. The parent process must be debugged with the native debugging enigne
  2. The parent process must launch the child process using either the CreateProcess or CreateProcessAsUser Win32 APIs.

My process is created as follows:

ProcessStartInfo startInfo = new ProcessStartInfo();
Process p = new Process();

startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = false;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardInput = false;
...
p.StartInfo = startInfo;
p.EnableRaisingEvents = true;
p.Start();

And as far as I am aware, as long as I use

UseShellExecute = false; 

the process should be started with CreateProcess. (Req. 2)

In my project I have also enabled native code debugging. (Req.1)

I have also included both python.pdb and python36.pdb in my symbols list. However it seems I'm unable to find python3.pdb

'python.exe' (Win32): Loaded 'C:\...\Python36\python.exe'. Symbols loaded.
'python.exe' (Win32): Loaded 'C:\...\Python36\python36.dll'. Symbols loaded.
'python.exe' (Win32): Loaded 'C:\...\python3.dll'. Cannot find or open the PDB file.

This was not included when I installed python with debugging symbols and I do not seem to find it anywhere else.

I am using visual studio 2017, no breakpoints are hit.


Solution

  • Just a quick update if anyone stumbles over this post.

    I contacted the creators of this tool, and even though its description may indicate that what im trying to do here should work, it does not.

    The person i talked to said he would discuss this with his python team but i have now not heard anything for a couple of months so I assume it's not going to happen any time soon.