SOLVED: Wrestling with exceptions on win32 gcj 4.1

Rutger Ovidius r_ovidius@eml.cc
Tue Feb 7 21:49:00 GMT 2006


Tuesday, February 7, 2006, 12:28:05 PM, you wrote:

tD> hello,

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

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

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

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

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

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

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

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

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

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

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

tD> bye,
tD> -- dpr

Does this mean 4.1 can work on win32?  It was said that it was
currently broken on this platform:

http://gcc.gnu.org/ml/java/2005-11/msg00292.html

Is another patch needed to remove the -fomit-frame-pointer you
mentioned here? Maybe this is due to a new addition because manual
configure.host hacking wasn't previously necessary.

http://gcc.gnu.org/ml/java/2006-02/msg00047.html

There is an old patch that unfortunately hit a dead end, but helped with
exceptions/stack traces by enabling basic Dwarf2 unwinding on win32
(but not across .dll boundaries AFAIK)

http://gcc.gnu.org/ml/gcc-patches/2004-11/msg01989.html





More information about the Java mailing list