7.3. Running the GNU Debugger

To run the GNU Debugger on a program you want to debug, type the following at a shell prompt:
scl enable devtoolset-4 'gdb file_name'
This starts the gdb debugger in interactive mode and displays the default prompt, (gdb). To quit the debugging session and return to the shell prompt, run the following command at any time:
Note that you can execute any command using the scl utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset gdb as default:
scl enable devtoolset-4 'bash'


To verify the version of gdb you are using at any point, type the following at a shell prompt:
which gdb
Red Hat Developer Toolset's gdb executable path will begin with /opt. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset gdb:
gdb -v

Example 7.3. Running the gdb Utility on the fibonacci Binary File

Assuming that you have successfully compiled the fibonacci binary file as shown in Example 7.1, “Compiling a C Program With Debugging Information”, you can start debugging it with gdb by typing the following at a shell prompt:
~]$ scl enable devtoolset-4 'gdb fibonacci'
GNU gdb (GDB) Red Hat Enterprise Linux (7.10-20.el7)
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word".