My end goal is to debug a Python script which calls my own COM dll written in C++. Using Python 3.8, in MS Visual Studio Community 2019.
My main problem is debugging. MSVC is constantly asking for debug symbols for Python38.dll, and failing to hit breakpoints.
In my Python project, Debug Properties, if DO NOT check 'Enable Native Code Debugging', then my Python runs and stops correctly at breakpoints that I have set. The COM dll is failing on an assertion (which is what I am trying to debug), and I get the option to 'Retry to Debug' ... but nothing happens, and my python code ends (The program 'python3.8.exe' has exited with code -1 (0xffffffff).
)
If I DO check 'Enable Native Code Debugging', the programme ignores my Python breakpoints, and pops up this window:
If I choose 'Close' then Visual Studio starts to run the Python script (without hitting any Python script breakpoints), the assertion is hit, and choosing 'Retry' opens my C++ code at the offending line (which is at least helpful up to a point). The same COM dll works fine if driven from VBA in Excel, so I suspect I have an issue with parameter passing via win32com.client, so I want to check if the dll is receiving what I think I am sending: hence the requirement to debug.
If I do 'Open the Symbols Settings Dialog', I get this:
Where you can see that I have followed the MS instructions on their website, and used the Python 3.8 installer to install the symbols. The directory C:\Program Files\Python38 does indeed contain python38.pdb. I suspect Visual Studio is loading python from somewhere else? Have I installed the symbols in the wrong place?
I would like to be able to step through my Python code (hitting breakpoints where marked), and also hit breakpoints in the C++ code. Is this possible, and if so, how do I set up my Visual Studio to play nicely with Python 3.8?
If anyone did wade all the way through the question, the solution that worked for me was to:
When I run a python script now from VS, I can see that the command window has C:\Program Files\Python37\python37.exe
Checking 'Enable Native Code Debugging' now not only hits my Python breakpoints, but also any breakpoints in my C++ (when the file is open).
One fly in the ointment is that the Debugger spends a long time loading symbols for all of the individual python packages. I have tried specifying that I only want symbols for my COM dll, but to no avail. I start the Debugger and then surf SO looking at Q&A until I hit the first breakpoint some time later ...
If anyone has a fix for this, I'd love to hear it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With