[gdal-dev] Building debug Python bindings (e.g. _gdal.pyd) with MS Visual Studio

Jason Roberts jason.roberts at duke.edu
Sat Jul 17 14:37:05 EDT 2010


Howard,

Thanks for the hint. I was able to get what appear to be debug versions of
the extension DLLs (e.g. _gdal_d.pyd) along with symbols (e.g. _gdal_d.pdb).
For the record, here is a basic procedure that seemed to work for VS 2003:

1. Download release-1310-dev.zip and extract someplace, e.g.
C:\gdal_release-1310-dev.

2. Copy entire C:\Python25 to C:\gdal_release-1310-dev\Python25.

3. Modify C:\gdal_release-1310-dev\makefile so that PYTHON_DIR is
appropriate.

4. Download Python source and extract someplace, e.g. C:\Python-2.5.4.

5. Follow instructions in C:\Python-2.5.4\PCbuild\readme.txt to build
pythoncore and python projects in VS 2003 with debug.

6. Copy C:\Python-2.5.4\PCbuild\python_d.exe, python_d.pdb, python25_d.dll,
and python25_d.pdb to C:\gdal_release-1310-dev\Python25.

7. Copy C:\Python-2.5.4\PCbuild\python25_d.lib to
C:\gdal_release-1310-dev\Python25\libs.

8. C:\gdal_release-1310-dev> nmake gdal gdal-python DEBUG=YES

9. Search C:\gdal_release-1310-dev for the _*_d.pyd and _*_d.pdb files. They
are in separate places.

I have not tried the debugger yet, but in my past experience, if you can get
the debug symbols you can usually get the debugger working. There might be
some issues with the VC runtime library though.

If anyone has any further hints please let me know...

Thanks,

Jason

-----Original Message-----
From: Howard Butler [mailto:hobu.inc at gmail.com] 
Sent: Saturday, July 17, 2010 12:15 PM
To: Jason Roberts
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] Building debug Python bindings (e.g. _gdal.pyd) with
MS Visual Studio


On Jul 17, 2010, at 10:45 AM, Jason Roberts wrote:

> This is probably a question for Tamas Szekeres and Howard Butler, but I'm
emailing the whole list in case others are knowledgeable or interested.
>  
> As part of trying to figure out http://trac.osgeo.org/gdal/ticket/3672, I
would like to step through GDAL's SWIG-generated Python bindings in the
Visual Studio debugger. I downloaded release-1310-dev.zip, started a VS 2003
command line, and ran this:
>  
> C:\gdal_release-1310-dev> nmake gdal gdal-python DEBUG=YES
>  
> I noticed that .pdb files were generated for all of the apps such as
ogr2ogr.exe. I noticed that gdal17.dll is now 9 MB rather than 6 MB,
suggesting that it includes debug symbols internally. But the Python
bindings such as _gdal.pyd _gdal_array.pyd are the same size as the release
build and I could not find any .pdb files. I have not tried the debugger yet
but I'm guessing it will not find any symbols.
>  
> Am I correct? If so, could you please advise me on how to build the Python
bindings with debug symbols? Any other hints for stepping through the GDAL
Python bindings or GDAL library code with Visual Studio?
>  
> Thanks for your help,

You need to build a *Python* with debug symbols as well, and then
distutils/setuptools from that debug Python build will build a debug
extension.  Otherwise, I think you have to hack distutils/setuptools to
override and insert debug symbols, but it's been years since I've fooled
with this stuff.  Searching for information about debugging windows python c
extensions might get you some general help.  

Sorry I don't know more,

Howard




More information about the gdal-dev mailing list