Writing Bug-Free C/D Code
BCS
BCS at pathlink.com
Mon Mar 19 11:16:46 PDT 2007
Henning Hasemann wrote:
> I just start a few little things.
>
> 1.)
[...]
> Of course, because here myFoo is default initialised to null this always gives
> a segfault where myFoo is first being used in such a way,
> so it is very easy to track down (if you use a debugger at least).
[...]
> 2.)
> Another thing would be easy support for stack traced exceptions.
> I tried flectioned last weak or so (just for this purpose) but it
> didnt want to compile with my code (I think I was still on dmd-1.007
> so it might have been a bug there). I think STE's are of use
> to many developers so they should be put into phobos or so.
>
I have found a handy way to catch seg-v's is by catching SIGSEGV with a
function that throws an exception, that way I can get a stack trace
using my DIY stack tracing. The first line in each function I write is:
scope(failure) writef("Backtrace@"__FILE__":"~itoa!(__LINE__)~\n);
it works just fine as long as you don't ever throw exceptions in normal
code paths
More information about the Digitalmars-d
mailing list