www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - source of exception

reply Frank Benoit <keinfarbton nospam.xyz> writes:
On linux with gdb:
If i have an exception I cannot get the source of the exception. A msg
like "std.format formatArg" lets me grep through my program and search
for all lines calling format and analyse them as potential sources. And
this is a good one. Try to find a ArrayBoundsException.

Is there a chance to get the "catch throw" command (breaks on a c++
throw) in gdb working?

Or is there any better way to find the source?
May 06 2006
next sibling parent John Demme <me teqdruid.com> writes:
Frank Benoit wrote:

 On linux with gdb:
 If i have an exception I cannot get the source of the exception. A msg
 like "std.format formatArg" lets me grep through my program and search
 for all lines calling format and analyse them as potential sources. And
 this is a good one. Try to find a ArrayBoundsException.
 
 Is there a chance to get the "catch throw" command (breaks on a c++
 throw) in gdb working?
 
 Or is there any better way to find the source?
That's a non-trivial function to add to GDB. As a hack, I have two different versions of libphobos.a-- the regular one, plus one that I compiled wherein I insert the following code in the Exception constructor: Object o; o.toString(); GDB catches the segfault, and I can do a backtrace to see what caused the exception. ~John Demme
May 06 2006
prev sibling parent reply BCS <BCS_member pathlink.com> writes:
In article <e3jg4m$1jj0$1 digitaldaemon.com>, Frank Benoit says...
On linux with gdb:
If i have an exception I cannot get the source of the exception. A msg
like "std.format formatArg" lets me grep through my program and search
for all lines calling format and analyse them as potential sources. And
this is a good one. Try to find a ArrayBoundsException.

Is there a chance to get the "catch throw" command (breaks on a c++
throw) in gdb working?

Or is there any better way to find the source?
I haven't tried it but you might be able to set a break point the exception's constructor. If they don't have one, thay should (at least in the debug version).
May 06 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

BCS schrieb am 2006-05-07:
 In article <e3jg4m$1jj0$1 digitaldaemon.com>, Frank Benoit says...
On linux with gdb:
If i have an exception I cannot get the source of the exception. A msg
like "std.format formatArg" lets me grep through my program and search
for all lines calling format and analyse them as potential sources. And
this is a good one. Try to find a ArrayBoundsException.

Is there a chance to get the "catch throw" command (breaks on a c++
throw) in gdb working?

Or is there any better way to find the source?
I haven't tried it but you might be able to set a break point the exception's constructor. If they don't have one, thay should (at least in the debug version).
the interresting breakpoint is: _d_throw 4 the problem: gdb interpretes "break _d_throw 4" as "break _d_throw" :( workaround: Compile and link your programm. Use the output of the following shell command to set a breakpoint: objdump -t yourProgramm | grep "_d_throw 4" | head -n 1 | sed "s: .*::;s:^:break *0x:" Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEXjy03w+/yD4P9tIRAjDEAKCqXdt5v9FWsD9wInOI2kZdIp8cZACdEMaa VXcYRZd56NThgATUPVgLa0E= =u0+P -----END PGP SIGNATURE-----
May 07 2006