This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [basic-improvements] try/finally support for c/c++ - more tests
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, Alexandre Oliva <aoliva at redhat dot com>, Mark Mitchell <mark at codesourcery dot com>, Geoff Keating <geoffk at geoffk dot org>, "zack at codesourcery dot com" <zack at codesourcery dot com>, "jakub at redhat dot com" <jakub at redhat dot com>, "aldyh at redhat dot com" <aldyh at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "jason at redhat dot com" <jason at redhat dot com>
- Date: Fri, 8 Nov 2002 07:54:04 -0500
- Subject: Re: [basic-improvements] try/finally support for c/c++ - more tests
- References: <133260000.1036714743@warlock.codesourcery.com> <orheesr3w2.fsf@free.redhat.lsd.ic.unicamp.br> <20021108122658.GA30241@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Nov 08, 2002 at 04:26:58AM -0800, Richard Henderson wrote:
> On Fri, Nov 08, 2002 at 04:07:09AM -0200, Alexandre Oliva wrote:
> > I fail to see how longjmp_unwind could possibly be implemented without
> > EH frame information for all frames, C ones included.
>
> The idea I has was that it unwound frames until (1) we arrive at
> the destination frame or (2) we don't find any more EH information,
> at which point it falls back to just longjmp.
But that's the same what would be needed for __try/__finally based
thread cancellation, there is no difference if libpthread cancellation
calls _Unwind_ForcedUnwind directly with a stop_fn which checks for
__libc_start_main resp. pthread_start_thread, or if pthread cancellation
calls longjmp_unwind with a jmp_buf set up in __libc_start_main resp.
pthread_start_thread.
Even there we don't want to abort() in:
if (exc->private_1 == 0)
code = _Unwind_RaiseException_Phase2 (exc, &cur_context);
else
code = _Unwind_ForcedUnwind_Phase2 (exc, &cur_context);
if (code != _URC_INSTALL_CONTEXT)
abort ();
but to let either the stop_fn, or some other hook decide what to do,
such as do the longjmp.
The question is more what will each function having cleanups have to do:
Is it something like:
...
extern __thread jmp_buf *__youngest_jmp_buf;
...
{
jmp_buf __buf;
jmp_buf *__previous = __youngest_jmp_buf;
int __cleanup;
__youngest_jmp_buf = &__buf;
__cleanup = setjmp (__buf);
if (!__cleanup)
{
try block;
}
{
finally block;
}
__youngest_jmp_buf = __previous;
if (__cleanup)
longjmp_unwind (__youngest_jmp_buf);
}
?
If __thread is not supported on particular target, it would have to
do a call to pthread library to find address of (resp. get and set)
__youngest_jmp_buf instead.
Jakub