This is the mail archive of the gcc@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]

Re: Request for Exception Handling Table Information


> We are looking at creating another language product on Linux and I
> am wanting to find out what would be needed to have GCC C++
> exceptions propagate through our stack frames and vice versa

As Mike Stump explains: Nothing is needed. If you build-up your tree
structures with the available infrastructure, it will just magically
work.

> >From seeing the sample output with the option -fnew-exceptions I suspect 
> that the new table format is upwardly compatible.  Is this true?

Yes. Look at throw_helper in gcc/libgcc2.c; there is a check whether
the exception table starts with NEW_EH_RUNTIME. This is to not require
recompilation when the new exception model is activated

[BTW, it shouldn't be called NEW_EH_RUNTIME. It won't be new in a
couple of years from now, but it still will be called NEW]

> Given that I have to use an option to get the new tables I suspect
> that this format is experimental.

Yes; although I understand it is fully operational now.

> Is it expected to be become the default (if so, any estimated time)?

You may ask these kinds of questions many more times, and still won't
get an answer. Why would we (as a group) make time estimates about the
progress of our work (which is volunteer's time for many of us)? Now,
from looking at the change logs, you may be able to find out who
originally contributed the new EH stuff, and contact that person
directly.

> W.r.t. the calls done at throw/catch points, what I want to understand is 
> the interface that GCC is using into the runtime library to create/catch 
> exceptions.  I don't know the location of any external documentation though 
> I have looked through some of the source code.  So would you be able to 
> point me to any of the archives that may contain documentation on the 
> interface or give me a hint on relavent files to look at (b.t.w. I have 
> looked at the file except.c in the gcc tree).

I propose a different procedure: Ask a specific question, and get a
specific answer. To make a start, consider the question:

Q. What routines will g++ use to throw an exception, under
-fnew-exceptions?

A. First, it will invoke __eh_alloc, to allocate memory for the
exception object. This is a C++ specific, as arbitrary-sized
information may travel with an exception in C++, and it is implemented
in cp/exception.cc. It then will create the exception object in the
allocated space, call the type_info function of the static type of the
object, and call __cp_push_exception, then __throw.

__cp_push_exception is also a language-specific function, which first
allocates a cp_eh_info (a structure starting with an __eh_info). It
puts the object and its type_info into the structure, and fills out
the __eh_info in the following way:

- the match function is set to __cplus_type_matcher
- the language is set to EH_LANG_C_plus_plus
- the version is set to 1

It then calls __get_eh_info(), which is a language-independent
function to obtain a thread-safe pointer to the current exception. For
C++, the old value of that pointer is stored (to implement push/pop
model); then the cp_eh_info value is stored as the current exception.

__throw is a language-independent function, which retrieves the
current exception, determines the unwind information and initiates the
processing via __builtin_eh_return.

All this stuff lives in libgcc2.c and cp/exception.cc (except for the
implementation of __builtin_eh_return, of course, which is in
except.c)

Regards,
Martin

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