Preliminary patch: New stack trace infrastructure

Bryce McKinlay mckinlay@redhat.com
Fri Nov 26 06:48:00 GMT 2004


There is still some cleanup work to be done and missing pieces to be 
filled in (most noteably, AccessController), but here is a preliminary 
snapshot of the new stack trace infrastructure code.

Basically, this code will give clean looking, accurate stack traces 
using the DWARF2 debugging information and gcj's compiled metadata.

Key benefits:

- It gives stack traces, complete with line numbers, through interpreted 
bytecode (part of this code is based on an earlier implementation from 
Mark Wielaard - thanks Mark!)
- It gives stack traces through shared libraries. Currently, addr2line 
is still used to do this, which can be a noticeable performance problem 
when it has to open big libraries like libgcj, but I plan to integrate 
Casey Marshall's DWARF2 debug-info reading code soon. For now we may 
wish to disable addr2line usage for applications where printStackTrace() 
must be fast.
- Stack trace implementation is secure: stack frame -> class association 
is no longer based on mangled names, so classes wont be able to 
illegally elevate their privileges just by being called the same name as 
a secure class.
- Stack printing looks nicer and is smarter about which frames to 
include or exclude.

Behold:

$ gij Hello
Exception in thread "main" java.lang.ClassNotFoundException: asdasda not 
found in [file:./, core:/]
   at java.net.URLClassLoader.findClass (URLClassLoader.java:960)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:314)
   at java.lang.Class.forName (natClass.cc:89)
   at Hello.main (Hello.java:13)

$ gcj -g -O2 Hello.java --main=Hello
$ ./a.out
Exception in thread "main" java.lang.ClassNotFoundException: asdasda not 
found in [file:./, core:/]
   at java.net.URLClassLoader.findClass (URLClassLoader.java:960)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:314)
   at java.lang.Class.forName (natClass.cc:89)
   at Hello.main (Hello.java:13)

I've been using this for a while locally, so I'm confident that this 
code is reasonably stable on Linux systems, however systems that don't 
use DWARF2 EH (eg Windows) will need work.

Bryce

-------------- next part --------------
A non-text attachment was scrubbed...
Name: libjava-stacktrace-26112004.patch
Type: text/x-patch
Size: 78284 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20041126/6e2987fc/attachment.bin>


More information about the Java-patches mailing list