-
Notifications
You must be signed in to change notification settings - Fork 663
How to debug ogr2ogr2 (and other C and C packages)
In order to debug a C or C++ program, in general two conditions must be met:
- The package must contain debugging symbols
- The code shouldn't be optimized
These imply that a binary package suitable for production won't be in general suitable for debugging.
In this guide I'll describe the process, focusing on ogr2ogr2 binary, but similar steps can be applied to debug any other C or C++ in general.
- Get the sources
- Figure out how to build the binaries
- Figure out how to configure the build in order to produce debugging symbols and non-optimized code
- Debug a problem: inspect a coredump or trace a live execution with a debugger
There are two options:
- get the debian source package
- get the source code from its repo.
The debian source package differs from the source in that it usually contains specific build options and potentially some patches, plus some other information such as dependencies on other packages.
The ogr2ogr2 binary is actually part of the gdal project. You can get the sources from:
(the mirror works just great so most likely you won't need to use svn, commits are cross-referenced)
If you use a debian system for building, then the debian source package contains all the information you need to get the dependencies automatically:
sudo apt-get build-dep ogr2ogr2-static-bin
Otherwise, the source code usually contains information about the dependencies in a README or INSTALL file, always worth reading. If you don't have them all, you'll get a failure at compilation time that will hint you about the missing dependency.
TODO
TODO
TODO
TODO