Monday, July 7, 2008

Analyzing Core Dumps and Assert Debugging

#define ASSERT(x)
void assert(int expression);
If expression evaluates to 0 (false), then the expression, sourcecode filename, and line

number are sent to the standard error, and then calls the abort function.
Common error outputting is in the form:

Assertion failed: expression, file filename, line line-number

#define NDEBUG === > then the macro assert does nothing.

To enable core dumps for your current shell, use ulimit to set a maximal core dump size in megabytes.
For this example, we'll "limit" core dumps to 1 gigabyte:

gcc -g -o exe_name main.c
$ulimit -c 1024
$ls -als core

Analyzing Core Dumps
====================
$gdb ./exe_name ./core_filename

No comments: