www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Debugging with gdb on Posix but setAssertHandler is deprecated

reply Jens Mueller <jens.k.mueller gmx.de> writes:
Hi,

I've written a small module for debugging on Posix systems.
It uses raise(SIGTRAP) and a custom errorHandlerType with
setAssertHandler. But setAssertHandler is deprecated.
Why is it deprecated? How should I do it instead?

I want to do it generally for Error and Exception. Don't know how yet.
How do you debug your programs? I've read that gdb has catch throw for
C++ to break when exceptions are thrown. I don't like changing gdb for
this.
My idea is that instead of throwing an Error/Exception I print it and
then raise SIGTRAP.

Jens
Nov 17 2010
parent reply Sean Kelly <sean invisibleduck.org> writes:
Jens Mueller <jens.k.mueller gmx.de> wrote:
 Hi,
 
 I've written a small module for debugging on Posix systems.
 It uses raise(SIGTRAP) and a custom errorHandlerType with
 setAssertHandler. But setAssertHandler is deprecated.
 Why is it deprecated? How should I do it instead?
 
 I want to do it generally for Error and Exception. Don't know how yet.
 How do you debug your programs? I've read that gdb has catch throw for
 C++ to break when exceptions are thrown. I don't like changing gdb for
 this.
 My idea is that instead of throwing an Error/Exception I print it and
 then raise SIGTRAP.
It's deprecated because DMD doesn't generate a valid call stack when generating an assert, so if you try to return from the assert handler instead of throwing the app will crash.
Nov 21 2010
parent Jens Mueller <jens.k.mueller gmx.de> writes:
Sean Kelly wrote:
 Jens Mueller <jens.k.mueller gmx.de> wrote:
 Hi,
 
 I've written a small module for debugging on Posix systems.
 It uses raise(SIGTRAP) and a custom errorHandlerType with
 setAssertHandler. But setAssertHandler is deprecated.
 Why is it deprecated? How should I do it instead?
 
 I want to do it generally for Error and Exception. Don't know how yet.
 How do you debug your programs? I've read that gdb has catch throw for
 C++ to break when exceptions are thrown. I don't like changing gdb for
 this.
 My idea is that instead of throwing an Error/Exception I print it and
 then raise SIGTRAP.
It's deprecated because DMD doesn't generate a valid call stack when generating an assert, so if you try to return from the assert handler instead of throwing the app will crash.
Thanks. That explains my segmentation fault. Is there going to be an alternative way of doing it? Shouldn't one fix the problem in dmd instead of deprecating the handler? In the meantime I will try using gdb reverse debugging. Jens
Nov 21 2010