【问题标题】:All exception break point is stopping for no reason on simulator所有异常断点在模拟器上无缘无故停止
【发布时间】:2015-02-07 03:36:12
【问题描述】:

这很烦人,每次我尝试在模拟器上使用“所有异常断点”进行调试时,应用程序都会无缘无故地停在这一行:

return UIApplicationMain(argc, argv, nil, NSStringFromClass([STAppDelegate class]));

有没有其他人发现他在这个问题上苦苦挣扎?

谢谢!

编辑

第一次投掷的回溯:

 thread #1: tid = 0x1d96b, 0x36fbf540 libc++abi.dylib`__cxa_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 3.2
    frame #0: 0x36fbf540 libc++abi.dylib`__cxa_throw
    frame #1: 0x306975cc libFontParser.dylib`TFileDescriptorContext::TFileDescriptorContext(char const*) + 112
    frame #2: 0x306973d8 libFontParser.dylib`TFileDataReference::TFileDataReference(char const*) + 164
    frame #3: 0x306971fc libFontParser.dylib`TFileDataSurrogate::TFileDataSurrogate(char const*, bool) + 188
    frame #4: 0x3069555a libFontParser.dylib`TFont::CreateFontEntitiesForFile(char const*, bool, TSimpleArray<TFont*>&, bool, short, char const*) + 1402
    frame #5: 0x30694a80 libFontParser.dylib`FPFontCreateFontsWithPath + 224
    frame #6: 0x2a5032bc libCGXType.A.dylib`create_private_data_with_path + 12
    frame #7: 0x2a3ca3c4 CoreGraphics`CGFontCreateFontsWithPath + 24
    frame #8: 0x2a4855d6 CoreGraphics`CGFontCreateFontsWithURL + 310
    frame #9: 0x313dfee4 GraphicsServices`AddFontsFromURLOrPath + 68
    frame #10: 0x313e39de GraphicsServices`__Initialize_block_invoke + 934
    frame #11: 0x0121fabe libdispatch.dylib`_dispatch_client_callout + 22
    frame #12: 0x01220750 libdispatch.dylib`dispatch_once_f + 100
    frame #13: 0x313df72c GraphicsServices`Initialize + 196
    frame #14: 0x377944c4 libobjc.A.dylib`_class_initialize + 536
    frame #15: 0x3779a046 libobjc.A.dylib`lookUpImpOrForward + 254
    frame #16: 0x37799f3e libobjc.A.dylib`_class_lookupMethodAndLoadCache3 + 34
    frame #17: 0x377a01f8 libobjc.A.dylib`_objc_msgSend_uncached + 24
    frame #18: 0x2d673b6e UIKit`-[UIStatusBarNewUIForegroundStyleAttributes makeTextFontForStyle:] + 78
    frame #19: 0x2d634d94 UIKit`-[UIStatusBarForegroundStyleAttributes textFontForStyle:] + 104
    frame #20: 0x2d5e767e UIKit`-[UIStatusBarServiceItemView updateForContentType:serviceString:serviceCrossfadeString:maxWidth:actions:] + 390
    frame #21: 0x2d5e74ee UIKit`-[UIStatusBarServiceItemView updateForNewData:actions:] + 186
    frame #22: 0x2d6428d0 UIKit`-[UIStatusBarItemView initWithItem:data:actions:style:] + 324
    frame #23: 0x2d642568 UIKit`-[UIStatusBarLayoutManager _createViewForItem:withData:actions:] + 108
    frame #24: 0x2d5e6f74 UIKit`-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:] + 264
    frame #25: 0x2d5e6e22 UIKit`-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:] + 74
    frame #26: 0x2d5e6c72 UIKit`-[UIStatusBarForegroundView _setStatusBarData:actions:animated:] + 162
    frame #27: 0x2d5e6b96 UIKit`-[UIStatusBarForegroundView setStatusBarData:actions:animated:] + 710
    frame #28: 0x2d671ebe UIKit`__44-[UIStatusBar _prepareToSetStyle:animation:]_block_invoke + 358
    frame #29: 0x2d5fc230 UIKit`+[UIView(Animation) performWithoutAnimation:] + 72
    frame #30: 0x2d66fcf4 UIKit`-[UIStatusBar _prepareToSetStyle:animation:] + 688
    frame #31: 0x2d6579ca UIKit`-[UIStatusBar _requestStyleAttributes:animationParameters:] + 290
    frame #32: 0x2d65696e UIKit`-[UIStatusBar requestStyle:animated:] + 86
    frame #33: 0x2d65559a UIKit`-[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:] + 406
    frame #34: 0x2d85122a UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 970
    frame #35: 0x2d85bc68 UIKit`__84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke + 36
    frame #36: 0x2d84fc5a UIKit`-[UIApplication workspaceDidEndTransaction:] + 130
    frame #37: 0x3086c0e0 FrontBoardServices`__31-[FBSSerialQueue performAsync:]_block_invoke + 12
    frame #38: 0x2a13782c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    frame #39: 0x2a136af0 CoreFoundation`__CFRunLoopDoBlocks + 216
    frame #40: 0x2a13564a CoreFoundation`__CFRunLoopRun + 1714
    frame #41: 0x2a082db0 CoreFoundation`CFRunLoopRunSpecific + 476
    frame #42: 0x2a082bc2 CoreFoundation`CFRunLoopRunInMode + 106
    frame #43: 0x2d653c36 UIKit`-[UIApplication _run] + 558
    frame #44: 0x2d64ea30 UIKit`UIApplicationMain + 1440
  * frame #45: 0x003b4ec2 Stox`main(argc=1, argv=0x01200b08) + 178 at main.m:17

