Question

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

Was it helpful?

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) 

OTHER TIPS

This conveniently does everything in one command:

make && chmod 755 your_program && lldb -s <(echo 'target stop-hook add --one-liner "frame variable"') your_program your_program_s_arguments
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top