[MinGW] Slightly More Robust Stacktraces on Windows

Ranjit Mathew rmathew@gmail.com
Thu Jul 6 17:17:00 GMT 2006


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

Hi,

  As discussed earlier, the current hack in fallback_backtrace()
in "sysdep/i386/backtrace.h" works only for static method
invocations, that too without -findirect-dispatch. The attached
patch attempts to make this function a bit more robust by looking
for the following function prologue in function bodies to
determine their respective beginning addresses:

  pushl %ebp
  movl %esp, %ebp

We can assume the presence of this prologue since
fallback_backtrace() anyway needs code compiled with
- -fno-omit-frame-pointer for it to work.

main() is a notable exception to this pattern since GCC
(for MinGW) emits code to first align the stack on a 16-byte
boundary (by default) before emitting the function prologue.

In any case, we do not need to unwind all the way back to
main() - stopping at JvRunMain() should suffice. This is not just
a nifty optimisation; it prevents us from following wild %ebp
values beyond the programme's initial call stack frame.

The attached patch makes stack traces work with static
and instance methods, compiled with or without -findirect-dispatch
(as far as a very light testing could tell). It was tested
using an i686-pc-linux-gnu to i686-pc-mingw32 cross-compiler.

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

iD8DBQFErUWbYb1hx2wRS48RAgxoAJ0TpEgewUUmMqaMYuWYt+/XPKG2vACgoqUM
81MwqDjjpNlbI3uo1V838Mc=
=RF2E
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: p1.txt
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20060706/da0c8f9c/attachment.txt>


More information about the Java-patches mailing list