(gdb) r
Starting program: /home/hchen/java/sum
[Thread debugging using libthread_db enabled]
[New Thread -1243736400 (LWP 18131)]
[New Thread -1245406320 (LWP 18134)]
[Switching to Thread -1243736400 (LWP 18131)]
Breakpoint 1, sum.main(java.lang.String[])void ([email protected]) at sum.java:14
14 int result=0;
Current language: auto; currently java
(gdb) break sum.Sum
Breakpoint 3 at 0x8048b68: file sum.java, line 4.
(gdb) c
Continuing.
Breakpoint 2, sum.main(java.lang.String[])void ([email protected]) at sum.java:16
16 result += i;
(gdb) p result
$2 = 1225
(gdb) n
15 for (i=1; i<=100; i++){
(gdb) c
Continuing.
result = 5050
Breakpoint 3, sum.Sum(int)long (n=1000) at sum.java:4
4 long result=0, i;
(gdb) bt
#0 sum.Sum(int)long (n=1000) at sum.java:4
#1 0x08048edf in sum.main(java.lang.String[])void ([email protected]) at sum.java:19
#2 0xb6b17611 in gnu::java::lang::MainThread::call_main () from /usr/lib/libgcj.so.81
#3 0xb6b86797 in gnu::java::lang::MainThread::run () from /usr/lib/libgcj.so.81
#4 0xb6b29cf3 in _Jv_ThreadRun () from /usr/lib/libgcj.so.81
#5 0xb6ad77dd in _Jv_RunMain () from /usr/lib/libgcj.so.81
#6 0xb6ad7994 in _Jv_RunMain () from /usr/lib/libgcj.so.81
#7 0xb6ad7a1b in JvRunMain () from /usr/lib/libgcj.so.81
#8 0x08048b38 in main (argc=Cannot access memory at address 0x0) at /tmp/ccKMKFB0.i:11
(gdb) n
5 for(i=0; i
(gdb) n
6 result += i;
(gdb) n
5 for(i=0; i
(gdb) finish
Run till exit from #0 sum.Sum(int)long (n=1000) at sum.java:5
0x08048edf in sum.main(java.lang.String[])void ([email protected]) at sum.java:19
19 System.out.println("result = "+Sum(1000));
Value returned is $1 = 499500
(gdb) n
result = 499500
0xb6b17611 in gnu::java::lang::MainThread::call_main () from /usr/lib/libgcj.so.81
(gdb) info thread
2 Thread -1245553776 (LWP 18143) 0xffffe410 in __kernel_vsyscall ()
* 1 Thread -1243883856 (LWP 18142) 0xb6b17611 in gnu::java::lang::MainThread::call_main () from /usr/lib/libgcj.so.81
(gdb)