September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tuesday, 23 September 2014 at 20:29:22 UTC, Walter Bright wrote: > On 9/23/2014 12:57 PM, Jacob Carlborg wrote: >> From the LLVM docs [1]: > > Thank you. This is helpful. Yes, that's quite a nice list already. As far as the C++ implementation details go, I posted the most interesting source files in the earlier discussion: http://forum.dlang.org/thread/lutf3c$2usj$1@digitalmars.com (the GCC ones can be found in the GCC release tarballs, the OS X Clang ones at http://llvm.org/svn/llvm-project/libcxxabi/trunk/src/). David |
September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On 9/23/14, 2:07 PM, David Nadlinger wrote:
> On Tuesday, 23 September 2014 at 20:29:22 UTC, Walter Bright wrote:
>> On 9/23/2014 12:57 PM, Jacob Carlborg wrote:
>>> From the LLVM docs [1]:
>>
>> Thank you. This is helpful.
>
> Yes, that's quite a nice list already.
>
> As far as the C++ implementation details go, I posted the most
> interesting source files in the earlier discussion:
> http://forum.dlang.org/thread/lutf3c$2usj$1@digitalmars.com (the GCC
> ones can be found in the GCC release tarballs, the OS X Clang ones at
> http://llvm.org/svn/llvm-project/libcxxabi/trunk/src/).
>
> David
Speaking of which, what's the current story with gdc and ldc with regard to unwinding? Can they unwind properly when a C++ exception gets thrown? -- Andrei
|
September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Tuesday, 23 September 2014 at 21:20:37 UTC, Andrei Alexandrescu wrote:
> Speaking of which, what's the current story with gdc and ldc with regard to unwinding? Can they unwind properly when a C++ exception gets thrown? -- Andrei
Currently, the LDC runtime just aborts, but that wouldn't be too hard to fix.
David
|
September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Tuesday, 23 September 2014 at 17:37:42 UTC, Andrei Alexandrescu wrote: > We need a libunwind expert to figure out a good approach for handling exceptions thrown by C++ code into D. > > Is anyone fluent with libunwind? > > > Andrei https://github.com/deadalnix/libsdrt/blob/master/src/d/rt/eh.d |
September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Tuesday, 23 September 2014 at 18:14:35 UTC, Andrei Alexandrescu wrote: > On 9/23/14, 11:03 AM, David Nadlinger wrote: >> On Tuesday, 23 September 2014 at 17:37:42 UTC, Andrei Alexandrescu wrote: >>> We need a libunwind expert to figure out a good approach for handling >>> exceptions thrown by C++ code into D. >>> >>> Is anyone fluent with libunwind? >> >> More or less. >> >> What exactly are your goals? I thought the options we have are fairly >> clear, as discussed a few days ago. At least, Amaury and I seemed to >> agree (both of us worked on EH recently). The main question to decide is >> whether you want to go down the catch-C++-exceptions-in-D rabbit hole. > > I think we should explore that rabbit hole. In the interim, a simpler solution may work: a C++ exception can only be caught from within C++ code. If no handler, the program terminates reliably. -- Andrei Here is the other side of the rabbit hole you want to be compatible with: libstdc++-v3//libsupc++/eh_personality.cc (from GCC source tree, svn checkout svn://gcc.gnu.org/svn/gcc/trunk SomeLocalDir ). I think catching C++ exception may be realistic on the long run, but having them unwind properly should probably be the goal on the short run. |
September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 23 September 2014 22:20, Andrei Alexandrescu via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On 9/23/14, 2:07 PM, David Nadlinger wrote:
>>
>> On Tuesday, 23 September 2014 at 20:29:22 UTC, Walter Bright wrote:
>>>
>>> On 9/23/2014 12:57 PM, Jacob Carlborg wrote:
>>>>
>>>> From the LLVM docs [1]:
>>>
>>>
>>> Thank you. This is helpful.
>>
>>
>> Yes, that's quite a nice list already.
>>
>> As far as the C++ implementation details go, I posted the most interesting source files in the earlier discussion: http://forum.dlang.org/thread/lutf3c$2usj$1@digitalmars.com (the GCC ones can be found in the GCC release tarballs, the OS X Clang ones at http://llvm.org/svn/llvm-project/libcxxabi/trunk/src/).
>>
>> David
>
>
> Speaking of which, what's the current story with gdc and ldc with regard to unwinding? Can they unwind properly when a C++ exception gets thrown? -- Andrei
GDC lets foreign exceptions pass through just fine. The only time when runtime terminates is when GDC has no choice *but* to handle a foreign exception it doesn't know about.
By all means, you can have this kind of code:
---
D:
extern(C++) int Dfunction()
{
try {
return CXXfunction(2);
}
catch {
return 8;
}
}
---
C++:
int main() {
try {
return Dfunction();
}
catch (int error) {
return error;
}
}
int CXXfunction(int i)
{
throw int(16);
return i * 2;
}
And the runtime flow is:
Phase 1.
=> __gdc_personality_v0 // Found nothing, continue unwinding.
=> __gxx_personality_v0 // Found something, cache details and continue unwind
Phase 2.
=> __gdc_personality_v0 // Found nothing, continue unwinding.
=> __gxx_personality_v0 // Found something, finish unwinding.
And we land back in C++ main, return 16.
Iain.
|
September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On 23 September 2014 22:29, deadalnix via Digitalmars-d <digitalmars-d@puremagic.com> wrote: > On Tuesday, 23 September 2014 at 17:37:42 UTC, Andrei Alexandrescu wrote: >> >> We need a libunwind expert to figure out a good approach for handling exceptions thrown by C++ code into D. >> >> Is anyone fluent with libunwind? >> >> >> Andrei > > > https://github.com/deadalnix/libsdrt/blob/master/src/d/rt/eh.d https://github.com/D-Programming-GDC/GDC/blob/master/libphobos/libdruntime/gcc/deh.d :o) |
September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On 9/23/14, 3:14 PM, Iain Buclaw via Digitalmars-d wrote:
> GDC lets foreign exceptions pass through just fine.
Proper unwinding of the D stack and all? -- Andrei
|
September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On 9/23/14, 3:15 PM, Iain Buclaw via Digitalmars-d wrote:
> On 23 September 2014 22:29, deadalnix via Digitalmars-d
> <digitalmars-d@puremagic.com> wrote:
>> On Tuesday, 23 September 2014 at 17:37:42 UTC, Andrei
>> Alexandrescu wrote:
>>>
>>> We need a libunwind expert to figure out a good approach for handling
>>> exceptions thrown by C++ code into D.
>>>
>>> Is anyone fluent with libunwind?
>>>
>>>
>>> Andrei
>>
>>
>> https://github.com/deadalnix/libsdrt/blob/master/src/d/rt/eh.d
>
> https://github.com/D-Programming-GDC/GDC/blob/master/libphobos/libdruntime/gcc/deh.d
>
> :o)
Noice. How difficult would be to port this to dmd/Linux? This is big - we need to get it done, and soon.
Andrei
|
September 23, 2014 Re: Any libunwind experts n da house? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 9/23/2014 3:45 PM, Andrei Alexandrescu wrote:
> On 9/23/14, 3:15 PM, Iain Buclaw via Digitalmars-d wrote:
>> On 23 September 2014 22:29, deadalnix via Digitalmars-d
>> <digitalmars-d@puremagic.com> wrote:
>>> On Tuesday, 23 September 2014 at 17:37:42 UTC, Andrei
>>> Alexandrescu wrote:
>>>>
>>>> We need a libunwind expert to figure out a good approach for handling
>>>> exceptions thrown by C++ code into D.
>>>>
>>>> Is anyone fluent with libunwind?
>>>>
>>>>
>>>> Andrei
>>>
>>>
>>> https://github.com/deadalnix/libsdrt/blob/master/src/d/rt/eh.d
>>
>> https://github.com/D-Programming-GDC/GDC/blob/master/libphobos/libdruntime/gcc/deh.d
>>
>>
>> :o)
>
> Noice. How difficult would be to port this to dmd/Linux? This is big - we need
> to get it done, and soon.
>
> Andrei
There is a problem, that code is gpl licensed. It may not actually matter, since this code is only to interface with gpl libraries, but we should be careful.
|
Copyright © 1999-2021 by the D Language Foundation