Any libunwind experts n da house?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 24 12:28:50 PDT 2014


On 9/24/14, 9:54 AM, Iain Buclaw via Digitalmars-d wrote:
> On 24 September 2014 16:07, Andrei Alexandrescu via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>> I wonder how difficult would be to create a wrapper class CppException for
>> everything derived from C++ std::exception. It would not save the exact
>> exception, but it would save its what() string and perhaps the
>> typeid().name(). A translator would create CppException objects from
>> std::exception objects and their derivatives.
>>
>> How hard would that be? Please advise.
>>
>
> Thinking about it:
>
> - Identifying a C++ exception, simple.

Noice.

> - Identifying whether a D catch handler for a C++ exception object
> matches, tricky - maybe.  ABI of structs being a potential maintenance
> burden - though you'd hope that they only change ABI once every two
> years or so. Second, determining that the C++ object being thrown and
> catch handler we are examining match might be awkward from D.  That is
> something that needs investigation.

Yah. I'm thinking of simplifying assumptions, e.g. all C++ exceptions 
map to one single D type called CppException, and we can assume there's 
always a D handler on top of the stack. All the CppException saves is a 
copy of the what() message from the C++ exception.

> However, for sure, the easiest thing that could be done *now* that
> only needs a slight EH library tweak is using catch-all handlers to
> recover from any language exception.
>
> try {
>    SomeCxxFuncThatMayThrow();
> }
> catch {
>    // Recover, but without knowing what happened.
> }
>
> But I'd imagine you'd actually want information to come with your
> caught exception, though. :)

Well even a catch like that would definitely be an improvement.


Andrei




More information about the Digitalmars-d mailing list