This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [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


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