Debugging HelloWorld program

Bryce McKinlay bryce@albatross.co.nz
Wed Oct 11 16:10:00 GMT 2000


Tom.Williams@diversifiedsoftware.com wrote:

[...]

> Program received signal SIGINT, Interrupt.
> [Switching to Thread 1024 (runnable)]
> 0x4040dcbe in __sigsuspend (set=0xbffff99c) at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
> 48      ../sysdeps/unix/sysv/linux/sigsuspend.c: No such file or directory.
> (gdb) bt
> #0  0x4040dcbe in __sigsuspend (set=0xbffff99c) at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
> #1  0x403d1e44 in __pthread_wait_for_restart_signal (self=0x403d9b60) at pthread.c:785
> #2  0x403ceb30 in pthread_cond_wait (cond=0x40385740, mutex=0x40385728) at restart.h:26
> #3  0x40246f8c in _Jv_ThreadWait () at ../../../libjava/posix-threads.cc:410
> #4  0x40134a98 in JvRunMain (klass=0x804cae0, argc=1, argv=0xbffffb54) at ../../../libjava/prims.cc:888
> #5  0x804b8e3 in main (argc=1, argv=0xbffffb54) at /tmp/ccO6XxTUmain.i:11
> #6  0x40407d2e in __libc_start_main (main=0x804b8c0 <main>, argc=1, argv=0xbffffb54, init=0x8048f40 <_init>, fini=0x804b92c <_fini>,
> rtld_fini=0x4000a720 <_dl_fini>, stack_end=0xbffffb4c)
>     at ../sysdeps/generic/libc-start.c:92
> (gdb) continue
> Continuing.

That's a stack trace of the initial (posix/C) "main" thread. If you look
in JvRunMain() in prims.cc, you'll see that all it does it
start the java "main" thread and waits until all other threads have
died. gdb will usually automatically switch you to the thread thats
doing the work, but in this case it hasn't done that. Try using the
"info threads" and "thread n" commands to switch to the main thread
(should be the highest numbered one) and get a stack trace of that,
which should be more interesting.

Another option is to start gdb in another window and use the "attach"
command to observe the already-running Java application (you
should attach to the lowest numbered pid for threads to work correctly).

regards

  [ bryce ]


More information about the Java mailing list