GCC has become pretty good at generating debuginfo that is usable by profilers, tracers and debuggers even for optimized production code.
But using and distributing the symbols, unwind tables and debuginfo for production binaries in distributions is somewhat different from using the same debuginfo during a compile-edit-debug cycle (where you can create special debug builds).
I will present what I learned from hacking on elfutils, rpm and debugedit for Fedora. And give an overview of the tools involved (gcc/DWARF, rpm/debugedit, .gnu_debugdata, gdb/gdb-index, dwz, binutils/gold, elfutils/eu-strip).
Then we can discuss how to make some of them work better together and new tools that we might need when switching to DWARF5.
Making it possible to install multiple versions and subpackages.
Defacto "standards", goal not always clear, various "fixups".
Ultimately want "everything", just not (all) installed by default.
So really just for native executables on GNU/Linux.
Except linux kernel modules. Some limited support for partially linked .ko files (ET_REL).
No good story on how to handle those. Hoped that it would go away. But newer languages (go, rust) seem to favor static linking.
So it depends on who you talk to...
The table is exact at each instruction boundary, so it can be used for stack unwinding from asynchronous events (such as debugger or garbage collector).
-b, --base-dir=STRING base build directory of objects
-d, --dest-dir=STRING directory to rewrite base-dir into
-l, --list-file=STRING file where to put list of source and header file names
-i, --build-id recompute build ID note and print ID on stdout
-s, --build-id-seed=STRING if recomputing the build ID note use this string as hash seed
-n, --no-recompute-build-id do not recompute build ID note even when -i or -s are given
Used by Debian for reproducable builds. Not for source file location.
-fdebug-prefix-map=BUILDPATH=.
They have a pending patch to improve flexibility (and use an environment variable).
This seems a good time to add an fast debug search index to binary (still not split debuginfo).
gdb-add-index (part of gdb).
Alternative is gold --gdb-index
You could use binutils:
objcopy --only-keep-debug foo foo.debug
strip foo
objcopy --add-gnu-debuglink=foo.debug foo
Or use elfutils:
eu-strip -f foo.debug foo
strip -g (to keep everything except .debug)
eu-strip has explicit --keep-section and --remove-section
Useful special case elfutils eu-strip has:
--reloc-debug-sections Resolve all trivial relocations between debug sections if the removed sections are placed in a debug file (only relevant for ET_REL files, operation is not reversable, needs -f)
Now lets add something back to the main binary.
ELF section with xz compressed ELF image containing a partial .symtab table.
See rpm find-debuginfo.sh script.
(awk, nm, sort, comm, objcopy -S --keep-symbols, xz, objcopy --add-section)
Now that we have prepared all .debug files try to optimize and deduplicate DWARF DIE tree.
Used in multifile mode.
Limitations
Reassembles .gdb_index
Part of RMP (but really just bfd_calc_gnu_debuglink_crc32).
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |