Getting Started with GDB139
Now let us debug the output file. Note that when starting
gdb
, you use the output file
sum
on the command line and
gdb
will automatically find out the source code file name (
sum.c
)
from the information stored inside the executable file. An explanation of different
gdb
com-
mands is provided at the end of this debug session. Note that the
next
command is abbreviated
as
n
in this session.
[rr@conformix 5]$ gdb sum
GNU gdb 5.0rh-5 Red Hat Linux 7.1
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public
License, and you are
welcome to change it and/or distribute copies of it under
certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty"
for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) list
1 #include
2 main ()
3 {
4 int num1, num2, total ;
5
6 printf("Enter first number : ");
7 scanf("%d", &num1);
8 printf("Enter second number : ");
9 scanf("%d", &num2);
10
(gdb) list
11 total = num1 + num2;
12
13 printf("\nThe sum is : %d\n", total);
14 }
(gdb) list 1,14
1 #include
2 main ()
3 {
4 int num1, num2, total ;
5
6 printf("Enter first number : ");
7 scanf("%d", &num1);
8 printf("Enter second number : ");
9 scanf("%d", &num2);
10
11 total = num1 + num2;
12
13 printf("\nThe sum is : %d\n", total);
Next Page >>
<< Previous Page
Back to the Table of Contents