~> gdb pi GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) Copyright 2003 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-gnu"... (gdb) list 1 #include 2 3 int main (){ 4 5 int i ; 6 double pi = 0 ; 7 8 for (i=0; i<10000000; i++) 9 10 pi += pow (-1,i) / (2*i+1) ; (gdb) run Starting program: /home/prof/maziero/ambiente/pi O valor aproximado de Pi é: 3.141593 Program exited with code 045. (gdb) disassemble main Dump of assembler code for function main: 0x080483ac : push %ebp 0x080483ad : mov %esp,%ebp 0x080483af : sub $0x18,%esp 0x080483b2 : and $0xfffffff0,%esp 0x080483b5 : mov $0x0,%eax 0x080483ba : sub %eax,%esp 0x080483bc : movl $0x0,0xfffffff0(%ebp) 0x080483c3 : movl $0x0,0xfffffff4(%ebp) 0x080483ca : movl $0x0,0xfffffffc(%ebp) 0x080483d1 : cmpl $0x98967f,0xfffffffc(%ebp) 0x080483d8 : jle 0x80483dc 0x080483da : jmp 0x8048414 0x080483dc : fildl 0xfffffffc(%ebp) 0x080483df : lea 0xfffffff8(%esp,1),%esp 0x080483e3 : fstpl (%esp,1) 0x080483e6 : push $0xbff00000 0x080483eb : push $0x0 0x080483ed : call 0x80482cc 0x080483f2 : add $0x10,%esp 0x080483f5 : mov 0xfffffffc(%ebp),%eax 0x080483f8 : shl %eax 0x080483fa : inc %eax 0x080483fb : push %eax 0x080483fc : fildl (%esp,1) 0x080483ff : lea 0x4(%esp,1),%esp 0x08048403 : fdivrp %st,%st(1) 0x08048405 : fldl 0xfffffff0(%ebp) 0x08048408 : faddp %st,%st(1) 0x0804840a : fstpl 0xfffffff0(%ebp) 0x0804840d : lea 0xfffffffc(%ebp),%eax 0x08048410 : incl (%eax) 0x08048412 : jmp 0x80483d1 0x08048414 : fldl 0xfffffff0(%ebp) 0x08048417 : fldl 0x8048520 0x0804841d : fmulp %st,%st(1) 0x0804841f : fstpl 0xfffffff0(%ebp) 0x08048422 : sub $0x4,%esp 0x08048425 : pushl 0xfffffff4(%ebp) 0x08048428 : pushl 0xfffffff0(%ebp) 0x0804842b : push $0x8048500 0x08048430 : call 0x80482ec 0x08048435 : add $0x10,%esp 0x08048438 : leave 0x08048439 : ret End of assembler dump. (gdb) break main Breakpoint 1 at 0x80483bc: file pi.c, line 6. (gdb) run Starting program: /home/prof/maziero/ambiente/pi Breakpoint 1, main () at pi.c:6 6 double pi = 0 ; (gdb) next 8 for (i=0; i<10000000; i++) (gdb) next 10 pi += pow (-1,i) / (2*i+1) ; (gdb) print pi $1 = 0 (gdb) print i $2 = 0 (gdb) next 8 for (i=0; i<10000000; i++) (gdb) next 10 pi += pow (-1,i) / (2*i+1) ; (gdb) pi rint pi $3 = 1 (gdb) print i $4 = 1 (gdb) cont Continuing. O valor aproximado de Pi é: 3.141593 Program exited with code 045. (gdb) quit