Xcode 如何通过LLDB命令行添加断点操作?

Xcode 如何通过LLDB命令行添加断点操作?,xcode,debugging,breakpoints,lldb,Xcode,Debugging,Breakpoints,Lldb,如果您从Xcode编辑一个断点,那么有一个非常有用的选项,可以添加一个“操作”,以便在每次命中断点时自动执行 如何从LLDB命令行添加这样的操作?轻松使用断点命令add命令。键入help breakpoint command add了解详细信息,但下面是一个示例 int main () { int i = 0; while (i < 30) { i++; // break here } } 添加断点条件,使断点仅在i为5的倍数时停止: (l

如果您从Xcode编辑一个断点,那么有一个非常有用的选项,可以添加一个“操作”,以便在每次命中断点时自动执行


如何从LLDB命令行添加这样的操作?

轻松使用
断点命令add
命令。键入
help breakpoint command add
了解详细信息,但下面是一个示例

int main ()
{
    int i = 0;
    while (i < 30)
    {
        i++; // break here
    }
}
添加断点条件,使断点仅在
i
为5的倍数时停止:

(lldb) br mod -c 'i % 5 == 0' 1
让断点打印
i
的当前值,并在点击时回溯:

(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
进程78674已停止并以编程方式重新启动。
进程78674已停止并以编程方式重新启动。
进程78674已停止并以编程方式重新启动。
进程78674已停止并以编程方式重新启动。
进程78674已停止
*线程#1:tid=0x1c03,0x0000000100000f5f a.out`main+31 at a.c:6,停止原因=断点1.1
#0:0x0000000100000f5f a.out`main+31 a.c:6
3 int i=0;
4时(i<30)
5        {
->6i++;//在这里中断
7        }
8    }
(int)$25=20
*线程#1:tid=0x1c03,0x0000000100000f5f a.out`main+31 at a.c:6,停止原因=断点1.1
#0:0x0000000100000f5f a.out`main+31 a.c:6
#1:0x00007fff8c2a17e1 libdyld.dylib`start+1

非常感谢你,伙计!我想它一定在“断点集”的某个地方,我完全找错了方向。
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