Debugging C with Clang compiler and LLDB on MacOS
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
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
Disclaimer
- License under
CC BY-NC 4.0
- Copyright issue feedback
me#imzye.me
, replace # with @ - Not all the commands and scripts are tested in production environment, use at your own risk
- No privacy information is collected here
Try iOS App