Debugging HelloWorld program

Tom.Williams@diversifiedsoftware.com Tom.Williams@diversifiedsoftware.com
Wed Oct 11 16:15:00 GMT 2000


Hi!  Thanks again for the info!  This is the VERY first time I've ever used
gdb so please excuse my ignorance.  I switched to the "desired" thread and
ran the "bt" command.  It looks like the time is being spent in
__gconv_transform_ucs2_internal.  I also see the letter "e" in part of that
stack trace line so I guess the letter "e" in "Hello World" is being
converted or something.

Here is the stack trace on that thread:

Program received signal SIGINT, Interrupt.
[Switching to Thread 1024 (runnable)]
0x4040dcbe in __sigsuspend (set=0xbffff9ac) at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
48      ../sysdeps/unix/sysv/linux/sigsuspend.c: No such file or directory.
(gdb) info threads
  3 Thread 1026 (runnable)  0x4049415a in __gconv_transform_ucs2_internal (step=0x80c81d0, data=0x80c83c8, inbuf=0xbf7ffacc, inbufend=0x808bf26 "e",
    written=0xbf7ffa90, do_flush=0) at ../iconv/skeleton.c:202
  2 Thread 2049 (runnable)  0x404882cd in __poll (fds=0x80d25a0, nfds=1, timeout=2000) at ../sysdeps/unix/sysv/linux/poll.c:45
* 1 Thread 1024 (runnable)  0x4040dcbe in __sigsuspend (set=0xbffff9ac) at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
(gdb) thread 3
[Switching to thread 3 (Thread 1026 (runnable))]
#0  0x4049415a in __gconv_transform_ucs2_internal (step=0x80c81d0, data=0x80c83c8, inbuf=0xbf7ffacc, inbufend=0x808bf26 "e", written=0xbf7ffa90,
do_flush=0)
    at ../iconv/skeleton.c:202
202     ../iconv/skeleton.c: No such file or directory.
(gdb) bt
#0  0x4049415a in __gconv_transform_ucs2_internal (step=0x80c81d0, data=0x80c83c8, inbuf=0xbf7ffacc, inbufend=0x808bf26 "e", written=0xbf7ffa90,
do_flush=0)
    at ../iconv/skeleton.c:202
#1  0x40490c2d in __gconv (cd=0x80c83c0, inbuf=0xbf7ffacc, inbufend=0x808bf26 "e", outbuf=0xbf7ffac8, outbufend=0x8087fbc "", converted=0xbf7ffa90) at
 gconv.c:59
#2  0x404907d6 in iconv (cd=0x80c83c0, inbuf=0xbf7ffacc, inbytesleft=0xbf7ffad4, outbuf=0xbf7ffac8, outbytesleft=0xbf7ffad0) at iconv.c:52
#3  0x4022796f in gnu::gcj::convert::Output_iconv::write (this=0x8069348, inbuffer=0x808bf00, inpos=0, count=26) at
../../../libjava/gnu/gcj/convert/natIconv.cc:30
#4  0x4014aab2 in gnu.gcj.convert.UnicodeToBytes.write (this=0x8069348, str=0x8068780, inpos=0, inlength=26, work=0x808bf00)
    at ../../../libjava/gnu/gcj/convert/UnicodeToBytes.java:123
#5  0x401b6140 in java.io.PrintStream.writeChars (this=0x8066ce0, str=0x8068780, offset=0, count=26) at ../../../libjava/java/io/PrintStream.java:130
#6  0x401b5d10 in java.io.PrintStream.print (this=0x8066ce0, str=0x8068780, println=true) at ../../../libjava/java/io/PrintStream.java:63
#7  0x401b6762 in java.io.PrintStream.println (this=0x8066ce0, str=0x8068780) at ../../../libjava/java/io/PrintStream.java:220
#8  0x804b88a in HelloWorld.main (args=0x4037cdcc) at HelloWorld.java:5
#9  0x4022abcd in gnu::gcj::runtime::FirstThread::run (this=0x8067ea0) at ../../../libjava/gnu/gcj/runtime/natFirstThread.cc:146
#10 0x40235767 in java::lang::Thread::run_ (obj=0x8067ea0) at ../../../libjava/java/lang/natThread.cc:263
#11 0x40246dd1 in really_start (x=0x80a5ff8) at ../../../libjava/posix-threads.cc:344
#12 0x403b7563 in GC_start_routine (arg=0x807ffc0) at ../../../boehm-gc/linux_threads.c:631
#13 0x403cfd27 in pthread_start_thread (arg=0xbf7ffe40) at manager.c:241
#14 0x403cfd6a in pthread_start_thread_event (arg=0xbf7ffe40) at manager.c:264
(gdb)

Peace......

Tom




Bryce McKinlay
10/12/2000 04:29 AM

Sent by:  bryce


To:   Tom.Williams@diversifiedsoftware.com
cc:   java-discuss@sources.redhat.com

Subject:  Re: Debugging HelloWorld program


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