Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display all frame variables for every step in lldb

Tags:

c

gdb

lldb

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

like image 801
user376507 Avatar asked Dec 19 '22 20:12

user376507


1 Answers

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) 
like image 171
Martin R Avatar answered Dec 24 '22 01:12

Martin R