walking the stack

Andrew Haley aph@cambridge.redhat.com
Mon Apr 15 03:01:00 GMT 2002


Anthony Green writes:
 > I've been experimenting with an implementation of the Java's sandbox
 > design.
 > 
 > The idea is to map ProtectionDomains to PC ranges.  I determine PC
 > ranges by modifying libgcj.spec to link jrtbegin.o and jrtend.o before
 > and after all other files.  These object files contain the bits
 > necessary to determine the range of code needing registration with the
 > runtime.  For interpreted code I just need to register the closure stub.
 > 
 > Running a check for a priviliged action involves walking the stack and
 > examining the details of the appropriate ProtectionDomains along the
 > way.  My current experiments involve using glibc's backtrace()
 > function.   My questions...
 > 
 > 1) Is this reliable on all glibc ports?

It doesn't work everywhere, but where it is implemented it works well.
It depends on the ABI.

 > 2) Is there some better way to get stack trace info?  Like using the
 > DWARF2 data if it exists.

Yes.

 > 3) Is there a better way to do all of this?

There sure is: David Mosberger's libunwind.

Andrew.



More information about the Java mailing list