Debugging Panda under Win platform?

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.

You can debug Panda apps with the MSVC 2008 debugger.
To get debug symbols, you’ll need to compile Panda in debug configuration.

imgbin.org/images/330.png

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.

David

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. :slight_smile: 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).

David

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. :slight_smile:

Where do i find the _d.libs? I built everything under optimize 1.

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.

David

Not as far as I know. I could add that support though.

Okidoke; ill see what i can dig up with it tonight. Thanks guys.

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.

Decided to go ahead and let makepanda run while puzzling out Python – I ran it with --everything and --optimize 1, but I did not receive any DLLs with a _d extension in the output /bin directory.

I am quite lost. To build a debug Python, I must reconstruct exactly what Panda3d needs. I don’t understand the requirements of what is supposed to be in the thirdparty/win-python directory.

I really want to help debug and test with Panda, but I am stumped as to how to proceed on getting an environment where I can test this. It’s also making it difficult to continue with my project.

What are others doing? Can anyone offer any help on how to get this working? Any documents on how win-python is constructed?

win-python is created by running the Python installer .exe from their download page, and installing it into win-python with “Install just for me” selected in the installer.

But that’s just the release Python? I need the debug Python.

Well, I don’t know. I’m sure it provides some kind of “make install” or maybe you can reconstruct the structure manually. Or you can try to find information on how they make the releases.

How are people step-debugging Panda under Windows if they aren’t building a debug Python?

David says:

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?

Really getting frustrated here.

Well, I can step-debug Panda apps under Windows. I just can’t step through the code in the Python library.

makepanda will actually work out of the box - the library to use is specified in pyconfig.h.

You can try to see if this works right and if you can step through Panda. If not, you can try to look around on the internet to see if someone may have uploaded a Python build.

I’m a linux user myself so I just have to install the python2.6-dbg package :slight_smile:

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. :frowning:

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.