hchen@ubuntu:~/java$
gdb ./sum Copyright (C) 2006 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 "i486-linux-gnu"...
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
3 public static long Sum(int n){
12 public static final void main( String argc[] ) {
15 for (i=1; i<=100; i++){
18 System.out.println("result = "+result);
19 System.out.println("result = "+Sum(1000));
Breakpoint 1 at 0x8048d38: file sum.java, line 13.
Breakpoint 2 at 0x8048d61: file sum.java, line 16.
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 (argc=@2bfa8) at sum.java:14
Current language: auto; currently java
(gdb) break sum.Sum <----- 设置函数断点 Breakpoint 3 at 0x8048b68: file sum.java, line 4.
Breakpoint 2, sum.main(java.lang.String[])void (argc=@2bfa8) at sum.java:16
<--- 条件断点 15 for (i=1; i<=100; i++){
Breakpoint 3, sum.Sum(int)long (n=1000) at sum.java:4
<----- 函数断点 #0 sum.Sum(int)long (n=1000) at sum.java:4
#1 0x08048edf in sum.main(java.lang.String[])void (argc=@2bfa8) 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
Run till exit from #0 sum.Sum(int)long (n=1000) at sum.java:5
0x08048edf in sum.main(java.lang.String[])void (argc=@2bfa8) at sum.java:19
19 System.out.println("result = "+Sum(1000));
Value returned is $1 = 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