This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[MinGW] RFA: Fix GetCallerInfo() for Targets Using SJLJ EH
- From: Ranjit Mathew <rmathew at gmail dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Sat, 08 Jul 2006 09:40:22 +0530
- Subject: [MinGW] RFA: Fix GetCallerInfo() for Targets Using SJLJ EH
- Openpgp: url=http://ranjitmathew.hostingzero.com/aa_6C114B8F.txt
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
_Jv_StackTrace::GetCallerInfo() in stacktrace.cc does not
do anything if the target uses SJLJ EH. The attached patch
proposes to fix this. It also changes fallback_backtrace()
in sysdep/i386/backtrace.h to call the trace callback
function in STATE, if any, and to update STATE->POS with
every frame rather than once at the end.
It seems difficult to exercise this code path though.
Class.forName() doesn't use this function any more and
it indeed works for MinGW even without this patch.
Class.getClassLoader() also seems to ordinarily bypass
this function.
Tested via an i686-pc-linux-gnu to i686-pc-mingw32
cross-compiler.
OK to apply to trunk?
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
iD8DBQFErzAuYb1hx2wRS48RAsjYAKCLlc9Y8tsGm4BxL9Utl4fde75ogACcDNMP
LbxvEYMcvsD5Q9grbKcRRIA=
=5w+2
-----END PGP SIGNATURE-----
Index: ChangeLog
from Ranjit Mathew <rmathew@gcc.gnu.org>
* stacktrace.cc (_Jv_StackTrace::GetCallerInfo): Use
fallback_backtrace() for targets using SJLJ EH.
* sysdep/i386/backtrace.h (fallback_backtrace): If STATE has a
trace callback function, call it for every frame. Update STATE->POS
for every frame instead of once at the end of the backtrace process.
Index: stacktrace.cc
===================================================================
--- stacktrace.cc (revision 115260)
+++ stacktrace.cc (working copy)
@@ -421,7 +421,6 @@ void
_Jv_StackTrace::GetCallerInfo (jclass checkClass, jclass *caller_class,
_Jv_Method **caller_meth)
{
-#ifndef SJLJ_EXCEPTIONS
int trace_size = 20;
_Jv_StackFrame frames[trace_size];
_Jv_UnwindState state (trace_size);
@@ -439,15 +438,18 @@ _Jv_StackTrace::GetCallerInfo (jclass ch
//JvSynchronized (ncodeMap);
UpdateNCodeMap ();
+#ifdef SJLJ_EXCEPTIONS
+ // The Unwind interface doesn't work with the SJLJ exception model.
+ // Fall back to a platform-specific unwinder.
+ fallback_backtrace (&state);
+#else /* SJLJ_EXCEPTIONS */
_Unwind_Backtrace (UnwindTraceFn, &state);
+#endif /* SJLJ_EXCEPTIONS */
if (caller_class)
*caller_class = trace_data.foundClass;
if (caller_meth)
*caller_meth = trace_data.foundMeth;
-#else
- return;
-#endif
}
// Return a java array containing the Java classes on the stack above CHECKCLASS.
Index: sysdep/i386/backtrace.h
===================================================================
--- sysdep/i386/backtrace.h (revision 115261)
+++ sysdep/i386/backtrace.h (working copy)
@@ -66,6 +66,10 @@ fallback_backtrace (_Jv_UnwindState *sta
&& scan_bytes[2] == 0xE5)
{
state->frames[i].start_ip = (void *)scan_addr;
+
+ if (state->trace_function != NULL)
+ (state->trace_function) (state);
+
break;
}
}
@@ -75,7 +79,7 @@ fallback_backtrace (_Jv_UnwindState *sta
break;
i++;
+ state->pos = i;
}
- state->pos = i;
}
#endif