2013-05-02 109 views

回答

18

易於與breakpoint command add命令。請輸入help breakpoint command add以獲取詳細信息,但這裏是一個示例。

int main() 
{ 
    int i = 0; 
    while (i < 30) 
    { 
     i++; // break here 
    } 
} 

對此運行lldb。首先,把一個斷點在源代碼行以「破」的地方在它(好的速記像這樣的例子,但它基本上有你的源代碼的grep過來的,所以不適合大型項目有用)

(lldb) br s -p break 
Breakpoint 1: where = a.out`main + 31 at a.c:6, address = 0x0000000100000f5f 

添加斷點

(lldb) br mod -c 'i % 5 == 0' 1 

具有斷點打印的i和回溯的電流值,當它擊中:狀態所以斷點時i是5的倍數僅停止

(lldb) br com add 1 
Enter your debugger command(s). Type 'DONE' to end. 
> p i 
> bt 
> DONE 

然後使用它:

Process 78674 stopped and was programmatically restarted. 
Process 78674 stopped and was programmatically restarted. 
Process 78674 stopped and was programmatically restarted. 
Process 78674 stopped and was programmatically restarted. 
Process 78674 stopped 
* thread #1: tid = 0x1c03, 0x0000000100000f5f a.out`main + 31 at a.c:6, stop reason = breakpoint 1.1 
    #0: 0x0000000100000f5f a.out`main + 31 at a.c:6 
    3  int i = 0; 
    4  while (i < 30) 
    5  { 
-> 6   i++; // break here 
    7  } 
    8 } 
(int) $25 = 20 
* thread #1: tid = 0x1c03, 0x0000000100000f5f a.out`main + 31 at a.c:6, stop reason = breakpoint 1.1 
    #0: 0x0000000100000f5f a.out`main + 31 at a.c:6 
    #1: 0x00007fff8c2a17e1 libdyld.dylib`start + 1 
+0

非常感謝老兄!我認爲它一定是在「斷點設置」的某個地方,而我完全是在錯誤地咆哮。 – PHD 2013-05-02 19:47:38