[MinGW] RFA: Make Stack Traces Work for Interpreted Code on Windows

Ranjit Mathew rmathew@gmail.com
Sun Jul 9 09:19:00 GMT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

  When run under the interpreter, an exception-throwing programme
crashes the interpreter on Windows since JvRunMain() does not
occur in the call stack and we once again roam the wilderness of
arbitrary EBP values.

The fix was to change fallback_backtrace() in
"sysdep/i386/backtrace.h" to stop on _Jv_RunMain() instead since
this does occur in both interpreted and natively-executed call
stacks. (Since this function is overloaded, I needed to use an
interim variable with the appropriate cast to tell the compiler
which of these function variants to pick up.)

fallback_backtrace() also does not correctly handle unwinding
through interpreted code. The fix was as simple as copying the
relevant bits of code from _Jv_StackTrace::Unwind_TraceFn() and
adjusting it a little bit.

This exposed the fact that _Jv_InterpMethod::run() is a private
method. Therefore I had to declare fallback_backtrace() as
a friend function for this class (similar to that for the
_Jv_StackTrace class). This declaration is done only if
HAVE_FALLBACK_BACKTRACE is defined. This definition in turn was
moved out of "sysdep/i386/backtrace.h" to configure.host, where
it is added to libgcj_cxxflags (this jugglery avoids having to deal
with included file ordering issues).

The attached patch contains all these changes. Note that it also
contains the "sysdep/i386/backtrace.h" changes from:

  http://gcc.gnu.org/ml/java-patches/2006-q3/msg00098.html

purely as a matter of convenience for yours truly.

With this patch, we now get proper stack traces for interpreted
code also on Windows. (I note that under the interpreter we do
not get line numbers for the innermost call frame, even on Linux.
I haven't investigated this issue yet.)

Tested via a crossed-native i686-pc-mingw32 compiler built on
i686-pc-linux-gnu.

OK to apply?

Thanks,
Ranjit.

- --
Ranjit Mathew       Email: rmathew AT gmail DOT com

Bangalore, INDIA.     Web: http://rmathew.com/




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEsMo5Yb1hx2wRS48RAmZmAJsHu0Iyx3r9W4ILKg27BMBDC1sOZwCgix8m
CFfW9c39jTSvqNxoH6lBLxY=
=wLCp
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: p2.txt
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20060709/8c852163/attachment.txt>


More information about the Java-patches mailing list