Debug packages contain debug symbols and usually are named <package>-dbg. They are useful if program crashes and you want to generate stack trace which contains information about functions where it crashed.

Configuration for creating debug package

Package control entry

Add a binary package stanza to debian/control describing the debug package. An example:

Package: giblib1-dbg
Architecture: any
Section: debug
Priority: extra
    giblib1 (= ${binary:Version}),
Description: debugging symbols for giblib1
 giblib is a library of handy stuff. Contains an imlib2 wrapper to avoid the
 context stuff, doubly-linked lists and font styles.
 This package contains the debugging symbols for giblib1.

Debhelper dependency

To use the dh_strip options as described below, you will need to build using Debhelper version 5 or later. Set the Build-Depends in debian/control like this:

    debhelper (>= 5),

Selectively strip debugging symbols

The build process needs to selectively strip debugging symbols from binaries, but retain them for use in the debug packages.

Stripping the binary files is usually done by the Debhelper dh_strip program, which defaults to discarding the debugging symbols. You will need to have dh_strip invoked with the --dbg-package=foo option to place the debugging symbols under /usr/lib/debug/ in the named package.

Debhelper < 7

If using Debhelper earlier than version 7, you will have explicit calls to dh_strip in your debian/rules. Change the call to look like:

binary-arch: build install
        dh_strip --dbg-package=giblib1-dbg

Debhelper >= 7

Debhelper version 7 aggregates long sequences of individual ‘dh_foo’ commands into the dh command, so you will probably not have an explicit dh_strip call. Instead, you will need to override the default invocation of dh_strip.

To allow for simpler overrides of individual Debhelper commands, set your Build-Depends field to depend on a minimum Debhelper version of 7.0.50 in debian/control:

    debhelper (>= 7.0.50),

Then add the following rule to debian/rules:

.PHONY: override_dh_strip
        dh_strip --dbg-package=giblib1-dbg

If you want to create more than one debug package, you need to do,

        dh_strip -pfoo --dbg-package=foo-dbg
        dh_strip -pbar --dbg-package=bar-dbg

Additional provisions

If you use dh automated install and you have only one binary package except the new -dbg package, make sure that the files that were previously automatically installed to debian/giblib1 are still installed there, e.g. by adding an override:

        dh_auto_install --destdir=debian/giblib1

In that situation, it is also possible to make the debug package's documentation in /usr/share/doc/giblib1-dbg/ a symlink to /usr/share/doc/giblib1 using

        dh_installdocs --link-doc=giblib1


If you use cdbs then just add the line:

DEB_DH_STRIP_ARGS := --dbg-package=giblib1-dbg

CategoryDeveloper CategoryDebugging