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: Mark Mitchell <mark at codesourcery dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: 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: Thu, 07 Nov 2002 14:50:47 -0800
- Subject: Re: [basic-improvements] try/finally support for c/c++ - more tests
--On Thursday, November 07, 2002 02:39:02 PM -0800 Richard Henderson
<rth@redhat.com> wrote:
On Thu, Nov 07, 2002 at 02:03:55PM -0800, Mark Mitchell wrote:
Suppose the dynamic stack of your code looks like:
C++ -> C -> C++ -> sigpause
When cancellation occurs, you want to have sigpause throw an exception,
run cleanups in C++, then run the pthread_cleanup_push stuff in C,
the outer C++ cleanups agagin, etc.
Yes.
Well, I'm catching up, and nobody is throwing up.
We're all trying. Finally.
How, exactly, do you do that without having C use EH? Or,
more specifically, how do you interleave the C stack and
the C++ EH?
When in C code, and you hit pthread_cleanup_push, call into the runtime
passing the address of the start and end of the function you're in, and
the frame pointer. When unwinding, notice that you're in that PC range
with that frame pointer, and run the cleanups that correspond to that
range. You're guaranteed to be getting these in the right order; as
you unwind you'll always be pulling stuff off the front of the list.
The call to register the handler needn't be a call; it could be inlined.
You need is to hook a record on the front of a piece of thread-specific
data.
I bet the idea of using the frame pointer to tell function instances
apart doesn't quite work, but I bet some modification of that idea could
work.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com