第三:

 thread #1: tid = 0x1d96b, 0x36fbf540 libc++abi.dylib`__cxa_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 3.2
    frame #0: 0x36fbf540 libc++abi.dylib`__cxa_throw
    frame #1: 0x30798c22 libTrueTypeScaler.dylib`ScalerNewBlock(memoryContext*, long, long, void*, unsigned char, unsigned char) + 430
    frame #2: 0x3077e172 libTrueTypeScaler.dylib`OutlineToPath(memoryContext*, fnt_ElementType const*) + 178
    frame #3: 0x3079502a libTrueTypeScaler.dylib`ObtainDesiredOutline(memoryContext*, fnt_ElementType const*, unsigned long, void**) + 10
    frame #4: 0x3077e07c libTrueTypeScaler.dylib`RenderPath(fsg_SplineKey*, memoryContext*, scalerGlyph const*) + 36
    frame #5: 0x3077c980 libTrueTypeScaler.dylib`TTRenderGlyphs + 436
    frame #6: 0x306c5722 libFontParser.dylib`TConcreteFontScaler::CopyGlyphPath(unsigned short, CGAffineTransform const*) const + 378
    frame #7: 0x306a0ce6 libFontParser.dylib`FPFontCopyGlyphPath + 494
    frame #8: 0x2a3abb4a CoreGraphics`CGFontCreateGlyphPath + 30
    frame #9: 0x2a3aba56 CoreGraphics`CGFontCreateGlyphBitmap + 266
    frame #10: 0x2a3b3c1a CoreGraphics`CGGlyphBuilder::create_missing_bitmaps(CGGlyphIdentifier const*, unsigned long, CGGlyphBitmap const**) + 82
    frame #11: 0x2a6fd4dc libRIP.A.dylib`render_glyphs + 172
    frame #12: 0x2a6fcaca libRIP.A.dylib`draw_glyph_bitmaps + 906
    frame #13: 0x2a6fc430 libRIP.A.dylib`ripc_DrawGlyphs + 1108
    frame #14: 0x2a3a1002 CoreGraphics`draw_glyphs + 274
    frame #15: 0x2aaae268 CoreText`DrawSbixGlyphsAtPositions(TFont const*, CGFont*, TCFRef<__CFData const*> const&, unsigned short const*, CGPoint const*, unsigned long, CGContext*, CGAffineTransform, CGAffineTransform) + 1880
    frame #16: 0x2aa6bcce CoreText`CTFontDrawGlyphsWithAdvances + 470
    frame #17: 0x349eba1a UIFoundation`__NSStringDrawingEngine + 6710
    frame #18: 0x349efa64 UIFoundation`-[NSAttributedString(NSExtendedStringDrawing) drawWithRect:options:context:] + 532
    frame #19: 0x2d603370 UIKit`-[UILabel _drawTextInRect:baselineCalculationOnly:] + 4440
    frame #20: 0x2d668ed4 UIKit`-[UILabel drawTextInRect:] + 488
    frame #21: 0x2d668ce8 UIKit`-[UILabel drawRect:] + 84
    frame #22: 0x2d668c70 UIKit`-[UIView(CALayerDelegate) drawLayer:inContext:] + 400
    frame #23: 0x2d045910 QuartzCore`-[CALayer drawInContext:] + 228
    frame #24: 0x2d02f350 QuartzCore`CABackingStoreUpdate_ + 2068
    frame #25: 0x2d110b6c QuartzCore`___ZN2CA5Layer8display_Ev_block_invoke + 52
    frame #26: 0x2d02eb34 QuartzCore`x_blame_allocations + 88
    frame #27: 0x2d02e7e4 QuartzCore`CA::Layer::display_() + 1156
    frame #28: 0x2d012d9c QuartzCore`CA::Layer::display_if_needed(CA::Transaction*) + 200
    frame #29: 0x2d012a60 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
    frame #30: 0x2d012446 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 222
    frame #31: 0x2d012250 QuartzCore`CA::Transaction::commit() + 324
    frame #32: 0x2d5e51c8 UIKit`_afterCACommitHandler + 132
    frame #33: 0x2a137844 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
    frame #34: 0x2a134f28 CoreFoundation`__CFRunLoopDoObservers + 276
    frame #35: 0x2a13532a CoreFoundation`__CFRunLoopRun + 914
    frame #36: 0x2a082db0 CoreFoundation`CFRunLoopRunSpecific + 476
    frame #37: 0x2a082bc2 CoreFoundation`CFRunLoopRunInMode + 106
    frame #38: 0x313e7050 GraphicsServices`GSEventRunModal + 136
    frame #39: 0x2d64ea30 UIKit`UIApplicationMain + 1440
  * frame #40: 0x003b4ec2 Stox`main(argc=1, argv=0x01200b08) + 178 at main.m:17

