c - 显示 lldb 中每一步的所有帧变量

标签 c gdb lldb

如何显示 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() 例程中所有变量的值

最佳答案

这个 lldb 命令应该可以解决问题:

target stop-hook add --one-liner "frame variable"

例子:

(lldb) b print_all_variables
断点 2: where = stophook`print_all_variables + 10 at main.c:14, address = 0x0000000100000eca
(lldb) target stop-hook add --one-liner "frame variable"
停止钩 #1 添加。
(lldb) c
进程 4838 恢复
(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) 我 = 0
(lldb)

关于c - 显示 lldb 中每一步的所有帧变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20590855/

相关文章:

c++ - 链接失败,怎么回事?

linux - 如何从 gdb 中自动重新连接到由 valgrind 控制的进程?

c++ - std::condition_variable 仅在调试时有效?

swift - 如何在 Xcode 6 调试器中查看 Swift "let"常量的值

c++ - 调试时在lldb中获取类静态成员函数地址 : Interpreter couldn't resolve a value during execution

gcc - 计算 GDB 和 LLDB 中的表达式

c - 在c中存储地址动态数组

c - C 中的嵌套 for 循环模式

c - 将动态分配的二维数组分配给结构中的双指针时出现段错误

linux - gdb - 目标中不支持硬件断点