Limiting GCC Messages
Limitng GCC messages(limit errors)
Limiting GCC Messages(Warning -> Errors)
Paginated Output
Paginated Compiler Output(redirect Stderr)
assert() in C
We can build tests right into our source code
* Like Java, C has support for assert()
– It’s provided via the preprocessor:
#include <assert.h>
* Usage:
assert( some-condition-you-expect-to-be-true );
* We can use this to build sanity-checks into our code
#include <assert.h>
int f( int a, int b )
{
assert( a != 0 && b > 0 );
…;
}
* You can use assert() to comment on your
assumptions as write.
assert( i < length );
…
assert( x >= 0 && y >= 0 );
…
assert( ptr != NULL );
* But, these are comments with teeth!
* They will terminate your program if they are
violated.
Assertion failed: (j >= 0 && j + 1 < len),\
function sortList, file bubble3b.c, line 50.</assert.h></assert.h>
Assert as Executable Comments
Using and Not Using assert()
Instrumentation via GCC
Stack Buffer Overflow
Heap Buffer Overflow
Static Buffer Overflow
Use After Return
Use Out of Scope
Use After Free
Memory Leak
Null Pointer Dereference
Signer Integer Overflow
Code Coverage
Tools for Code Coverage
Using gcov
Reading gcov Output
Getting More from gcov
Reading gcov Output