【问题讨论】:

  • 您的代码中有异常。暂时禁用异常,继续执行并读取控制台日志。
  • 我在异常之后继续,大约 3 次继续按下后(每次都在同一点再次停止),我得到一个日志“void CGPathAddLineToPoint(CGMutablePathRef, const CGAffineTransform *, CGFloat, CGFloat) : 没有当前点。”该应用程序继续正常运行!好奇怪..
  • 你在做任何自定义绘图吗?当您调用 CGContextAddLineToPoint 之前调用 CGContextMoveToPoint 时,通常会发生该错误。
  • 是的,异常很可能是被什么东西捕捉到并处理了。
  • @KerrM 我在我的应用程序中使用了很多地方.. 所以它有点难以追踪......但奇怪的是我很难过,它只在两次后出现在日志中我按继续!此外,该应用程序不会粉碎!这很常见吗?

标签: objective-c xcode ios-simulator


【解决方案1】:

我刚刚遇到了同样的问题并找到了问题所在。

确保您在Info.plistFonts provided by this application 下指定的所有字体实际上都在您的应用程序包中。

【讨论】:

  • 在拉了很多头发并尝试了所有可能的方法之后,我找到了你的建议,它对我有用
  • 你先生是个英雄,我的问题也是字体打错了。
  • 我的一个 .xib 文件中有旧字体。将其更改为系统字体解决了该问题。谢谢!
  • 我遇到了同样的遗留字体问题。下面是我如何找到它的:find . -name "*.xib" -or -name "*.storyboard" -exec grep -i font {} \; | grep family 搜索项目然后寻找name 显示了 ui 元素。 (我不是 shell 专家)
  • 改进@thetrutz 正则表达式:find . -name "*.xib" -or -name "*.storyboard" -exec bash -c 'echo "{}"; grep -i font "{}"' \; | grep -E 'family|^\.' 这也将打印包含匹配项的文件名。
【解决方案2】:

有一种更准确的方法可以使用调试器在您的应用中追踪可疑字体,而且它可以在调用时方便地停止。

第 1 步:重现 __cxa_throw 断点

通常在您的应用中实例化一个(或可能是第一个)UIView 对象时会发生这种情况。你会看到你的调试器坏了,你会有一个这样的堆栈:

第 2 步:选择堆栈跟踪中带有符号 FPFontCreateFontsWithPath 的条目

在我的例子中,这个条目是堆栈中的第 7 行。

如果你看一下反汇编,你会注意到这个条目的函数签名:

啊,酷!看起来它需要一些C字符串。我敢打赌其中一个也是文件路径!

第 3 步:在应用内存中找到该字符串

我在 (x86_64) 模拟器中运行它,它在我的计算机上将函数参数存储在一些以 r 开头的寄存器中。 More details on registers here.

按 Shift+Command+M 或从菜单中选择“调试 > 调试工作流程 > 查看内存”选项。

在此视图的底部,逐个浏览寄存器并输入地址。在我的例子中,r14 包含文件的路径。

好的,现在我知道是什么字体搞砸了。它正在寻找 HelveticaNeue.ttc。让我们在项目中找到对它的引用。

打开终端,导航到您的项目并运行:

$ ~/W/X/project> grep -R "HelveticaNeue" ./
.//MyProject/Main.Storyboard:        <array key="HelveticaNeue.ttc">
.//MyProject/Main.Storyboard:            <string>HelveticaNeue</string>
.//MyProject/Main.Storyboard:                                <fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="18"/>

