This is the mail archive of the java@gcc.gnu.org mailing list for the Java 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: documentation on "sjlj exceptions", DWARF2, etc?



On 11 Dec 2001, Adam Megacz wrote:
> It appears that I need to educate myself on gcc's ABI for C++
> exceptions. Can anybody refer me to a good source of documentation for
> DWARF2 and (more importantly) "sjlj exceptions" (I have no idea what
> the heck that means, by the way). Info on something called "EH
> personalities" would also be appreciated; I see "EH" sprinkled
> throughout the mingw exception handling code...

The new GCC EH code is clean and beautiful but lacking in documentation.
The best I know of is the draft ABI specs for IA-64 (which the new GCC
implementation is based on, for all targets besides IA-64).

http://www.codesourcery.com/cxx-abi/abi-eh.html

The DWARF2 and sjlj techniques are specific to GCC and not covered by this
document.  In brief, DWARF2 EH relies on the compiler emitting a special
section, .eh_frame, for each call frame that may be visited by the
unwinder.  This section describes the stack layout of a call frame in
enough detail so that the unwinder can restore registers and execution
context necessary to resume execution in that frame (i.e. in a cleanup or
exception handler).

Setjmp/longjmp handling (sjlj for short) relies on a simplified setjmp
call at the start of each try...catch block that saves the machine state,
so it can later be restored by a longjmp by the unwinder.  The advantages
of sjlj EH is a simpler, more portable implementation, and smaller size.
The primary disadvantage is performance: it incurs some cost even if no
exception is never thrown.

Personality routines are explained in section 1.6 of the IA64 ABI spec:

"The personality routine is the function in the C++ (or other language)
runtime library which serves as an interface between the system unwind
library and language-specific exception handling semantics. It is specific
to the code fragment described by an unwind info block, and it is always
referenced via the pointer in the unwind info block, and hence it has no
psABI-specified name."

> I'm guessing that I need to know about this stuff based on reading
> mailing list archives, and info on cygwin (which is closely related to
> mingw).

Be careful... I spent weeks learning about the implementation back when I
was fixing the SPARC DWARF2 unwinder.  The specification is long, the code
complex, and you can easily get lost in it.  (No doubt others can learn it
faster than I did, but I know you have an aggressive timeline for your
mingw port.)

My suggestion is to go with the sjlj model for now (configured by
--enable-sjlj-exceptions) and hope it just works.  It's possible to
support DWARF2 EH on mingw, but it might require binutils and/or runtime
library modifications, and the last I heard (June-July) nobody on the
cygwin team had succeeded yet.  (Besides that, sjlj avoids the
complications of unwinding through signal handlers, which DWARF2 cannot do
reliably without complex target-specific fallback routines.)

Jeff


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