5

From Debian's DebugPackage, I know the debug information file for an executable goes in /usr/lib/debug when creating two part executables (i.e., stripping the executable of its symbols and placing them in a separate file).

However, the symbol file will refer to source files, and I don't see where the source files are supposed to be placed. On Red Hat/Fedora, I know they are located in /usr/src/debug (according to Fedora's Packaging:Debuginfo).

Where do I put source files for debugging on Debian?


A concrete example is Crypto++. I have a patch for its GNUMakefile that adds the following:

IS_DEBIAN = $(shell uname -a 2>&1 | $(EGREP) -i -c "debian|ubuntu|mint")
...

# https://wiki.debian.org/DebugPackage
ifeq ($(IS_DEBIAN),1)
  DEBUG_SYM_DIR ?= /usr/lib/debug/cryptopp
  DEBUG_SRC_DIR ?= /usr/src/debug/cryptopp
endif
...

And then there's a symbol recipe that looks like so:

symbol symbols:
    $(MKDIR) -p $(DEBUG_SYM_DIR) $(DEBUG_SRC_DIR)
    -objcopy --only-keep-debug cryptest.exe cryptest.exe.debug
    -objcopy --only-keep-debug libcryptopp.so libcryptopp.so.debug
    -strip --strip-debug --strip-unneeded cryptest.exe
    -strip --strip-debug --strip-unneeded libcryptopp.so
    -$(CP) cryptest.exe.debug $(DEBUG_SYM_DIR)/
    -$(CP) libcryptopp.so.debug $(DEBUG_SYM_DIR)/
    -objcopy --add-gnu-debuglink=$(DEBUG_SYM_DIR)/cryptest.exe.debug cryptest.exe
    -objcopy --add-gnu-debuglink=$(DEBUG_SYM_DIR)/libcryptopp.so.debug libcryptopp.so
    -$(CP) *.h *.cpp $(DEBUG_SRC_DIR)/

So the workflow is:

cd cryptopp
make static dynamic test
sudo make symbols
sudo make install

Related, but not relevant (in case someone wants to comment): I can't add symbols as a dependency to another recipe or just make symbols because of a bug in objcopy (I believe its a bug - see Binutil Bug 18064 - objcopy, add-gnu-debuglink and "cannot fill debug link section").

  • I'm not sure I understand the question. Are you asking this as part of a packaging task? – Faheem Mitha Mar 1 '15 at 2:34
  • @Faheem - After I do a make install, I often find I need to step into library code to figure to how to work with it. And GDB expects things in certain places (which is often platform specific). So you can think of it as a packaging question, but its really a question of "where do things go so I can debug it after installation". – user56041 Mar 1 '15 at 2:36
  • Oh, Ok. If you can make this question more concrete/specific by providing an example using freely available software, that would be helpful. BTW, doing software installations on Debian by making a Debian package is usually a good idea, particularly if you are planning to customize the installation. – Faheem Mitha Mar 1 '15 at 2:40
  • 1
    This stackoverflow.com/q/28787534/350713 looks like a near dupe. It's probably better to avoid duplicating this information across sites. – Faheem Mitha Mar 1 '15 at 2:44
  • 1
    Building Debian packages these days is not a big deal. It is quite semi-automated, at least for simple packages. And #debian-mentors on OFTC is usually reasonably helpful. If you want to talk about this or related topics further, I suggest hopping into the chat room. You can ping me there if you want. – Faheem Mitha Mar 1 '15 at 3:35
5

Debian binary packages don't include source code, except in a few cases where source code is useful for building other packages (e.g. liblzo2-dev for minilzo.c, or binutils-source, gcc-4.9-source etc. for building toolchains), or where many users expect to be able to install the source easily (the kernel source for example). The source is shipped in a source package, which is built automatically by dpkg-buildpackage.

The way to install Debian packages' source code is to use apt-get source; in your case

apt-get source cryptopp

Users can do this anywhere they have write-access to, which means there is no canonical source location. Furthermore, since packages can be built anywhere, the stored source location is liable to change too... (There is an interesting feature in Debian which can help though: /usr/src belongs to the src group and is group-writeable, so any user in the src group can use that directory without being root. Binary packages which provide source code install the source code in /usr/src.)

So to use debugging packages in Debian with the corresponding source code, you need to install the debugging package, get the matching source code as above, and tell gdb how to match things up with directory and set substitute-path statements (see the gdb documentation for details).

On the packaging side, the source package takes care of itself, and if you're using debhelper, the debug package takes care of itself too (since version 9.20151219).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy