2013-05-02 70 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