Differences between revisions 4 and 5
Revision 4 as of 2013-12-26 10:17:51
Size: 358
Editor: DelbertWa
Comment:
Revision 5 as of 2013-12-27 04:10:54
Size: 4047
Editor: TomTromey
Comment: spam
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Hi there! :) My name is Delbert, I'm a [[http://Www.Adobe.com/cfusion/search/index.cfm?term=&student&loc=en_us&siteSection=home|student]] studying [[https://Www.google.com/search?hl=en&gl=us&tbm=nws&q=Chinese|Chinese]] Studies from Steinheim, Germany.<<BR>>
<<BR>>
Also visit my homepage [[http://www.rentacarinhyderabad.com|Tour operators in Hyderabad]]
#pragma section-numbers 2
= Advice for distributions =


GDB has a number of features that either require special work by distributions to support, or that are of special interest to distributions. This page collects these into a checklist so distros can be sure to provide the best debugging support to their users.

<<TableOfContents>>
<<Anchor(Subject)>>

== sys/sdt.h probes ==

A number of system libraries have <sys/sdt.h> probes built-in. GDB has built-in knowledge of a few of these probes, which it uses to provide a better debugging experience to users. In particular:

  * libgcc has hooks used by GDB to handle unwinding nicely. This lets things like "next over throw" work.

  * libstdc++ has hooks used by GDB to implement "catch throw" and some other features specifically related to C++ exceptions

  * glibc has hooks used by GDB to handle longjmp gracefully (even in the presence of PC obfuscation) and an improved interface with the runtime linker. See LinkerInterface.

While <sys/sdt.h> came from the SystemTap project, it is really more of a GCC- and ELF-feature, consisting of just a couple of header files. See [[https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation]]. To ensure this is used in your distro, make sure these headers are available when building the various dependent libraries, and, for glibc, ensure you specify the {{{--enable-systemtap}}} configure option. You can check your work using {{{readelf -n}}}.

== Python "hook" activation ==

GDB will automatically load some Python code when the inferior loads a shared library or the like. Many system programs, like libstdc++, ship with Python code like pretty-printers and type-printers. If the distro arranges this properly, then debugging will "just work" for users without any special configuration. You can see more information [[https://sourceware.org/gdb/current/onlinedocs/gdb/Python-Auto_002dloading.html#Python-Auto_002dloading|in the manual]].

In Fedora we arrange for GDB to look in {{{/usr/share/gdb/auto-load}}} for the Python "hook" files. The hook files are named after their "parent" libraries and put into this directory. For example, the libstdc++ hook file is {{{/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.17-gdb.py}}}.

== build-id ==

The GNU toolchain supports emitting a unique "build id" into each executable or shared library. GDB knows how to look up separate debug info files using the build id. This is superior to a by-name approach because it accounts for scenarios like examining a core dump made on a different machine with different versions of libraries installed.

See [[https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html|the GDB documentation about build-id]] or [[http://fedoraproject.org/wiki/Releases/FeatureBuildId|the Fedora feature describing the roll-out there]].

== .gdb_index ==

GDB supports a special index file that can be used to speed up GDB startup and let GDB use less memory. The index is easy to create using GDB and other GNU utilities. See [[https://sourceware.org/gdb/onlinedocs/gdb/Index-Files.html#Index-Files|the GDB documentation]] for more information.

== dwz ==

The dwz program can be used to further compress the DWARF in your separate debuginfo files. This is a semantic compressor, not just a simple gzip-style compressor; a benefit of it is that it also lets gdb use less memory at runtime.

== Compilation flags ==

With {{{-fasynchronous-unwind-tables}}} GDB can provide backtrace any time the program crashes or any time it gets interrupted by user. For some targets it is already the default. It is needed only for optimized builds and only for {{{-fomit-frame-pointer}}} code.

{{{#!wiki comment
Should be here also other flags providing better debugging experience although unrelated to GDB itself?
Fedora rpmbuild flags:
-Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches
Controversial, not in Fedora: -g3
}}}

Advice for distributions

GDB has a number of features that either require special work by distributions to support, or that are of special interest to distributions. This page collects these into a checklist so distros can be sure to provide the best debugging support to their users.

1. sys/sdt.h probes

A number of system libraries have <sys/sdt.h> probes built-in. GDB has built-in knowledge of a few of these probes, which it uses to provide a better debugging experience to users. In particular:

  • libgcc has hooks used by GDB to handle unwinding nicely. This lets things like "next over throw" work.
  • libstdc++ has hooks used by GDB to implement "catch throw" and some other features specifically related to C++ exceptions
  • glibc has hooks used by GDB to handle longjmp gracefully (even in the presence of PC obfuscation) and an improved interface with the runtime linker. See LinkerInterface.

While <sys/sdt.h> came from the SystemTap project, it is really more of a GCC- and ELF-feature, consisting of just a couple of header files. See https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation. To ensure this is used in your distro, make sure these headers are available when building the various dependent libraries, and, for glibc, ensure you specify the --enable-systemtap configure option. You can check your work using readelf -n.

2. Python "hook" activation

GDB will automatically load some Python code when the inferior loads a shared library or the like. Many system programs, like libstdc++, ship with Python code like pretty-printers and type-printers. If the distro arranges this properly, then debugging will "just work" for users without any special configuration. You can see more information in the manual.

In Fedora we arrange for GDB to look in /usr/share/gdb/auto-load for the Python "hook" files. The hook files are named after their "parent" libraries and put into this directory. For example, the libstdc++ hook file is /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.17-gdb.py.

3. build-id

The GNU toolchain supports emitting a unique "build id" into each executable or shared library. GDB knows how to look up separate debug info files using the build id. This is superior to a by-name approach because it accounts for scenarios like examining a core dump made on a different machine with different versions of libraries installed.

See the GDB documentation about build-id or the Fedora feature describing the roll-out there.

4. .gdb_index

GDB supports a special index file that can be used to speed up GDB startup and let GDB use less memory. The index is easy to create using GDB and other GNU utilities. See the GDB documentation for more information.

5. dwz

The dwz program can be used to further compress the DWARF in your separate debuginfo files. This is a semantic compressor, not just a simple gzip-style compressor; a benefit of it is that it also lets gdb use less memory at runtime.

6. Compilation flags

With -fasynchronous-unwind-tables GDB can provide backtrace any time the program crashes or any time it gets interrupted by user. For some targets it is already the default. It is needed only for optimized builds and only for -fomit-frame-pointer code.

None: DistroAdvice (last edited 2013-12-27 04:10:54 by TomTromey)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.