This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: Add raw address to java stack trace if line number unavailable.


David Daney wrote:
This patch adds a new system property 'gnu.gcj.runtime.NameFinder.show_raw' that when set true will print the IP in the stack trace if the line number is unavailable. When set the trace will look something like this:

[daney@dl2 junk]$ ./Hello
Hello World
java.lang.NullPointerException
   at Hello.f1(./Hello [8048bd5])
   at Hello.main(./Hello [8048c67])
java.lang.NullPointerException
   at H1.foo(./Hello [8048d53])
   at Hello.main(./Hello [8048ca8])
java.lang.NullPointerException
   at java.util.Date.parse(Date.java:767)
   at Hello.main(./Hello [8048ce9])


You can see that libgcj was compiled with -g so java.util.Date.parse has a line number. My test program (Hello) was compiled without -g so you get the offset printed out along with the object name. This allows you to use addr2line in an off-line mode to find the line numbers if desired.


This can be used in conjunction with the 'gnu.gcj.runtime.NameFinder.use_addr2line' to disable line number generation at runtime (for better performance), but still be able to get the line number information if desired.

Back in 3.3 and 3.4 the addresses used to print out, but that capability was lost with the new stack trace infrastructure. So in someways you could look at this as fixing a regression.

Currently regression testing on i686-pc-linux-gnu.

OK to commit if no regressions?

Testing completed with no failures for make -k check in libjava.



gcc/java: 2006-06-05 David Daney <ddaney@avtrex.com>

    * gcj.texi (libgcj Runtime Properties): Document
    gnu.gcj.runtime.NameFinder.show_raw and
    gnu.gcj.runtime.NameFinder.remove_unknown.


libjava: 2006-06-05 David Daney <ddaney@avtrex.com>

    * gnu/gcj/runtime/NameFinder.java (show_raw): New field.
    (showRaw): New method.
    * stacktrace.cc : Include gnu/gcj/runtime/StringBuffer.h.
    (getLineNumberForFrame): Show IP offset in trace if line number
    not available and show_raw true.




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