Red Hat Developer Toolset 1.x User Guide - Linux
Red Hat Developer Toolset 1.x User Guide - Linux
Red Hat Developer Toolset 1.x User Guide - Linux
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
28 Chapter 3. GNU Debugger (GDB)<br />
Chapter 3. GNU Debugger (GDB)<br />
The GNU Debugger, commonly abbreviated as GDB, is a command line tool that can be used to debug<br />
programs written in various programming languages. It allows you to inspect memory within the code<br />
being debugged, control the execution state of the code, detect the execution of particular sections of<br />
code, and much more.<br />
<strong>Red</strong> <strong>Hat</strong> <strong>Developer</strong> <strong>Toolset</strong> is distributed with GDB 7.5. This version is more recent than the version<br />
included in <strong>Red</strong> <strong>Hat</strong> Enterprise <strong>Linux</strong> and provides numerous bug fixes and enhancements, including<br />
improved support for Python scripting, ambiguous line specifications, and tracepoints, as well as<br />
improved inferior control commands and handling of C++ debugee executables. For a detailed list of<br />
changes, refer to Section B.2, “Changes in GDB 7.5”.<br />
3.1. Installing the GNU Debugger<br />
In <strong>Red</strong> <strong>Hat</strong> <strong>Developer</strong> <strong>Toolset</strong>, the GNU Debugger is provided by the devtoolset-1.1-gdb package, and is<br />
automatically installed with devtoolset-1.1 as described in Section 1.5, “Installing <strong>Red</strong> <strong>Hat</strong> <strong>Developer</strong><br />
<strong>Toolset</strong>”.<br />
3.2. Preparing a Program for Debugging<br />
Compiling Programs with Debugging Information<br />
To compile a C program with debugging information that can be read by the GNU Debugger, make sure<br />
the gcc compiler is run with the -g option. To do so on the command line, use a command in the<br />
following form:<br />
scl enable devtoolset-1.1 'gcc -g -o output_file input_file...'<br />
Similarly, to compile a C++ program with debugging information, run:<br />
scl enable devtoolset-1.1 'g++ -g -o output_file input_file...'