exceptions

grauzone none at example.net
Thu Feb 25 09:44:19 PST 2010


Ellery Newcomer wrote:
> On 02/24/2010 12:37 PM, Robert Clipsham wrote:
>> On 24/02/10 17:51, Ellery Newcomer wrote:
>>>> ----
>>>> import tango.core.tools.TraceExceptions;
>>>> ----
>>>>
>>>> If you want to use gdb then type 'b _d_throw_exception' (or 'b 
>>>> _d_throw'
>>>> for dmd) before you run your app. This will break on every exception
>>>> thrown, so you may have to hit 'c' a few times to continue at each
>>>> thrown exception until you find the one you need.
>>>
>>> Thanks!
>>>
>>> b _d_throw gives me
>>>
>>> Function "_d_throw" not defined.
>>>
>>> same for _d_throw_exception.
>>>
>>> I can get a breakpoint on _d_arraycopy, but there seem to be way too
>>> many calls for it to be useful.
>>
>> Hmm, that's odd... if you type b _d_t<tab> or b _d_<tab> then you should
>> get a list of runtime functions, do you see anything listed there that
>> could be related? It seems odd to me that that function isn't there, it
>> always is for me. I'm pretty sure I use a debug version of the runtime
>> though, so that could be it. Your best option is probably to use Tango's
>> built in stack tracing for now if you can't get gdb working properly.
>> I've never had issues with it, but I use a custom version of gdb with
>> the D patches applied, as well as a compiler built with debug symbols,
>> and the runtime/other libraries built with them too in most cases.
> 
> Oooh! nice trick!
> Ah, it's '_d_throw at 4' and quotes help. Yahoo!

By the way, that's because someone defined _d_throw to have Windows 
calling convention, even on Linux. I wonder what that's useful for.

> 
> Do I need to do anything special to get stack tracing to work? when I 
> try to compile a simple program it barfs on me and gives
> 
> undefined reference to `dladdr'
> 
> from
> 
> import tango.core.tools.TraceExceptions;

You must link to libdl (-ldl).

> void main(){
> int[] i = [1,2];
> int[]  j = new int[3];
> j[] = i[];
> }
> 
> oh well. Thanks a ton, I'm back in business now!


More information about the Digitalmars-d-learn mailing list