[ab4fdfc] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[4b0ebf70] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
[8dfc5c3] | 7 | <!ENTITY gdb-download-http "&gnu-http;/gdb/gdb-&gdb-version;.tar.xz">
|
---|
[e1e58be] | 8 | <!ENTITY gdb-download-ftp " ">
|
---|
[42b7702d] | 9 | <!ENTITY gdb-md5sum "85c722e2f2baea2b7820a6a7eaea2ce8">
|
---|
[6f0a8c86] | 10 | <!ENTITY gdb-size "23 MB">
|
---|
[42b7702d] | 11 | <!ENTITY gdb-buildsize "823 MB (add 788 MB for docs; add 738 MB for tests)">
|
---|
| 12 | <!ENTITY gdb-time "0.9 SBU (add 0.4 SBU for docs; add 6.3 SBU tests; all using parallelism=8)">
|
---|
[4b0ebf70] | 13 | ]>
|
---|
| 14 |
|
---|
[d3970e1] | 15 | <sect1 id="gdb" xreflabel="GDB-&gdb-version;">
|
---|
[4b0ebf70] | 16 | <?dbhtml filename="gdb.html"?>
|
---|
| 17 |
|
---|
| 18 |
|
---|
[d3970e1] | 19 | <title>GDB-&gdb-version;</title>
|
---|
[4b0ebf70] | 20 |
|
---|
| 21 | <indexterm zone="gdb">
|
---|
[4890200] | 22 | <primary sortas="a-GDB">GDB</primary>
|
---|
[4b0ebf70] | 23 | </indexterm>
|
---|
| 24 |
|
---|
| 25 | <sect2 role="package">
|
---|
[d3970e1] | 26 | <title>Introduction to GDB</title>
|
---|
| 27 |
|
---|
| 28 | <para>
|
---|
| 29 | <application>GDB</application>, the GNU Project debugger, allows you
|
---|
| 30 | to see what is going on <quote>inside</quote> another program while it
|
---|
| 31 | executes -- or what another program was doing at the moment it crashed.
|
---|
| 32 | Note that <application>GDB</application> is most effective when tracing
|
---|
| 33 | programs and libraries that were built with debugging symbols and not
|
---|
| 34 | stripped.
|
---|
| 35 | </para>
|
---|
[4b0ebf70] | 36 |
|
---|
[09ddf35a] | 37 | &lfs122_checked;
|
---|
[4b0ebf70] | 38 |
|
---|
| 39 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 40 | <itemizedlist spacing="compact">
|
---|
| 41 | <listitem>
|
---|
[4890200] | 42 | <para>
|
---|
| 43 | Download (HTTP): <ulink url="&gdb-download-http;"/>
|
---|
| 44 | </para>
|
---|
[4b0ebf70] | 45 | </listitem>
|
---|
| 46 | <listitem>
|
---|
[4890200] | 47 | <para>
|
---|
| 48 | Download (FTP): <ulink url="&gdb-download-ftp;"/>
|
---|
| 49 | </para>
|
---|
[4b0ebf70] | 50 | </listitem>
|
---|
| 51 | <listitem>
|
---|
[4890200] | 52 | <para>
|
---|
| 53 | Download MD5 sum: &gdb-md5sum;
|
---|
| 54 | </para>
|
---|
[4b0ebf70] | 55 | </listitem>
|
---|
| 56 | <listitem>
|
---|
[4890200] | 57 | <para>
|
---|
| 58 | Download size: &gdb-size;
|
---|
| 59 | </para>
|
---|
[4b0ebf70] | 60 | </listitem>
|
---|
| 61 | <listitem>
|
---|
[4890200] | 62 | <para>
|
---|
| 63 | Estimated disk space required: &gdb-buildsize;
|
---|
| 64 | </para>
|
---|
[4b0ebf70] | 65 | </listitem>
|
---|
| 66 | <listitem>
|
---|
[4890200] | 67 | <para>
|
---|
| 68 | Estimated build time: &gdb-time;
|
---|
| 69 | </para>
|
---|
[4b0ebf70] | 70 | </listitem>
|
---|
| 71 | </itemizedlist>
|
---|
[da73c1c] | 72 | <!--
|
---|
[17817c8] | 73 | <bridgehead renderas="sect3">Additional Downloads</bridgehead>
|
---|
| 74 | <itemizedlist spacing="compact">
|
---|
| 75 | <listitem>
|
---|
| 76 | <para>
|
---|
| 77 | Required patch:
|
---|
| 78 | <ulink url="&patch-root;/gdb-&gdb-version;-upstream_fixes-1.patch"/>
|
---|
| 79 | </para>
|
---|
| 80 | </listitem>
|
---|
| 81 | </itemizedlist>
|
---|
[da73c1c] | 82 | -->
|
---|
[d3970e1] | 83 | <bridgehead renderas="sect3">GDB Dependencies</bridgehead>
|
---|
[d4c9b7c] | 84 |
|
---|
[9533795] | 85 | <bridgehead renderas="sect4">Recommended Runtime Dependency</bridgehead>
|
---|
| 86 | <para role="recommended">
|
---|
| 87 | <xref linkend="six"/> (Python 3 module, required at run-time to
|
---|
| 88 | use GDB scripts from various LFS/BLFS packages with Python 3
|
---|
| 89 | installed in LFS)
|
---|
| 90 | </para>
|
---|
| 91 |
|
---|
[d4c9b7c] | 92 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
| 93 | <para role="optional">
|
---|
[852fc810] | 94 | <xref linkend="doxygen"/>,
|
---|
[a2e21ee] | 95 | <xref linkend="gcc"/> (ada, gfortran, and go are used for tests),
|
---|
[51cb7cd] | 96 | <xref linkend="guile"/>,
|
---|
| 97 | <xref linkend="rust"/> (used for some tests),
|
---|
[2029b72] | 98 | <xref linkend="valgrind"/>, and
|
---|
| 99 | <ulink url="https://sourceware.org/systemtap/">SystemTap</ulink>
|
---|
[51cb7cd] | 100 | (run-time, used for tests)
|
---|
[d4c9b7c] | 101 | </para>
|
---|
| 102 |
|
---|
[4b0ebf70] | 103 | </sect2>
|
---|
| 104 |
|
---|
| 105 | <sect2 role="installation">
|
---|
[d3970e1] | 106 | <title>Installation of GDB</title>
|
---|
[da73c1c] | 107 | <!--
|
---|
[d1e4f43] | 108 | <para>
|
---|
| 109 | First, apply a patch that fixes problems when debugging programs compiled
|
---|
| 110 | with <xref linkend="rust" role="nodep"/>:
|
---|
| 111 | </para>
|
---|
| 112 |
|
---|
| 113 | <screen><userinput remap="pre">patch -Np1 -i ../gdb-&gdb-version;-upstream_fixes-1.patch</userinput></screen>
|
---|
[da73c1c] | 114 | -->
|
---|
[d3970e1] | 115 | <para>
|
---|
| 116 | Install <application>GDB</application> by running the following
|
---|
| 117 | commands:
|
---|
| 118 | </para>
|
---|
[4b0ebf70] | 119 |
|
---|
[29d11601] | 120 | <screen><userinput>mkdir build &&
|
---|
| 121 | cd build &&
|
---|
| 122 |
|
---|
| 123 | ../configure --prefix=/usr \
|
---|
| 124 | --with-system-readline \
|
---|
| 125 | --with-python=/usr/bin/python3 &&
|
---|
[4b0ebf70] | 126 | make</userinput></screen>
|
---|
| 127 |
|
---|
[46fd248] | 128 | <para>
|
---|
| 129 | Optionally, to build the API documentation using
|
---|
| 130 | <xref linkend="doxygen"/>, run:
|
---|
| 131 | </para>
|
---|
| 132 |
|
---|
[a42c273] | 133 | <screen remap="doc"><userinput>make -C gdb/doc doxy</userinput></screen>
|
---|
[46fd248] | 134 |
|
---|
[d3970e1] | 135 | <para>
|
---|
[9aeac59] | 136 | Running the tests is not recommended. The results vary a lot depending
|
---|
| 137 | on the system architecture and what optional dependencies are installed
|
---|
| 138 | and what version of gcc is being used. On one system tested, there were
|
---|
| 139 | 140 unexpected failures (out of over 108,000 tests) and on another system
|
---|
| 140 | there were "only" 32 unexpected failures. The time to run the tests
|
---|
| 141 | varies from approximately 6 SBU to over 15 SBU when using -j8. This depends
|
---|
[5baf368] | 142 | on number of tests that time out as well as other factors.
|
---|
[9aeac59] | 143 | </para>
|
---|
| 144 |
|
---|
| 145 | <tip>
|
---|
| 146 | <para>
|
---|
| 147 | With a plain <command>make check</command>, there are many warning
|
---|
| 148 | messages about a missing global configuration file. These can be
|
---|
| 149 | avoided by running <command>touch global.exp</command> and prepending
|
---|
| 150 | the <command>make check</command> command with
|
---|
| 151 | <command>DEJAGNU=$PWD/global.exp</command>. In addition the tests can
|
---|
| 152 | be speeded up considerably by using the <command>make</command> option
|
---|
| 153 | "-j<N>" where <N> is the number of cores on your system.
|
---|
| 154 | </para>
|
---|
| 155 | </tip>
|
---|
| 156 |
|
---|
| 157 | <para>
|
---|
| 158 | To test the results anyway, issue:
|
---|
[03b05e7] | 159 | </para>
|
---|
| 160 |
|
---|
[a42c273] | 161 | <screen remap="test"><userinput>pushd gdb/testsuite &&
|
---|
[03b05e7] | 162 | make site.exp &&
|
---|
[9aeac59] | 163 | echo "set gdb_test_timeout 30" >> site.exp &&
|
---|
| 164 | make check 2>1 | tee gdb-check.log
|
---|
[03b05e7] | 165 | popd</userinput></screen>
|
---|
| 166 |
|
---|
| 167 | <para>
|
---|
| 168 | See <emphasis>gdb/testsuite/README</emphasis> and <ulink
|
---|
| 169 | url="https://sourceware.org/gdb/wiki/TestingGDB">TestingGDB</ulink>.
|
---|
[9aeac59] | 170 | There are many additional problems with the test suite:
|
---|
[d3970e1] | 171 | </para>
|
---|
[8558044] | 172 |
|
---|
[39e42c88] | 173 | <itemizedlist>
|
---|
| 174 | <listitem>
|
---|
| 175 | <para>
|
---|
[3e42104] | 176 | Clean directories are needed if re-running the tests. For that
|
---|
[6a1237d] | 177 | reason, make a copy of the compiled source code
|
---|
[8558044] | 178 | directory before the tests in case you need to run the tests again.
|
---|
[39e42c88] | 179 | </para>
|
---|
| 180 | </listitem>
|
---|
[8558044] | 181 |
|
---|
[39e42c88] | 182 | <listitem>
|
---|
| 183 | <para>
|
---|
| 184 | Results depend on installed compilers.
|
---|
| 185 | </para>
|
---|
| 186 | </listitem>
|
---|
[8558044] | 187 | <!-- I did not see this
|
---|
[39e42c88] | 188 | <listitem>
|
---|
| 189 | <para>
|
---|
[8558044] | 190 | There are a large number of timeouts (there is a variable
|
---|
| 191 | that can be set to increase time for timeout, but
|
---|
| 192 | changing it will result in a different number of tests being
|
---|
[3e42104] | 193 | run).
|
---|
[39e42c88] | 194 | </para>
|
---|
| 195 | </listitem>
|
---|
[29d11601] | 196 | or this
|
---|
[39e42c88] | 197 | <listitem>
|
---|
| 198 | <para>
|
---|
| 199 | There are failures associated with system readline 6.x.
|
---|
| 200 | </para>
|
---|
| 201 | </listitem>
|
---|
[29d11601] | 202 | -->
|
---|
[e2fe6d4] | 203 | <!--
|
---|
[39e42c88] | 204 | <listitem>
|
---|
| 205 | <para>
|
---|
| 206 | A few tests assume that the header file
|
---|
| 207 | <filename><sys/sdt.h></filename>, part of <ulink
|
---|
| 208 | url="https://sourceware.org/systemtap/">SystemTap</ulink>, is
|
---|
| 209 | present.
|
---|
| 210 | </para>
|
---|
| 211 | </listitem>
|
---|
[e2fe6d4] | 212 | -->
|
---|
[29d11601] | 213 | <!-- I don't know if this is true or not. I tested on a Haswell.
|
---|
[24c0a06e] | 214 | <listitem>
|
---|
| 215 | <para>
|
---|
| 216 | If the test suite is run on a Skylake-based Intel CPU or newer,
|
---|
| 217 | many tests will fail due to the removal of the deprecated/problematic
|
---|
| 218 | libmpx library in GCC.
|
---|
| 219 | </para>
|
---|
| 220 | </listitem>
|
---|
[8558044] | 221 | -->
|
---|
[9aeac59] | 222 | <!-- <listitem>
|
---|
[39e42c88] | 223 | <para>
|
---|
[9aeac59] | 224 | -->
|
---|
[1fe05eb] | 225 | <!-- for gdb-11.1, gcc-11.2 - pierre
|
---|
[54bd123] | 226 | A test run of the test suite had about 1700 unexpected failures
|
---|
[f863fd7d] | 227 | (out of over 80000 tests). Over 1370 of the failures were related
|
---|
[e2fe6d4] | 228 | to FORTRAN tests. -->
|
---|
[e440af5] | 229 | <!-- for gdb-12.1, gcc-11.3.0 - bdubbs
|
---|
[e2fe6d4] | 230 | A test run of the test suite had a little over 200 unexpected failures
|
---|
[6f0a8c86] | 231 | out of over 94000 tests.-->
|
---|
[da73c1c] | 232 | <!-- for gdb-13.0, gcc-12.2.0 - bdubbs
|
---|
[6f0a8c86] | 233 | A test run of the test suite had 33 unexpected failures
|
---|
[da73c1c] | 234 | out of over 106000 tests. -->
|
---|
[15abfad] | 235 | <!-- for gdb-13.2, gcc-13.1.0 - pierre
|
---|
[da73c1c] | 236 | A test run of the test suite had 183 unexpected failures
|
---|
[15abfad] | 237 | out of over 105000 tests. -->
|
---|
| 238 | <!-- for gdb-14.1, gcc 13.2.0 - rahul -->
|
---|
[9aeac59] | 239 | <!-- A test run of the test suite had 51 unexpected failures
|
---|
[15abfad] | 240 | out of the over 106000 tests.
|
---|
[39e42c88] | 241 | </para>
|
---|
| 242 | </listitem>
|
---|
[aea8090f] | 243 |
|
---|
[bfbc72a] | 244 | <listitem>
|
---|
| 245 | <para>
|
---|
| 246 | On some systems, the gdb.tui test suite will fail if running over
|
---|
| 247 | SSH.
|
---|
| 248 | </para>
|
---|
| 249 | </listitem>
|
---|
[9aeac59] | 250 | -->
|
---|
[aea8090f] | 251 | <listitem>
|
---|
| 252 | <para>
|
---|
| 253 | On some AMD-based systems, over 200 additional tests
|
---|
| 254 | may fail due to a difference in the threading implementation
|
---|
| 255 | on those CPUs.
|
---|
| 256 | </para>
|
---|
| 257 | </listitem>
|
---|
| 258 |
|
---|
[42b7702d] | 259 | <listitem>
|
---|
| 260 | <para>
|
---|
| 261 | For gdb-15.2, using an Intel i7-14700K, there were 118 unexpected failures
|
---|
| 262 | out of over 116,000 tests.
|
---|
| 263 | </para>
|
---|
| 264 | </listitem>
|
---|
| 265 |
|
---|
[39e42c88] | 266 | </itemizedlist>
|
---|
[4b0ebf70] | 267 |
|
---|
[d3970e1] | 268 | <para>
|
---|
| 269 | Now, as the <systemitem class="username">root</systemitem> user:
|
---|
| 270 | </para>
|
---|
[4b0ebf70] | 271 |
|
---|
[da73c1c] | 272 | <screen role="root"><userinput>make -C gdb install &&
|
---|
| 273 | make -C gdbserver install</userinput></screen>
|
---|
[4b0ebf70] | 274 |
|
---|
[852fc810] | 275 | <para>
|
---|
[46fd248] | 276 | If you have built the API documentation, it is now in gdb/doc/doxy.
|
---|
| 277 | You can install it (as the <systemitem class="username">root</systemitem>
|
---|
| 278 | user):
|
---|
[852fc810] | 279 | </para>
|
---|
| 280 |
|
---|
[a42c273] | 281 | <screen role="root"
|
---|
| 282 | remap="doc"><userinput>install -d /usr/share/doc/gdb-&gdb-version; &&
|
---|
[03b05e7] | 283 | rm -rf gdb/doc/doxy/xml &&
|
---|
[852fc810] | 284 | cp -Rv gdb/doc/doxy /usr/share/doc/gdb-&gdb-version;</userinput></screen>
|
---|
| 285 |
|
---|
[4b0ebf70] | 286 | </sect2>
|
---|
[d3970e1] | 287 |
|
---|
[870e9f05] | 288 | <sect2 role="commands">
|
---|
| 289 | <title>Command Explanations</title>
|
---|
[8558044] | 290 |
|
---|
[870e9f05] | 291 | <para>
|
---|
| 292 | <parameter>--with-system-readline</parameter>: This switch forces
|
---|
| 293 | <application>GDB</application> to use the copy of
|
---|
| 294 | <application>Readline</application> installed in LFS.
|
---|
| 295 | </para>
|
---|
| 296 |
|
---|
[d38dc9a] | 297 | <para>
|
---|
| 298 | <parameter>--with-python=/usr/bin/python3</parameter>: This switch
|
---|
[54bd123] | 299 | forces <application>GDB</application> to use Python 3.
|
---|
[d38dc9a] | 300 | </para>
|
---|
| 301 |
|
---|
[870e9f05] | 302 | </sect2>
|
---|
| 303 |
|
---|
[4b0ebf70] | 304 | <sect2 role="content">
|
---|
| 305 | <title>Contents</title>
|
---|
| 306 |
|
---|
| 307 | <segmentedlist>
|
---|
| 308 | <segtitle>Installed Programs</segtitle>
|
---|
| 309 | <segtitle>Installed Library</segtitle>
|
---|
| 310 | <segtitle>Installed Directories</segtitle>
|
---|
| 311 |
|
---|
| 312 | <seglistitem>
|
---|
[4890200] | 313 | <seg>
|
---|
[da73c1c] | 314 | gcore, gdb, gdbserver, and gdb-add-index
|
---|
[4890200] | 315 | </seg>
|
---|
| 316 | <seg>
|
---|
[da73c1c] | 317 | libinproctrace.so
|
---|
[4890200] | 318 | </seg>
|
---|
| 319 | <seg>
|
---|
[03b05e7] | 320 | /usr/{include,share}/gdb and /usr/share/doc/gdb-&gdb-version;
|
---|
[4890200] | 321 | </seg>
|
---|
[4b0ebf70] | 322 | </seglistitem>
|
---|
| 323 | </segmentedlist>
|
---|
| 324 |
|
---|
| 325 | <variablelist>
|
---|
| 326 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 327 | <?dbfo list-presentation="list"?>
|
---|
| 328 | <?dbhtml list-presentation="table"?>
|
---|
| 329 |
|
---|
[a55a187] | 330 | <varlistentry id="gcore">
|
---|
| 331 | <term><command>gcore</command></term>
|
---|
| 332 | <listitem>
|
---|
| 333 | <para>
|
---|
[4c24eb0a] | 334 | generates a core dump of a running program
|
---|
[a55a187] | 335 | </para>
|
---|
| 336 | <indexterm zone="gdb gcore">
|
---|
| 337 | <primary sortas="b-gcore">gcore</primary>
|
---|
| 338 | </indexterm>
|
---|
| 339 | </listitem>
|
---|
| 340 | </varlistentry>
|
---|
| 341 |
|
---|
[4b0ebf70] | 342 | <varlistentry id="gdb-prog">
|
---|
| 343 | <term><command>gdb</command></term>
|
---|
| 344 | <listitem>
|
---|
[d3970e1] | 345 | <para>
|
---|
[4c24eb0a] | 346 | is the GNU Debugger
|
---|
[d3970e1] | 347 | </para>
|
---|
[4b0ebf70] | 348 | <indexterm zone="gdb gdb-prog">
|
---|
| 349 | <primary sortas="b-gdb-prog">gdb-prog</primary>
|
---|
| 350 | </indexterm>
|
---|
| 351 | </listitem>
|
---|
| 352 | </varlistentry>
|
---|
| 353 |
|
---|
| 354 | <varlistentry id="gdbserver">
|
---|
| 355 | <term><command>gdbserver</command></term>
|
---|
| 356 | <listitem>
|
---|
[d3970e1] | 357 | <para>
|
---|
[4890200] | 358 | is a remote server for the GNU debugger (it allows programs
|
---|
[4c24eb0a] | 359 | to be debugged from a different machine)
|
---|
[d3970e1] | 360 | </para>
|
---|
[4b0ebf70] | 361 | <indexterm zone="gdb gdbserver">
|
---|
| 362 | <primary sortas="b-gdbserver">gdbserver</primary>
|
---|
| 363 | </indexterm>
|
---|
| 364 | </listitem>
|
---|
| 365 | </varlistentry>
|
---|
| 366 |
|
---|
[11f9b1d1] | 367 | <varlistentry id="gdb-add-index">
|
---|
| 368 | <term><command>gdb-add-index</command></term>
|
---|
| 369 | <listitem>
|
---|
| 370 | <para>
|
---|
| 371 | Allows adding index files to ELF binaries. This speeds up
|
---|
| 372 | <command>gdb</command> start on large programs.
|
---|
| 373 | </para>
|
---|
| 374 | <indexterm zone="gdb gdb-add-index">
|
---|
| 375 | <primary sortas="b-gdb-add-index">gdb-add-index</primary>
|
---|
| 376 | </indexterm>
|
---|
| 377 | </listitem>
|
---|
| 378 | </varlistentry>
|
---|
| 379 |
|
---|
[4b0ebf70] | 380 | <varlistentry id="libinproctrace">
|
---|
[4890200] | 381 | <term><filename class="libraryfile">libinproctrace.so</filename></term>
|
---|
[4b0ebf70] | 382 | <listitem>
|
---|
[d3970e1] | 383 | <para>
|
---|
| 384 | contains functions for the in-process tracing agent. The agent
|
---|
| 385 | allows for installing fast tracepoints, listing static tracepoint
|
---|
| 386 | markers, probing static tracepoints markers, and starting trace
|
---|
| 387 | monitoring.
|
---|
| 388 | </para>
|
---|
[4b0ebf70] | 389 | <indexterm zone="gdb libinproctrace">
|
---|
| 390 | <primary sortas="c-libinproctrace">libinproctrace.so</primary>
|
---|
| 391 | </indexterm>
|
---|
| 392 | </listitem>
|
---|
[d3970e1] | 393 | </varlistentry>
|
---|
[11f9b1d1] | 394 |
|
---|
[4b0ebf70] | 395 | </variablelist>
|
---|
| 396 |
|
---|
| 397 | </sect2>
|
---|
| 398 |
|
---|
| 399 | </sect1>
|
---|