Clang && lldb#
听说clang+lldb >= gcc + gdb, 所以一试:
lldb基本命令#
与GDB相同
- break (b) - 设置断点,也就是程序暂停的地方
- run (r) - 启动目标程序,如果遇到断点则暂停
- step (s) - 进入下一条指令中的函数内部
- backtrace (bt) - 显示当前的有效函数
- frame (f) - 默认显示当前栈的内容,可以通过
frame arg进入特定的 frame(用作输出本地变量) - next (n) - 运行当前箭头指向行
- continue (c) - 继续运行程序直到遇到断点。
clang hello.c -g -o hello
lldb hello# lldb
b main
run
n
p str还有颜色 😂 可视效果确实提高了不少 而且这四个工具可以混用,也蛮好.
GDB#

First and foremost, you will need to compile your program with the flag “-g” (for debug) to run it via GDB. From there the syntax to start debugging is: