Sunday, October 11, 2009

iPhone dev Stupidity 43: Stop at assertion failure

When XCode meets an assertion failure, it simply exits - without any stack trace. 

It's really annoying. 

You can set a breakpoint at assertion failed entry:

(gdb) b __assert_rtn

Then the debugger will stop properly with the stack trace.


// defined in assert.h

#if __DARWIN_UNIX03


#define assert(e) \


    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)


#else /* !__DARWIN_UNIX03 */


#define assert(e)  \


    (__builtin_expect(!(e), 0) ? __assert (#e, __FILE__, __LINE__) : (void)0)


#endif /* __DARWIN_UNIX03 */



No comments: