Tutorial by Examples

Let's have a basic failing program: #include <iostream> void fail() { int *p1; int *p2(NULL); int *p3 = p1; if (p3) { std::cout << *p3 << std::endl; } } int main() { fail(); } Build it (add -g to include debug info): g++ -g -o m...
Lets use the same code as above for this example. #include <iostream> void fail() { int *p1; int *p2(NULL); int *p3 = p1; if (p3) { std::cout << *p2 << std::endl; } } int main() { fail(); } First lets compile it g++ -g -o main m...
Debugging starts with understanding the code you are trying to debug. Bad code: int main() { int value; std::vector<int> vectorToSort; vectorToSort.push_back(42); vectorToSort.push_back(13); for (int i = 52; i; i = i - 1) { vectorToSort.push_back(i *2); } ...
Static analysis is the technique in which on checks the code for patterns linked to known bugs. Using this technique is less time consuming than a code review, though, its checks are only limited to those programmed in the tool. Checks can include the incorrect semi-colon behind the if-statement (i...
Stack corruptions are annoying bugs to look at. As the stack is corrupted, the debugger often can't give you a good stack trace of where you are and how you got there. This is where safe-stack comes into play. Instead of using a single stack for your threads, it will use two: A safe stack and a dan...

Page 1 of 1