Debug Symbol Packages

Differences between revisions 1 and 2
Revision 1 as of 2014-03-10 14:01:37
Size: 5890
Editor: 210
Comment: create page
Revision 2 as of 2014-03-10 14:47:14
Size: 5500
Editor: 210
Comment: rewrite for ease of use. write intro.
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
The maintainers of a project usually place the {{{*-dbg.deb}}} packages alongside their binary package in the same repository. Installing them will just involve finding the appropriate package name based on the version of that is installed. However, not all maintainers do this and they may not be up to date. During compilation on the ubuntu servers debug packages are also [[https://launchpad.net/ubuntu/+source/pkg-create-dbgsym|created automatically]] for each binary package. These are named {{{*-dbgsym.ddeb}}} and are stored in a separate archive. This is because these packages are used relatively rarely compared to the main repositories and need not be mirrored as much. ([[AptElfDebugSymbols|the spec for this]]) Either one of these can be used. The maintainers of a project usually place the {{{*-dbg.deb}}} packages alongside their binary package in the same repository. Installing them will just involve finding the appropriate package name based on the version of that is installed. However, not all maintainers do this and they may not be up to date. During compilation on the ubuntu servers debug packages are also [[https://launchpad.net/ubuntu/+source/pkg-create-dbgsym|created automatically]] for each binary package. These are named {{{*-dbgsym.ddeb}}} and are stored in a separate archive. This is because these packages are used relatively rarely compared to the main repositories and need not be mirrored as much. ([[AptElfDebugSymbols|the spec for this]]) Either one of these can be used, but for a given package only one can be used at a time.
Line 13: Line 13:

First, check if there is a package with a -dbg suffix in the main Ubuntu repositories. These are the debug symbol packages, and are equivalent to '-dbgsym' described below. You can safely use either one, but not both at once. Try installing the package, adding -dbg to its name, for example:
{{{
sudo apt-get install xserver-xorg-core-dbg
}}}
if the package in question is the ''xserver-xorg-core'' package.

If there is no -dbg package:
=== Getting -dbgsym.ddeb packages ===
In case the {{{-dbg}}} package is not available for the version of the package you are using, you might have to use the {{{-dbgsym}}} packages. When a large number of dependancies need to have their symbols retrieved it might become necessary to enable the {{{-dbgsym}}} repositories anyway.
Line 23: Line 17:
 {{{
echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse" | \
sudo tee -a /etc/apt/sources.list.d/ddebs.list
}}}
 1. Stable releases (not alphas and betas) require three more lines adding to the same file, which is done by the following terminal command:
 {{{
echo "
deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
 {{{#!highlight bash
echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
Line 35: Line 25:
 You may also add these lines using the Synaptic Package Manager:
  * Choose ''Synaptic'' via the ''System > Administration'' menu.
  * Choose ''Software Sources'' or ''Repositories'' via the ''Settings'' menu, and click on the ''Third-Party Software'' tab.
  * Click the ''Add'' button and enter each ''deb ...'' line as above one by one and click the ''Add Source'' button (you will have to add these lines one at a time).
 The last three repositories may not be needed on a testing (alpha, beta daily build etc) releases.
Line 40: Line 27:
 1. Import the debug symbol archive signing key:  You can also add these repositories in your software sources from the Ubuntu software center or from synaptic. (see [[https://help.ubuntu.com/community/Repositories/Ubuntu|this article]] especially the section on [[https://help.ubuntu.com/community/Repositories/Ubuntu#Adding_Other_Repositories |adding other repositories]])
 You will need to add lines like
Line 42: Line 30:
deb http://ddebs.ubuntu.com trusty main restricted universe multiverse}}}

 1. Import the debug symbol archive [[https://help.ubuntu.com/community/Repositories/Ubuntu#Authentication_Tab|signing key]] from the ubuntu server:
 {{{#!highlight bash
Line 45: Line 37:
 1. Then run
 {{{
 1. Then run the following to update your package list or click the ''Reload'' button if you used the Synaptic Package Manager.
 {{{#!highlight bash
Line 49: Line 41:
 to update your package list or click the ''Reload'' button if you used the Synaptic Package Manager.   === Manual install of debug packages ===
 If the package in question is the ''xserver-xorg-core'' package you can try
 {{{
sudo apt-get install xserver-xorg-core-dbg
}}}
Line 51: Line 48:
 1. The debug symbol packages have the '-dbgsym' suffix attached, so to install the debug symbols for the package 'yelp', you first run:  or
Line 53: Line 50:
apt-cache policy yelp sudo apt-get install xserver-xorg-core-dbgsym
Line 55: Line 52:
 This will show you the version number currently installed (we'll use 2.22.1-0ubuntu2.8.04.1 in this example).
 '''NOTE:''' 'yelp' [which is the package name of "Help and Support" located under the 'System' menu] is ''just an example'' and '''not''' a part of the command: 'yelp' is only used to demonstrate the procedure. You must replace 'yelp' with the name of the package you want to debug.
Line 58: Line 53:
 1. Install the debug symbols:
 {{{
sudo apt-get install yelp-dbgsym=2.22.1-0ubuntu2.8.04.1
}}}
You can also use the Synaptic Package Manager to search for 'yelp-dbgsym' and install it from there.
=== Automatic Resolution / Installation of necessary packages ===
 The above procedure will install the debug symbol package for a single package only. Chances are that the binary uses shared libraries in other packages and debug symbols for them might be required in order to obtain a readable stack trace or perform other debugging tasks.
Line 64: Line 56:
The above procedure will install the debug symbol package for yelp only. Chances are that yelp uses shared libraries in other packages and debug symbols for them might be required in order to obtain a readable stack trace or perform other debugging tasks.

You can download the following [[attachment:list-symbols-packages-v2.1.sh |shell script (list-symbols-packages-v2.1.sh)]] to resolve all the dependencies. Attaching a debugger to an already running process may require elevated privileges even if you own the process. The following invocation will print out the list of files to install.
 You can download the following [[attachment:list-symbols-packages-v2.1.sh |shell script (list-symbols-packages-v2.1.sh)]] to resolve all the dependencies. Attaching a debugger to an already running process may require elevated privileges even if you own the process. The following invocation will print out the list of files to install. If you want to debug an instance of evince use:
Line 70: Line 60:
To automatically install them apt can be called with the input from the script. The script is invoked with {{{-t}}} for a terse output without the descriptions of the packages and error messages are suppressed.  To automatically install them apt can be called with the input from the script. The script is invoked with {{{-t}}} for a terse output without the descriptions of the packages and error messages are suppressed.
Line 76: Line 66:
/!\ Version 2 of this script makes it compatible with the newer GDB (which no longer loads all libraries at startup by default). -v2 currently only works if you run it against a currently-executing binary (i.e., with '-p $(pidof <whatever>'). The [[attachment:list-symbols-packages.sh|older version]] of the script is also available.  /!\ Version 2 of this script makes it compatible with the newer GDB (which no longer loads all libraries at startup by default). -v2 currently only works if you run it against a currently-executing binary (i.e., with '-p $(pidof <whatever>'). The [[attachment:list-symbols-packages.sh|older version]] of the script is also available.

Debugging Central

This page is part of the debugging series — pages with debugging details for a variety of Ubuntu packages.

This document describes how to set up the debugging symbol packages ( *-dbg.deb and *-.dbgsym.ddeb ). You might need to do this when you are performing tasks like a Backtrace or using Valgrind.

Debug Symbol Packages

If you want to debug a crash in a project you are developing yourself or from a third-party package, or need the debug symbols for particular libraries very often, it is helpful to install those permanently into your system.

Debugging a program or analyzing stack traces can be very hard because most of the information that can be extracted from them will be in the form of offsets into the binary machine code of the executable. The extra information that allows mapping a machine instruction in a complex module to a function and line number in a corresponding C file is stored in the debug symbol packages.

The maintainers of a project usually place the *-dbg.deb packages alongside their binary package in the same repository. Installing them will just involve finding the appropriate package name based on the version of that is installed. However, not all maintainers do this and they may not be up to date. During compilation on the ubuntu servers debug packages are also created automatically for each binary package. These are named *-dbgsym.ddeb and are stored in a separate archive. This is because these packages are used relatively rarely compared to the main repositories and need not be mirrored as much. (the spec for this) Either one of these can be used, but for a given package only one can be used at a time.

Getting -dbgsym.ddeb packages

In case the -dbg package is not available for the version of the package you are using, you might have to use the -dbgsym packages. When a large number of dependancies need to have their symbols retrieved it might become necessary to enable the -dbgsym repositories anyway.

  1. Create an /etc/apt/sources.list.d/ddebs.list by running the following line at a terminal:

       1 echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse
       2 deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
       3 deb http://ddebs.ubuntu.com $(lsb_release -cs)-security main restricted universe multiverse
       4 deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | \
       5 sudo tee -a /etc/apt/sources.list.d/ddebs.list
    
    The last three repositories may not be needed on a testing (alpha, beta daily build etc) releases.

    You can also add these repositories in your software sources from the Ubuntu software center or from synaptic. (see this article especially the section on adding other repositories) You will need to add lines like

    deb http://ddebs.ubuntu.com trusty main restricted universe multiverse
  2. Import the debug symbol archive signing key from the ubuntu server:

       1 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 428D7C01
    
  3. Then run the following to update your package list or click the Reload button if you used the Synaptic Package Manager.

       1 sudo apt-get update
    

Manual install of debug packages

  • If the package in question is the xserver-xorg-core package you can try

    sudo apt-get install xserver-xorg-core-dbg
    or
    sudo apt-get install xserver-xorg-core-dbgsym

Automatic Resolution / Installation of necessary packages

  • The above procedure will install the debug symbol package for a single package only. Chances are that the binary uses shared libraries in other packages and debug symbols for them might be required in order to obtain a readable stack trace or perform other debugging tasks.

    You can download the following shell script (list-symbols-packages-v2.1.sh) to resolve all the dependencies. Attaching a debugger to an already running process may require elevated privileges even if you own the process. The following invocation will print out the list of files to install. If you want to debug an instance of evince use:

       1 sudo bash ./list-symbols-packages-v2.sh -p $(pidof yelp)
    

    To automatically install them apt can be called with the input from the script. The script is invoked with -t for a terse output without the descriptions of the packages and error messages are suppressed.

       1 sudo bash ./list-symbols-packages-v2.sh -t -p $(pidof yelp) 2>/dev/null|\
       2 xargs -d $'\n' sudo apt-get install 
    

    Warning /!\ Version 2 of this script makes it compatible with the newer GDB (which no longer loads all libraries at startup by default). -v2 currently only works if you run it against a currently-executing binary (i.e., with '-p $(pidof <whatever>'). The older version of the script is also available.


CategoryBugSquad CategoryDebugging

Debug Symbol Packages (last edited 2024-02-22 21:36:37 by eeickmeyer)