Debug Source Code

Brent Fraser bfraser at GEOANALYTIC.COM
Tue Aug 7 15:50:48 EDT 2007


David,

There are several ways to debug Mapserver on Windows:

1.  Use mapserver's DEBUG map file keyword (I can solve 10%
of my problems this way).  Verbose output is generated and
sent to the standard error output (STDERR) or the MapServer
logfile (if set using the LOG parameter in the WEB object).

2.  Create a Visual Studio project for shp2img.exe and debug
it (if your problems are data related) (good for 70% of
problems).

3a.  If you've got a Visual Studio project file for
mapserver: Debug mapserv.exe without a webserver by simply
putting the query_string portion of your web URL on the
command line (you can do this within msvc++6 too):
            mapserv QUERY_STRING="mapfile=..."
(good for another 15%)

3b. If you don't have a Visual Studio project file (you used
nmake):
   with VC6:
    - make sure the mapserv.exe is compiled for Debug via
nmake
    - Invoke the VC++ 6 IDE, and create a new console app
project (it doesn't matter where or what it is named)
    - Select Project -> Settings, then select the Debug tab
    - Select the ">" button on the end of the "Executable
for debug session" and select browse
    - Browse to your mapserv.exe, click Ok to dismiss
Project Settings dialog
    - Select Build -> Start Debug -> step Into

    or with VC7:
    - make sure the mapserv.exe is compiled for Debug via
nmake
    - Invoke the VC++ 7 IDE, and do File -> Open -> Project
and select mapserv.exe
    - Select Debug -> Step Into

4. And when none of the above will catch the problem (the
last 5%)
    - set up IIS on your development machine,
    - insert a DebugBreak(); in mapserv.c's main() (you'll
need to add "#include <windows.h>")
    - when you run the app, a dialog will popup asking if
you want to abort
the application (or No to debug it).  If you answer No,the
VC++ IDE will be
invoked, showing the assembler code.  Click the "Single
Step" icon twice in
the IDE to advance to the source code, and dismiss the
assembler window.
You can then step thru the source.


Brent Fraser
GeoAnalytic Inc.
Calgary, Alberta

----- Original Message ----- 
From: "David Stajan" <dls at INFORMGIS.COM>
To: <MAPSERVER-USERS at LISTS.UMN.EDU>
Sent: Tuesday, August 07, 2007 1:02 PM
Subject: [UMN_MAPSERVER-USERS] Debug Source Code


Hi,


I was hoping somebody might be able to explain to me how to
walk through
the mapserver source code!  I have been compiling mapserver
on a windows
machine with visual studio command prompt, and everything
has been going
well.  I have ran into a couple of kinks and I think if I
could walk through the
code with break points I could come up with some solutions.


But how do you do this with Mapserver?  I've compiled it
with the MSVCRT
debug mode but it doesn't create pdb file for mapserver
executable.  It does
create a vc70.pdb file but I'm not sure if that can be used,
or how it's used.


Any help or tips on how to debug the source code would be
greatly appreciated



More information about the mapserver-users mailing list