What methods are there for debugging the Panda library under Windows?
At this moment, I don’t have version of Panda that I can debug. I’ve downloaded and compiled the debug version for Windows, but I haven’t learned how to run a loadable DLL in Python through the MSVC08 debugger.
Actually, that’s not strictly true; you’ll get debug symbols even in the “Release” compilation mode, though you’ll need to keep the pdb files that are produced by the compiler. Debugging is more confusing in “Release” mode, though, because the compiled code may not precisely match the source code, and stepping through the code instructions is weird. Also inspecting variables may fail because some variables may be reduced to registers and can’t be inspected.
But, yeah, in any case you’ll probably need to compile your own version of Panda in order to get debug symbols.
I’m not wanting to debug C++ code that I wrote, though. (Such as pview.exe, or some program that uses Panda libs directly, etc.) I want to run Panda run through the Python system, as my game is written in Python. My goal is to set break points in the C++ source of the Panda library and follow it as the modules are loaded and run from Python.
I’ve never debugged loadable modules using MSVC run through another program, so I am not at all sure how to set this up. If I try to run Python directly (passing, say, “-i mypythonbits.py”), MSVC complains because Python isn’t the debug build. Do I just need to install/compile a debug Python myself in order to get the debug symbols for Panda to load, too?
I did a debug build using the makepanda MSVC08 project, and I do have the .PDB files in my debug/bin directory, so I know it built a debug symbol-enabled version.
Where I am stuck is figuring out how to debug it from there. I am not sure what David means by compiling my own version. Separate from the makepanda solution? How does one go about setting this up?
I am very rusty with MS dev tools. Last MSVC I used was VC++ 6.0…
No, you just compiled your own version, the debug version you built with pdb’s. That’s fine. But, yeah, now you’ll need a debug version of Python to go with it, because you can’t run a debug version of Panda from a release version of Python (with or without the debugger).
You can get the Python source and build yourself a debug version. You might also be able to find one for download. Maybe you even have one installed already (it’s traditionally called python_d.exe).
Thanks David. I’ll try that later with a debugging Python. I don’t see a python_d.exe anywhere on my system, so looks like I will need to install/build it. My preference being building it, so I can have everything under the same library/optimization umbrella. But I’ll see later how big a task that is.
You mean you built Panda under optimize 1?
The _d libs are from Python - you need to build a debug version of Python, install it into thirdparty/win-python, and rebuild Panda with optimize 1.
Panda has no _d libraries if you compile them in debug mode - they are named the same way.
But if you don’t need to debug code in Python itself, but just in your own stuff, you don’t need a debug version of Python, I think.
Actually, that’s not true, at least it’s not true for ppremake. On Windows, with ppremake, Panda names its libraries _d in optimize 1 and 2, following the Python convention. I think it builds this way also with makepanda.
Yeah, I don’t need to debug the Python language part at all – It’s just that because I am using Panda as its out-of-the-box default of being Python-driven, I can’t easily debug Panda when my Python-coded game crashes.
As David said, I need a debug-symbol pathway all way through Python, from a debug-build Python that loads a debug-build Panda DLL.
I’m not sure about the _d libraries yet with makepanda on Windows. I swore I did a debug build but all of the DLLs in bin are without the _d extension. I will re-check.
Still trying to puzzle this out.
Update: Yeah, I didn’t do a debug build (was doing --optimize 3). I’ll try again once I figure out how to build a debug Python.
How are people step-debugging Panda under Windows if they aren’t building a debug Python?
No, you just compiled your own version, the debug version you built with pdb's. That's fine. But, yeah, now you'll need a debug version of Python to go with it, because you can't run a debug version of Panda from a release version of Python (with or without the debugger).
You can get the Python source and build yourself a debug version. You might also be able to find one for download. Maybe you even have one installed already (it's traditionally called python_d.exe).
But building a debug Python is a mess. Aside from delving into dependency hell, there’s the issue that all the libraries/DLLs are called whatever_d.lib and so on, so makepanda just won’t work out of the box.
I don’t really care about a debug Python. I’m not interested in stepping through the internals of the Python language. What I want to do is be able to use MSVC debugging tools with Panda3d libraries that are being called from Python.
Surely there is an easier way to do this for someone wanting to debug Panda code under Windows?
Ahhh, pyconfig.h holds lots of goodies, I see. That’s part of what I was missing.
I’ve decided to abandon the debug Python build approach. Sadly, I can’t just apt-get that package on this OS.
I do have a work around for now: I found out I can attach to the running python.exe process, and then invoke whatever Python might cause my program to crash. Since the Panda3d DLLs have full symbol info, from there I can at least view the C++ code and register dump whenever it dies.
I would still like the ability to step-debug and set break points, but at least I can see where a crash occurs, when it does. That should be enough for me to fix some of the problems I’ve encountered.
Sorry for being a nuisance, but been trying to figure this out for a week, on and off.