:> 
:> 
:> Shouldn't you use "kill(0, SIGSEGV)" ?
:
:Why not err(3) or abort(3) ?
:
:/assar

    I need something gdb can latch on to.  If the program exits all the state
    required to debug the problem goes away.  When writing a program one must
    make the run-time distinction between a bug and an expectable error. 
    If it's a bug then something unexpected occured which has to be fixed,
    so the best thing to do is usually to seg fault.

    After a while of debugging like this, the bugs get worked out and the
    programs stop seg faulting.  The final result tends to be a whole lot
    more stable then if you were to try to recover from or ignore the bug.

    I actually have a DBASSERT() macro to assert conditions and force the
    seg fault.  The macro uses GCC's preprocessor's __FILE__, __LINE__,
    and __FUNCTION__ macros in a call to a routine which prints out where
    the program died and then forces the seg-fault.

    If you put reasonable, strategic assertions in the code you tend to 
    catch problems before they've propogated through dozens of routines and
    become untraceable.

    #define DBASSERT(exp)           \
            if (!(exp)) _DBAssert(__FILE__, __LINE__, __FUNCTION__)

    ...

    void
    _DBAssert(const char *file, int line, const char *func)
    {
        fprintf(stderr, "Assertion failed %s line %d in %s\n", file, line, func);
        fflush(stderr);
    #ifndef NO_ASSERT_CORE
        *(long *)0 = 1;
    #endif
    exit(1);
    }


                                        -Matt



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to