Compiler & Debugger

Depending on which operating system you are using for this class, you could be using one of two different C compilers and their corresponding debuggers.


Under almost all Linux distributions, the default C compiler is gcc. Its debugger is gdb. It works by compiling directly to the target architecture from the provided C code.


Under macOS the default C compiler is clang. Its debugger is therefore not gdb, but rather lldb. This compiler is a front-end to LLVM (Low-Level Virtual Machine), which then is compiled to the CPU target.


Debugging a program is an imperative skill and you simply must know how to do it. Littering your code with printf() just isn't going to work at this level (especially not when we start compiling code for the MSP430).

Both debuggers work in generally the same way, it allows for the setting of breakpoints and the inspection of variables during runtime. Knowing how to do these two things should be sufficient to solve almost 90% of crashes. However, there are more powerful features available, below are some useful commands:

Task Command
Start Program run
Continue Program continue or c
Start Program with Arguments run arg1 arg2
Set a Breakpoint on a Function b func
Set a Breakpoint on a Line Number b main.c:10
Set a Breakpoint at a Memory Address b *0xc000
Print the Contents of a Register p $r14
Print a Variable in Scope p var
Examine the Contents of Memory x/hx 0x3fe

See this page for a comparison between both debuggers and more advanced commands.