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: SOLVED: Wrestling with exceptions on win32 gcj 4.1


hello,

i was able to solve my problem (see
http://gcc.gnu.org//ml/java/2006-02/msg00047.html) by applying
*any* of the two patches below.

since both patches apply to gcc i'm cc'ing to gcc list too.

i'm not 100% sure if my solution is correct. maybe just some exception data
is mangled in some way.
anyway, now i'm able to run basic swt application, and throw and catch
exceptions.

i'm happy and hope this could help somebody else to use gcj 4.1 on windows.
it would be unfortunate if gcj could not be used for most popular os ;)

so, the first patch makes uw_frame_state_for() function return
_URC_END_OF_STACK earlier, when context->fc->prev == NULL.

--- gcc/unwind-sjlj.c.old       2005-11-17 00:10:39.000000000 +0200
+++ gcc/unwind-sjlj.c   2006-02-07 14:02:36.000000000 +0200
@@ -265,7 +265,7 @@
  else
    {
      fs->personality = context->fc->personality;
-      return _URC_NO_REASON;
+      return context->fc->prev != NULL ? _URC_NO_REASON :
_URC_END_OF_STACK;
    }
}

my second patch makes _Unwind_Backtrace break out of the loop as soon as
_URC_END_OF_STACK is returned, so the trace callback is not called in that
case.

--- gcc/unwind.inc.old      2005-12-17 11:55:11.000000000 +0200
+++ gcc/unwind.inc  2006-02-07 20:13:38.000000000 +0200
@@ -292,17 +292,18 @@

      /* Set up fs to describe the FDE for the caller of context.  */
      code = uw_frame_state_for (&context, &fs);
-      if (code != _URC_NO_REASON && code != _URC_END_OF_STACK)
+
+      /* We're done at end of stack.  */
+      if (code == _URC_END_OF_STACK)
+       break;
+
+      if (code != _URC_NO_REASON)
       return _URC_FATAL_PHASE1_ERROR;

      /* Call trace function.  */
      if ((*trace) (&context, trace_argument) != _URC_NO_REASON)
       return _URC_FATAL_PHASE1_ERROR;

-      /* We're done at end of stack.  */
-      if (code == _URC_END_OF_STACK)
-       break;
-
      /* Update context to describe the same frame as fs.  */
      uw_update_context (&context, &fs);
    }

bye,
-- dpr


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