3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Installing%20GDB">Installing GDB
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Maintenance-Commands.html#Maintenance%20Commands">Maintenance Commands
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Using-History-Interactively.html#Using%20History%20Interactively">Using History Interactively
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"index.html#Top">Top
</a>
19 <h2 class=
"appendix">Installing GDB
</h2>
21 GDB comes with a
<code>configure
</code> script that automates the process
22 of preparing GDB for installation; you can then use
<code>make
</code> to
23 build the
<code>gdb
</code> program.
25 <p>The GDB distribution includes all the source code you need for
26 GDB in a single directory, whose name is usually composed by
27 appending the version number to
<code>gdb
</code>.
29 <p>For example, the GDB version
5.2.1 distribution is in the
30 <code>gdb-
5.2.1</code> directory. That directory contains:
33 <dt><code>gdb-
5.2.1/configure
</code>(and supporting files)
<code></code>
34 <dd>script for configuring GDB and all its supporting libraries
36 <br><dt><code>gdb-
5.2.1/gdb
</code>
37 <dd>the source specific to GDB itself
39 <br><dt><code>gdb-
5.2.1/bfd
</code>
40 <dd>source for the Binary File Descriptor library
42 <br><dt><code>gdb-
5.2.1/include
</code>
43 <dd><small>GNU
</small> include files
45 <br><dt><code>gdb-
5.2.1/libiberty
</code>
46 <dd>source for the
<code>-liberty
</code> free software library
48 <br><dt><code>gdb-
5.2.1/opcodes
</code>
49 <dd>source for the library of opcode tables and disassemblers
51 <br><dt><code>gdb-
5.2.1/readline
</code>
52 <dd>source for the
<small>GNU
</small> command-line interface
54 <br><dt><code>gdb-
5.2.1/glob
</code>
55 <dd>source for the
<small>GNU
</small> filename pattern-matching subroutine
57 <br><dt><code>gdb-
5.2.1/mmalloc
</code>
58 <dd>source for the
<small>GNU
</small> memory-mapped malloc package
61 <p>The simplest way to configure and build GDB is to run
<code>configure
</code>
62 from the
<code>gdb-
</code><var>version-number
</var><code></code> source directory, which in
63 this example is the
<code>gdb-
5.2.1</code> directory.
65 <p>First switch to the
<code>gdb-
</code><var>version-number
</var><code></code> source directory
66 if you are not already in it; then run
<code>configure
</code>. Pass the
67 identifier for the platform on which GDB will run as an
72 <pre class=
"example"> cd gdb-
5.2.1
73 ./configure
<var>host
</var>
77 <p>where
<var>host
</var> is an identifier such as
<code>sun4
</code> or
78 <code>decstation
</code>, that identifies the platform where GDB will run.
79 (You can often leave off
<var>host
</var>;
<code>configure
</code> tries to guess the
80 correct value by examining your system.)
82 <p>Running
<code>configure
</code><var>host
</var><code></code> and then running
<code>make
</code> builds the
83 <code>bfd
</code>,
<code>readline
</code>,
<code>mmalloc
</code>, and
<code>libiberty
</code>
84 libraries, then
<code>gdb
</code> itself. The configured source files, and the
85 binaries, are left in the corresponding source directories.
87 <p><code>configure
</code> is a Bourne-shell (
<code>/bin/sh
</code>) script; if your
88 system does not recognize this automatically when you run a different
89 shell, you may need to run
<code>sh
</code> on it explicitly:
91 <pre class=
"example"> sh configure
<var>host
</var>
94 <p>If you run
<code>configure
</code> from a directory that contains source
95 directories for multiple libraries or programs, such as the
96 <code>gdb-
5.2.1</code> source directory for version
5.2.1,
<code>configure
</code>
97 creates configuration files for every directory level underneath (unless
98 you tell it not to, with the
<code>--norecursion
</code> option).
100 <p>You can run the
<code>configure
</code> script from any of the
101 subordinate directories in the GDB distribution if you only want to
102 configure that subdirectory, but be sure to specify a path to it.
104 <p>For example, with version
5.2.1, type the following to configure only
105 the
<code>bfd
</code> subdirectory:
107 <pre class=
"example"> cd gdb-
5.2.1/bfd
108 ../configure
<var>host
</var>
111 <p>You can install
<code>gdb
</code> anywhere; it has no hardwired paths.
112 However, you should make sure that the shell on your path (named by
113 the
<code>SHELL
</code> environment variable) is publicly readable. Remember
114 that GDB uses the shell to start your program--some systems refuse to
115 let GDB debug child processes whose programs are not readable.
118 <li><a accesskey=
"1" href=
"Separate-Objdir.html#Separate%20Objdir">Separate Objdir
</a>: Compiling GDB in another directory
119 <li><a accesskey=
"2" href=
"Config-Names.html#Config%20Names">Config Names
</a>: Specifying names for hosts and targets
120 <li><a accesskey=
"3" href=
"Configure-Options.html#Configure%20Options">Configure Options
</a>: Summary of options for configure