2013-12-15 65 views
2

如何顯示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; 
} 

例行我將要顯示,在print_all_variables()例程上述每一步的所有變量的值,而使用lldb

回答

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) 
+0

謝謝你,這個工程。 – user376507

0

這樣可方便地做一切在一個命令:

make && chmod 755 your_program && lldb -s <(echo 'target stop-hook add --one-liner "frame variable"') your_program your_program_s_arguments 
相關問題