Lab 0

Topics: C/UNIX/Shell refresher and customizations

Getting started:


Part 1 (14:00-14:30)


Part 2 (14:30-15:05)


Part 3 (15:05)


Part 4 [15:10-15:20] gdb debug session

Copy ex1.c (C Refresher exercise) to ex1buggy.c, add a segfault bug (such as int *p=0; *p=0; in main), and compile it with gcc -g ex1buggy.c (-g adds debug information)

Then run your program => segmentation fault message

launch gdb a.out

type run (followed by the enter key)

=> will show you the error line

Also: "bt" (backtrace) will show the entire call stack, which is often useful

Familiarizing yourself with tools like valgrind and gdb will greatly speed up your debugging efforts later in the course


Part 5 [15:20-15:30] valgrind memory leak session

cp ex2.c ex2buggy.c, add a memory leak bug (e.g., by removing free()), and compile it with -g

launch valgrind --leak-check=full ./a.out

=> will show you that there is a memory leak in your program


Part 6 [15:30-16:50]


Secrets