168Chapter5 • Working with GNU Debugger
With every
finish
command, you can see the function that you were into and the return
value of that function. When you are back in the
main
function, you can use the
next
com-
mand to start tracing the execution line by line. Note that when you trace through, the output of
the process will appear in the window where you started the program. You will also enter the
input values in the same window. All those functions we had to finish were just part of the stan-
dard C libraries, and you could actually step into them anytime from this program as well, but
you normally wouldn't.
5.11Installing GDB
GNU debugger is included in all Linux distributions in the development package. In certain
cases, you may want to get a new copy in the source code form and build and install it manually.
The compilation and building process is similar to other GNU development tools. By this time
you have already built and installed the GNU compiler and the C library. With that experience,
you should not find the compilation and installation of GNU debugger difficult.
5.11.1Downloading and Building
You can download the latest version from ftp://ftp.gnu.org/gnu/gdb directory. The current
version at the time of writing this book is 5.1.1. The source code is available in the compressed
tar
format. The file name is
gdb-5.1.1.tar.gz
. You have to uncompress it using the fol-
lowing command.
tar zxvf gdb-5.1.1.tar.gz
I have untarred this file in
/opt
directory. The
tar
program will create
/opt/gdb-
5.1.1
directory and uncompress all source code tree under this directory. Move into this direc-
tory using the
cd
command. Run the
configure
script and the
make
command to build and
install the debugger. This is a similar process as with all other GNU tools. The following com-
mands will build
gdb
.
cd /opt/gdb-5.1.1
./configure –-prefix=/opt/gcc-3.0.4
make
Note that –
-prefix
shows the directory where the
gdb
binary and other files will be
installed. Usually this is the same directory where your other development tools are installed.
5.11.2Final Installation
The following command places the
gdb
binary and other files in the proper location. After
running this command, you can start using the new debugger.
make install