This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Throwable.printStackTrace ()


Andrew Haley wrote:

> I've checked in code to print stack traces.  It's not yet perfect, but
> I figured that it's such a useful debugging tool that it makes no
> sense to wait for perfection.

Very cool!!

One comment I would have is that the output may be a bit more verbose than
needed. For example, consider the following stack traces produced by a simple
test program, running under both the IBM VM and gcj:

$ java ExceptionTest
java.lang.Exception
        at ExceptionTest.bar(ExceptionTest.java:23)
        at ExceptionTest.foo(ExceptionTest.java:18)
        at ExceptionTest.main(ExceptionTest.java:8

$ ./exceptiontest
java.lang.Exception
   at 0x400caa48: __Q34java4lang9Throwable (/usr/local/gcc/lib/libgcj.so.1)
   at 0x400beafb: __Q34java4lang9Exception (/usr/local/gcc/lib/libgcj.so.1)
   at 0x0804b2bb: ExceptionTest::bar(int)
(/home/bryce/projects/tests/ExceptionTest.java:22)
   at 0x0804b286: ExceptionTest::foo(void)
(/home/bryce/projects/tests/ExceptionTest.java:18)
   at 0x0804b217: ExceptionTest::main(JArray<java::lang::String *> *)
(/home/bryce/projects/tests/ExceptionTest.java:8)
   at 0x4010ca30: run__Q34java4lang11FirstThread
(/usr/local/gcc/lib/libgcj.so.1)
   at 0x400c81b2: run___Q34java4lang6Thread (/usr/local/gcc/lib/libgcj.so.1)
   at 0x40111fea: run____Q34java4lang6ThreadPQ34java4lang6Object
(/usr/local/gcc/lib/libgcj.so.1)
   at 0x401222e2: _Jv_ThreadSetPriority__FP12_Jv_Thread_ti
(/usr/local/gcc/lib/libgcj.so.1)
   at 0x401d0c56: GC_start_routine (/usr/local/gcc/lib/libgcjgc.so.1)
   at 0x401e6eca: pthread_detach (/lib/libpthread.so.0)

Hmm. I suggest that first two lines and everything below main() are redundant
for the vast majority of debugging tasks. And how useful is having the address?

regards

  [ bryce ]



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]