Working with the Stack147
[rr@conformix 5]$ gdb sumf
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) break main
Breakpoint 1 at 0x8048496: file sumf.c, line 9.
(gdb) run
Starting program: /home/rr/5/sumf
Breakpoint 1, main () at sumf.c:9
9 printf("Enter first number : ");
(gdb) next
10 scanf("%d", &num1);
(gdb) next
Enter first number : 30
11 printf("Enter second number : ");
(gdb) next
12 scanf("%d", &num2);
(gdb) next
Enter second number : 40
14 total = sum(num1, num2);
(gdb) step
sum (num1=30, num2=40) at sumf.c:21
21 result = num1 + num2 ;
(gdb) next
22 printf("\nCalculation complete. Returning ...\n");
(gdb) frame
#0 sum (num1=30, num2=40) at sumf.c:22
22 printf("\nCalculation complete. Returning ...\n");
(gdb) info frame
Stack level 0, frame at 0xbffffa08:
eip = 0x804851b in sum (sumf.c:22); saved eip 0x80484ec
called by frame at 0xbffffa38
source language c.
Arglist at 0xbffffa08, args: num1=30, num2=40
Locals at 0xbffffa08, Previous frame's sp is 0x0
Saved registers:
ebp at 0xbffffa08, eip at 0xbffffa0c
(gdb) info args
num1 = 30
num2 = 40