如何显示lldb
中每一步的所有帧变量?
例如,我在C
int
print_all_variables(int a, int b)
{
int x = 10, i;
for (i = 0; i < 10; i++) {
x = a + b + x;
b++;
x++;
}
return x;
}
我想在使用lldb
进行调试时,在每个步骤中显示上面print_all_variables()例程中所有变量的值
答案 0 :(得分:8)
这个lldb命令可以解决这个问题:
target stop-hook add --one-liner "frame variable"
示例:
(lldb) b print_all_variables Breakpoint 2: where = stophook`print_all_variables + 10 at main.c:14, address = 0x0000000100000eca (lldb) target stop-hook add --one-liner "frame variable" Stop hook #1 added. (lldb) c Process 4838 resuming (int) a = 10 (int) b = 20 (int) x = 32767 (int) i = 1606416664 (lldb) n (int) a = 10 (int) b = 20 (int) x = 10 (int) i = 1606416664 (lldb) n (int) a = 10 (int) b = 20 (int) x = 10 (int) i = 0 (lldb)
答案 1 :(得分:0)
这可以方便地在一个命令中执行所有操作:
make && chmod 755 your_program && lldb -s <(echo 'target stop-hook add --one-liner "frame variable"') your_program your_program_s_arguments