Xcode添加断点调试.

当我们使用Xcode进行日常开发时,偶尔出现一些错误,Xcode反馈崩溃位置与错误信息并不与实际出现的问题的代码匹配.
这时我们可以通过以下操作,添加两个断点,保证程序在实际崩溃之前的那行代码停止,更直观的让我们发现问题的所在.

步骤如下:
  • 打开断点左标签,点击左下角的“+”按钮。
  • 选择 Exception Breakpoint.


    选择Exception Breackpoint
  • 系统会生成一个断点.保证断点信息如图所示.


    第一个断点
  • 再点击左下角的"+"按钮,选择 Symbolic Breakpoint.


    选择Symbolic Breakpoint
  • 在Symbol行输入malloc_error_break.保证断点信息如图所示.


    第二个断点
  • 设置结束,结果如图示.


    结果示例

设置完成,实现了我们需要的功能.可以更准确的进行debug了.


When those 2 breakpoints are enabled, xcode will automatically break on the faulting line instead of directly crashing without giving more informations.

To activate them, follow these steps :

  • open the breakpoint left tab, and click the "+" button in the bottom left corner.
  • select Add Exception Breakpoint.
  • Right click on the new breakpoint, and configure it this way :
    • Exception : All
    • Break : On throw
    • Action : Add Action
    • Options : leave the box unchecked.
  • Then add a symbolic break point ("+" button -> Add Symbolic Breakpoint)
  • Configure the breakpoint this way :
    • Symbol : malloc_error_break
    • don't modify all the other options
      You're done for starting debugging !

参考链接: Stackoverflow

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • *****************************(转载自此网址)********************...
    叶舞清风阅读 1,238评论 0 5
  • Xcode Debugging 你的代码,或者任何人的代码中总会有bug存在,你可以把调试看做是更好地理解代码的一...
    吃蘑菇De大灰狼阅读 2,491评论 0 2
  • 断点(转载) http://mp.weixin.qq.com/s?__biz=MzA4ODk0NjY4NA==&m...
    liwendong阅读 1,436评论 0 0
  • 《奇葩说》第五季开播,一堆新奇葩,一打老奇葩,还有更激烈的赛制,让这样一场别开生面的辩论,变得更富于刺激和娱乐性。...
    小幸甫阅读 166评论 0 1
  • 种花的准备又要忙了 于是我的心内十分充裕 感到空气对植株成活非常有利 这种季节必定有一场爱情 我很少在意自己不英俊...
    独立诗人金子阅读 205评论 0 1