Re: Regarding exceptions



On Sat, 04 Sep 2004 16:07:03 +0100, Andy Wingo wrote:
> I have a proposal that I'd like some comment on. The whole idea might
> just be too complicated; do let me know if this is way off the deep end.

Well, it does make me wonder why not simply use the underlying exception
handling ABI? On ELF it's table based, on Win32 it's SEH, dunno what Mac
uses ...

I think duplicating the native exception handling ABI seems a bit silly,
to be perfectly honest. If you want exception safe C libraries the best
way is to register exception handling frames so you can just use the
standard throw/catch C++ statements (for instance) from within your code.
For language interpreters you can just wrap callouts to native code with
try/catch and then convert them into whatever the best construct for your
language is.

The ELF exception handling ABI was designed quite carefully to not have
any runtime overhead (for instance), it seems a shame to duplicate that
effort.

As to how to register exception frames in C, well ...

* Compile GTK/GObject with a C++ compiler. No, I'm not joking, it'd still
export a standard C ABI, just that the toolchain would let you use
try/catch and generate all the table/unwind info for you.

* Use magic macros, functions and inline assembly that duplicate whatever
try/catch do internally (emit unwind data, __register_frame_info_bases and
so on)

* Add features to the GNU toolchain so they provide easier to use
interfaces for registering exception handling frames

On Win32 you can already set up exception handler frames with a macro.

Or you can use jump buffers as you proposed, I guess, though you lose
native integration with C++/Java/random-other-gcc-compilable-language
exceptions.

thanks -mike




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]