This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFA: handle "MiniDebuginfo" section
Tom Tromey writes:
> Tom> Here's the revised.
>
> I caught one little problem -- I had used gdb_test_multiple in an
> earlier revision and forgot to change it back. This lead to a test
> failure. Sigh.
>
> This version also changes some "verbose -log" calls back to "verbose",
> to avoid cluttering up the .log file unnecessarily.
>
> Finally, I was curious about the test coverage; this pointed out that
> the _close function was not being tested, so I added a test for that.
> There are still a few spots in the new file that aren't covered, but
> mostly errors, and I'm not as interested in testing all those.
>
> Tom
>
> 2012-11-14 Alexander Larsson <alexl@redhat.com>
> Jan Kratochvil <jan.kratochvil@redhat.com>
> Tom Tromey <tromey@redhat.com>
>
> * NEWS: Mention mini debuginfo feature.
> * minidebug.c: New file.
> * configure.ac: Check for lzma.
> * configure, config.in: Rebuild.
> * Makefile.in (LIBLZMA): New variable.
> (CLIBS): Include LIBLZMA.
> (SFILES): Mention minidebug.c.
> (COMMON_OBS): Mention minidebug.o.
> * symfile.c (read_symbols): New function.
> (syms_from_objfile, reread_symbols): Call it.
> * symfile.h (find_separate_debug_file_in_section): Declare.
>
> 2012-11-14 Tom Tromey <tromey@redhat.com>
>
> * gdb.texinfo (MiniDebugInfo): New node.
> (GDB Files): Update.
>
> 2012-11-14 Jan Kratochvil <jan.kratochvil@redhat.com>
> Tom Tromey <tromey@redhat.com>
>
> * gdb.base/gnu-debugdata.exp: New file.
> * gdb.base/gnu-debugdata.c: New file.
> * lib/gdb.exp (gdb_file_cmd): Handle LZMA warning.
> (gdb_unload): Return 0 on success.
Hi.
A couple of comments.
1) Being more of a minimalist when it comes to adding new stuff, and
applying "It's easier to relax restrictions than impose them after the fact."
it would be easy enough to restrict the section to being an (lzma-compressed)
ELF file (and equally easy to relax the restriction if someone ever presented
a compelling reason to support it). Sure, we *can* support COFF, etc. but
that doesn't, to me, mean we *should*.
Does Redhat have a *formal* spec of .gnu_debugdata that says COFF, etc. is
supported. [If that's the case then my point is moot,
but I couldn't find any such formal spec.]
2) Can you add something like the following to the docs?
This section is an LZMA compressed ELF file containing the standard
ELF symbol and DWARF sections. It needn't, but may, contain full debug info.
The intent is that it contains the desired subset of debug info that makes
things like backtracing work without making the file too large.
The point being the current docs say what .gnu_debugdata *does*,
but it doesn't formally and completely say what it *is*.
"LZMA-compressed object" leaves me guessing too much at the details.
By the way, strip -g should remove .gnu_debugdata.
I only skimmed subject lines of recent messages to binutils@ to see if a
patch has been submitted, and I just checked cvs head.
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 86cfe8e..224bdbf 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -15865,6 +15865,7 @@ program. To debug a core dump of a previous run, you must also tell
> @menu
> * Files:: Commands to specify files
> * Separate Debug Files:: Debugging information in separate files
> +* MiniDebugInfo:: Debugging information in a special section
> * Index Files:: Index files speed up GDB
> * Symbol Errors:: Errors reading symbol files
> * Data Files:: GDB data files
> @@ -16790,6 +16791,55 @@ gnu_debuglink_crc32 (unsigned long crc,
> @noindent
> This computation does not apply to the ``build ID'' method.
>
> +@node MiniDebugInfo
> +@section Debugging information in a special section
> +@cindex separate debug sections
> +@cindex @samp{.gnu_debugdata} section
> +
> +Some systems ship pre-built executables and libraries that have a
> +special @samp{.gnu_debugdata} section. This feature is called
> +@dfn{MiniDebugInfo}. This section holds an LZMA-compressed object and
> +is used to supply extra symbols for backtraces.
> +
> +The intent of this section is to provide extra minimal debugging
> +information for use in simple backtraces. It is not intended to be a
> +replacement for full separate debugging information (@pxref{Separate
> +Debug Files}). The example below shows the intended use; however,
> +@value{GDBN} does not currently put restrictions on what sort of
> +debugging information might be included in the section.
> +
> +@value{GDBN} has support for this extension. If the section exists,
> +then it is used provided that no other source of debugging information
> +can be found, and that @value{GDBN} was configured with LZMA support.
> +
> +This section can be easily created using @command{objcopy} and other
> +standard utilities:
> +
> +@smallexample
> +# Extract the dynamic symbols from the main binary, there is no need
> +# to also have these in the normal symbol table
> +nm -D @var{binary} --format=posix --defined-only \
> + | awk '@{ print $1 @}' | sort > dynsyms
> +
> +# Extract all the text (i.e. function) symbols from the debuginfo .
> +nm @var{binary} --format=posix --defined-only \
> + | awk '@{ if ($2 == "T" || $2 == "t") print $1 @}' \
> + | sort > funcsyms
> +
> +# Keep all the function symbols not already in the dynamic symbol
> +# table.
> +comm -13 dynsyms funcsyms > keep_symbols
> +
> +# Copy the full debuginfo, keeping only a minimal set of symbols and
> +# removing some unnecessary sections.
> +objcopy -S --remove-section .gdb_index --remove-section .comment \
> + --keep-symbols=keep_symbols @var{binary} mini_debuginfo
> +
> +# Inject the compressed data into the .gnu_debugdata section of the
> +# original binary.
> +xz mini_debuginfo
> +objcopy --add-section .gnu_debugdata=mini_debuginfo.xz @var{binary}
> +@end smallexample