public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [MinGW] RFA: Fix GetCallerInfo() for Targets Using SJLJ EH
@ 2006-07-08  4:09 Ranjit Mathew
  0 siblings, 0 replies; only message in thread
From: Ranjit Mathew @ 2006-07-08  4:09 UTC (permalink / raw)
  To: java-patches

[-- Attachment #1: Type: text/plain, Size: 1083 bytes --]

-----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-----

[-- Attachment #2: p1.txt --]
[-- Type: text/plain, Size: 2097 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-07-08  4:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-08  4:09 [MinGW] RFA: Fix GetCallerInfo() for Targets Using SJLJ EH Ranjit Mathew

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).