This is the mail archive of the java@gcc.gnu.org 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]
Other format: [Raw text]

Re: backtrace() vs. _Unwind_Backtrace()


On Dec 5, 2003, at 11:46 PM, Andrew Haley wrote:

Java uses backtrace() a lot, and _Unwind_Backtrace() is inefficient.
I see no good reason to switch unless backtrace() doesn't work on a
given target.

I disagree - backtrace() tells us nothing. All it gives us is the IP for the frame. We need more: the start address of the function, or some other way to map to the Class and _Jv_Method that the frame belongs to. To get that we need to use the unwinder anyway!


Also, backtrace() is not flexible - for most of the checks that need to be fast, we only need to look at the top 1 or 2 frames. Since _Unwind_backtrace has a callback that lets us stop walking the stack once we've got what we need, its unlikely to be any less efficient than having to allocate a buffer to store the entire stack and possibly extend it if its too small and call backtrace again.

Further more, backtrace won't work if someone decides to compile their code without frame pointers. And its not a standard POSIX function to my knowledge, thus not portable at all. Using it is just too fragile.

Regards

Bryce.



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