【问题标题】:"Execution was interrupted, reason: breakpoint" when trying to print something from the Xcode console尝试从 Xcode 控制台打印内容时出现“执行被中断,原因:断点”
【发布时间】:2013-08-01 23:13:01
【问题描述】:

我暂停了我的应用程序并尝试将某些内容打印到控制台。 (例如po foo())。这样做后,我收到以下消息:

错误:执行被中断,原因:断点2.1。
进程已恢复到执行前的状态。

但是,该函数中没有断点。为什么它显示这个错误而不执行函数?

这是在 Xcode 4.6 上。

【问题讨论】:

    标签: xcode llvm


    【解决方案1】:

    事实证明,有问题的断点 (2.1) 是 All Exceptions 断点。我调用的方法引发了一个异常,这导致了 All Exceptions 断点被命中。一旦到达断点,po 将停止执行(有关详细信息,请参阅this answer)。

    如果你禁用 All Exceptions 断点并再次运行它,更清楚的是有一个异常:

    error: Execution was interrupted, reason: signal SIGSTOP.
    The process has been returned to the state before execution.
    

    如果您始终启用 All Exceptions 断点,则消息可能不明确:它到达断点是因为执行路径中的某处确实存在断点,还是引发了异常?

    另一种解决方案(不需要禁用所有异常断点)是使用expr 而不是po(有关以下标志的说明,请参见上面的链接)。

    运行 expr -u 0 -o -- foo() 会产生以下输出:

    error: Execution was interrupted, reason: breakpoint 2.1 -2.1.
    The process has been left at the point where it was interrupted.  
    * thread #1: tid = [...] libobjc.A.dylib`objc_exception_throw, stop reason = breakpoint 2.1 -2.1  
        frame #0: [...] libobjc.A.dylib`objc_exception_throw
    

    objc_exception_throw 字符串暗示exception was raised

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-16
      • 1970-01-01
      • 1970-01-01
      • 2015-04-04
      • 2020-01-13
      • 2014-05-22
      • 2014-01-30
      • 2017-12-26
      相关资源
      最近更新 更多