toolchain/share/doc/gdb/MiniDebugInfo.html

104 lines
4.9 KiB
HTML
Raw Normal View History

2024-01-10 05:24:32 +00:00
<html lang="en">
<head>
<title>MiniDebugInfo - Debugging with GDB</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Debugging with GDB">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="GDB-Files.html#GDB-Files" title="GDB Files">
<link rel="prev" href="Separate-Debug-Files.html#Separate-Debug-Files" title="Separate Debug Files">
<link rel="next" href="Index-Files.html#Index-Files" title="Index Files">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software'' and ``Free Software Needs
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom.''
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="MiniDebugInfo"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Index-Files.html#Index-Files">Index Files</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Separate-Debug-Files.html#Separate-Debug-Files">Separate Debug Files</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="GDB-Files.html#GDB-Files">GDB Files</a>
<hr>
</div>
<h3 class="section">18.4 Debugging information in a special section</h3>
<p><a name="index-separate-debug-sections-1290"></a><a name="index-g_t_0040samp_007b_002egnu_005fdebugdata_007d-section-1291"></a>
Some systems ship pre-built executables and libraries that have a
special &lsquo;<samp><span class="samp">.gnu_debugdata</span></samp>&rsquo; section. This feature is called
<dfn>MiniDebugInfo</dfn>. This section holds an LZMA-compressed object and
is used to supply extra symbols for backtraces.
<p>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 (see <a href="Separate-Debug-Files.html#Separate-Debug-Files">Separate Debug Files</a>). The example below shows the intended use; however,
<span class="sc">gdb</span> does not currently put restrictions on what sort of
debugging information might be included in the section.
<p><span class="sc">gdb</span> 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 <span class="sc">gdb</span> was configured with LZMA support.
<p>This section can be easily created using <samp><span class="command">objcopy</span></samp> and other
standard utilities:
<pre class="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</var> --format=posix --defined-only \
| awk '{ print $1 }' | sort &gt; dynsyms
# Extract all the text (i.e. function) symbols from the debuginfo.
# (Note that we actually also accept "D" symbols, for the benefit
# of platforms like PowerPC64 that use function descriptors.)
nm <var>binary</var> --format=posix --defined-only \
| awk '{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 }' \
| sort &gt; funcsyms
# Keep all the function symbols not already in the dynamic symbol
# table.
comm -13 dynsyms funcsyms &gt; keep_symbols
# Separate full debug info into debug binary.
objcopy --only-keep-debug <var>binary</var> debug
# 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 debug mini_debuginfo
# Drop the full debug info from the original binary.
strip --strip-all -R .comment <var>binary</var>
# 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</var>
</pre>
</body></html>