Debug The Executable - Red Hat ENTERPRISE LINUX 3 - DEVELOPER TOOLS GUIDE Manual

Developer tools guide
Hide thumbs Also See for ENTERPRISE LINUX 3 - DEVELOPER TOOLS GUIDE:
Table of Contents

Advertisement

14
3.3. Run the Executable
To run the program, use the following example:
./hello
The program generates
hello world!
3 + 4 = 7
and returns when the program exits.

3.4. Debug the Executable

To start GDB, use the following commands:
gdb hello
After the initial copyright and configuration information, GDB returns its own prompt,
following is a sample debugging session:
1. To set a breakpoint, type:
break main
The following output displays:
Breakpoint 1 at 0x132: file hello.c, line 15.
Note the exact address and line number may vary, depending upon the target architecture being
debugged and the exact layout of the C code in the
2. To run the program, type:
run
The following output displays (when the program stops at a breakpoint):
Starting program: hello
Breakpoint 1, main () at hello.c:15
15 a = 3;
Again note that the exact line number and instruction displayed is dependent upon the source
code layout.
3. To print the value of variable,
print a
The following output displays:
$1 = 0
4. To execute the next command, type
next
The following output displays:
16 b = 4;
5. To display the value of a again, type:
print a
The following output displays:
$2 = 3
6. To display the program being debugged, type:
list
Chapter 3. Developing with Red Hat Enterprise Linux Developer Tools
, type:
a
next
file.
hello.c
:
. The
(gdb)

Advertisement

Table of Contents
loading

Table of Contents