Debug C with Clang
Prepare llvm
brew install llvm --with-clang --with-asan
Example
#include <stdio.h>
int main()
{
int x = 1;
int y = 5;
char *name = "Bob";
x += 1;
x += y;
printf("Name is %s\n", name);
printf("Number x is %d\n", x);
}
Compile
clang -g test.c -o test
Debug with lldb
lldb test
b 10
b main
run
br list
br del 1
p x
expr x = 5
f
Display current linebt
Using backtrace