太棒了,现在要么通过将 name="HelveticaNeue" family="Helvetica Neue" 替换为 type="system" 来将它们切换到系统,打开情节提要并手动编辑它们,或者将对缺少字体的引用添加到您的应用程序(info.plist 和目标)。

第 4 步:庆祝 ? ? ? ?

【讨论】:

  • 很棒的提示,非常感谢!在我的例子中,[View memory of "r15"] 没有显示字体名称,而是右键单击寄存器并选择 [Print description of "r15"] 在控制台中显示它。
  • 非常感谢!在与字体的战斗获胜后,我们有理由庆祝!只是一些对某人有用的注释:*您可以将文件添加为 .ttc(标准 mac 格式)*在 .plist 文件中添加整个文件名(带扩展名):即 helveticaneue.ttc
  • 不知道如何处理第 3 步,但我们可以在堆栈跟踪倒数第二个函数中选择并在控制台“寄存器读取 r14”中检查寄存器并在查看内存工具中查看生成的内存地址(指向以上)
  • 请解释更多以点击第 3 步,我无法找到寄存器。
  • 第 3 步的额外信息:调试器的变量视图在左下角有一个切换开关,带有三个选项:1. 自动(默认)、2. 局部变量和 3. 所有变量、寄存器、全局变量和静态变量。选择选项 3 以显示寄存器。
【解决方案3】:

正如回溯所示,应用程序并没有无缘无故停止。它停止了,因为抛出了一个异常,它看起来像一个 C++ 异常。

与 Objective-C 不同,异常只能作为编程错误的结果抛出,因此非常罕见,有很多 C++ 代码可以抛出和捕获大量异常。在那种情况下,最好只在 Objective-C 异常上设置断点,而不是所有异常。

【讨论】:

  • 如果有人需要这样做,只需右键单击断点,编辑并从“all”切换到“objective-c”
【解决方案4】:

如果您在 .plist 文件中没有发现问题,则问题可能出在您的 .storyboard 文件中。 从 Xcode 或在 Finder 的 textView 中将其打开为 源代码 - 搜索&lt;customFonts key="customFonts"&gt; 我里面有一些旧的不相关的数组/字体...:) 刚刚删除它并停止了

【讨论】:

  • 您的回答完全为我解决了!我在我的故事板和 .xib 文件中搜索了“customFont”,并在其中两个中找到了它。当我从两个文件中破解该部分时,问题就解决了!无论如何,它只是引用了一个系统字体 HelveticaNeue-Bold。 (我没有在我的应用程序的 .plist 中命名任何字体,所以这个 SO 中的主要解决方案对我没有帮助)。
【解决方案5】:

在我的例子中,引用在 xcuserdata 内:

user$ grep -R "HelveticaNeue" ./
Binary file .//MyProject.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate matches

【讨论】:

    【解决方案6】:

    一个异常被抛出,但是调用者(例如在 libFontParser 和 libTrueTypeScaler 中)正在处理它并且它没有到达你的程序。

    除非您看到问题的其他证据(例如日志消息)或异常到达您的程序,否则假定实现正在处理它。您可以在调试器中继续通过这些实例而无需担心。

    【讨论】:

    • 感谢您的回答,但我正在寻找一种方法来避免这些异常,因为它非常享受必须按三下“继续”。每次我运行应用程序时。
    • 你无法避免异常。您可以在 Xcode 中更改“异常”断点。
    【解决方案7】:

    我通过结合nmock's answerDaNLtR's answer 解决了这个问题。

    所以一开始我寻找&lt;customFonts key="customFonts"&gt;,里面有Montserrat-Light
    但它既没有出现在 info.plist 中,也没有添加到项目中。

    一旦我将Montserrat-Light.ttf 捆绑到项目中并在info.plist 中的Fonts provided by this application 下添加此字体的条目,问题就消失了。

    以下是上述解决方案的总结:

    1. 在您的 StoryboardXib 文件中查找任何自定义字体。
      您可以在&lt;customFonts key="customFonts"&gt; 中找到它们
    2. 如果实际上提到了自定义字体,请按照步骤 3 和 4 进行操作
    3. 将字体添加到您的 Xcode 项目中。
    4. Fonts provided by this application 下向 info.plist 添加一个条目。
      该条目应该是字体文件的名称,后跟其扩展名。
    5. 如果&lt;customFonts key="customFonts"&gt; 不包含任何自定义字体(例如:Helvetica-Neue 等),请尝试删除StroyboardXib 文件中的&lt;customFonts key="customFonts"&gt; 条目,如DaNLtR's answer 中所述李>

    我知道现在回答很晚,但希望这对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 2013-08-11
      • 2015-02-25
      • 1970-01-01
      • 2015-03-25
      • 2021-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多