CS 208: Computer Organization & Architecture

More C

Goals for today

Debugging with lldb

The LLDB Debugger is a terminal-based debugger that enables you to run your programs, stop them in the middle of execution (i.e. stop at breakpoints), examine variables while the program is stopped, and continue execution. Here's the very beginning of getting to know lldb.

Note that today we'll use the clang compiler and lldb instead of their more venerable friends gcc and gdb, because clang + lldb supports what we want to do on a Mac without much trouble, whereas the setup for gcc + gdb in our lab would be much more complicated. The steps here, though, will be essentially the same with gcc + gdb on other systems (notably Linux).

First, let's watch the Fibonacci numbers evolve.

Next, let's watch a string change in squashCharacterInString.

Strings, pointers, and stack frames

Before jumping in here, think about these two ideas:

With those ideas in mind, keep working with functions.c.

Trouble in stackframeland

Finally, let's turn our attention to the function makeTrouble.