Display all frame variables for every step in lldb

c, gdb, lldb

Solution

This lldb command should do the trick:

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

Example:

(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) 

Problem

How to display all frame variables for every step in `lldb`? For example, I have a routine in `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; } ``` I would want to display, values of all the variables in print_all_variables() routine above for every step while debugging using `lldb`

Original source