Gregory Turner wrote:
On Monday 19 May 2003 05:14 pm, Ulrich Weigand wrote:
Note that g++ exception handling with dwarf2 works quite different from MSVC exception handling -- the former hooks exception processing into the dwarf2 frame 'personality' routines, while the latter uses the exception frame chain anchored in the TEB ...
Ideally, some compiler will emerge which would generate the same undocumented unwind tables used by msvc to do it... that way tryblocks from native dlls and wine dlls, and MSVC++ and XYZ++ exceptions could all get along swimmingly...
Note that there are two quite different things involved here, as far as GCC extensions are concerned.
First, we'd need a GCC extension to support the __try/__finally and/or __try/__except syntax in the C (and possibly C++) frontend. This would hook into the regular GCC exception infrastructure (which on most targets uses dwarf2 frame personality routines to actually handle exceptions).
However, this wouldn't be enough, as those exception wouldn't be integrated with Windows/Wine 'SEH' based exceptions. So you'd really want *another* GCC extension to get GCC to use a different exception handling infrastructure (for both the new __try/__finally *and* for regular C++ exceptions as well), which would be compatible with Windows exception handling.
As the SEH based exception handling is large undocumented, and also very much platform specific, I'd doubt the GCC folks would be happy about the latter part ...
A different approach might be to add code to Wine to 'interface' between the two exception infrastructures e.g. by catching all Windows exceptions and rethrowing them as GCC exceptions or vice versa at every Windows/Unix code boundary. I'm not sure whether this would actually work, though (and even if, it probably won't be very efficient).
Alternatively, the Wine exception unwinding could try to follow both the SEH TEB-anchored frame chain *and* the dwarf2 CFI stack unwinding chain and intermix between the two as required (this is actually similar to a proposal on the GCC list how to handle C++ cleanups intermixed with pthread cancellation handlers).
Bye, Ulrich