2014-01-05 59 views
2

当在Xcode 5中进行调试时,是否有任何方法来隐藏调用堆栈并仅显示错误日志,或者手动打开和关闭它?我只希望错误日志是这样的:在xcode 5中隐藏“*** First call call stack”

TestProject[31643:70b] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'SecondViewController'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.' 

但它总是抛出调用stack.I必须向上滚动才能看到上面的日志。 这是令人讨厌的,因为我的MacBook是一个13英寸的macbook.How我可以隐藏下面的调用堆栈?

*** First throw call stack: 
(
    0 CoreFoundation      0x0174f5e4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x014be8b6 objc_exception_throw + 44 
    2 UIKit        0x00b95ca5 -[UIStoryboardPushSegue destinationContainmentContext] + 0 
    3 UIKit        0x00b8607e -[UIStoryboardSegueTemplate _perform:] + 174 
    4 UIKit        0x00767280 -[UIViewController performSegueWithIdentifier:sender:] + 72 
    5 UIKit        0x0e1b508c -[UIViewControllerAccessibility(SafeCategory) performSegueWithIdentifier:sender:] + 63 
    6 TestProject       0x00002bd9 -[ViewController imagePickerController:didFinishPickingMediaWithInfo:] + 345 
    7 UIKit        0x008c9e7e -[UIImagePickerController _imagePickerDidCompleteWithInfo:] + 506 
    8 PhotoLibrary      0x0ee7fe94 PLNotifyImagePickerOfImageAvailability + 106 
    9 PhotosUI       0x11015585 -[PUUIPhotosAlbumViewController handleNavigateToAsset:inContainer:] + 401 
    10 PhotosUI       0x10f987b4 -[PUPhotosGridViewController collectionView:shouldSelectItemAtIndexPath:] + 577 
    11 UIKit        0x00c61c0b -[UICollectionView _selectItemAtIndexPath:animated:scrollPosition:notifyDelegate:] + 173 
    12 UIKit        0x00c7a1f8 -[UICollectionView _userSelectItemAtIndexPath:] + 189 
    13 UIKit        0x00c7a3b5 -[UICollectionView touchesEnded:withEvent:] + 437 
    14 libobjc.A.dylib      0x014d0874 -[NSObject performSelector:withObject:withObject:] + 77 
    15 UIKit        0x007aa902 forwardTouchMethod + 271 
    16 UIKit        0x007aa972 -[UIResponder touchesEnded:withEvent:] + 30 
    17 libobjc.A.dylib      0x014d0874 -[NSObject performSelector:withObject:withObject:] + 77 
    18 UIKit        0x007aa902 forwardTouchMethod + 271 
    19 UIKit        0x007aa972 -[UIResponder touchesEnded:withEvent:] + 30 
    20 libobjc.A.dylib      0x014d0874 -[NSObject performSelector:withObject:withObject:] + 77 
    21 UIKit        0x007aa902 forwardTouchMethod + 271 
    22 UIKit        0x007aa972 -[UIResponder touchesEnded:withEvent:] + 30 
    23 UIKit        0x009c5c7f _UIGestureRecognizerUpdate + 7166 
    24 UIKit        0x0069019a -[UIWindow _sendGesturesForEvent:] + 1291 
    25 UIKit        0x006910ba -[UIWindow sendEvent:] + 1030 
    26 UIKit        0x00664e86 -[UIApplication sendEvent:] + 242 
    27 UIKit        0x0064f18f _UIApplicationHandleEventQueue + 11421 
    28 CoreFoundation      0x016d883f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
    29 CoreFoundation      0x016d81cb __CFRunLoopDoSources0 + 235 
    30 CoreFoundation      0x016f529e __CFRunLoopRun + 910 
    31 CoreFoundation      0x016f4ac3 CFRunLoopRunSpecific + 467 
    32 CoreFoundation      0x016f48db CFRunLoopRunInMode + 123 
    33 GraphicsServices     0x034b29e2 GSEventRunModal + 192 
    34 GraphicsServices     0x034b2809 GSEventRun + 104 
    35 UIKit        0x00651d3b UIApplicationMain + 1225 
    36 TestProject       0x0000237d main + 141 
    37 libdyld.dylib      0x01d7970d start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
+4

心存感激。由于Xcode的一些奇怪,许多人不能可靠地获得调用堆栈。当你需要它的时候(通常是),你真的需要它。 –

+0

我认为这会很好,如果我可以手动打开和关闭它@ @ HotLicks – johnMa

回答

1

不,我不相信你可以关闭堆栈跟踪。

事实是,尽管它“让你生气”,它们仍然可以帮助你调试问题。没有堆栈跟踪,这样做会困难得多。

+1

是的,他们可以帮助我调试问题,但我真的想先看到错误日志。感谢您的回复,但它不是我想要的是。 – johnMa

3

在x86模拟器中最简单的方法是添加一个异常断点并将其编辑为在断点处输出$eax,因为$ eax将包含异常原因。这样,当发生异常时,您可以查看原因作为您的上一次控制台输出,并能够浏览调用堆栈中的线索。

除此之外,你可以尝试swizzling -[NSException callStackReturnAddresses]返回一个空的数组。


更新

由于$eax只能在x86模拟器,你将需要64位模拟器和设备稍有不同的机制。一种方法是跳到第0帧(objc_exception_throw),并通过堆栈搜索指向原因的内存地址。通过一些小小的试验和错误,我发现32位模拟器的地址为(*((id*)$esp+8)),64位模拟器的地址为(*((id*)$rsp+7))。这对-[NSException raise]+[NSException raise:format:]呼叫都是一致的。我明天会检查设备。


更新2

原来这是一个更容易。例外始终是在该平台的第一个寄存器:

  • 32位模拟器:$eax
  • 64位模拟器:
  • 32位设备:$r0

我不知道arm64的约定,但例外可能会生活在第一个64位寄存器。如果你只是在一个平台上进行调试,那么你可以使用一个例外。如果你要调试多个平台上,你可以添加一个动作每一个接受,你会得到关于未知的寄存器一些错误消息,但他们都应该仍然适合您的屏幕不滚动:

enter image description here

+0

'$ eax'只适用于x86架构(32位iOS模拟器) –

+0

@BryanChen我已经添加了一条评论来解决这个问题。我有64位模拟器,所以我追踪了它的堆栈指针,但我明天可以获得arm32。 –

+0

如何从寄存器中获取常见错误日志?谢谢,一旦我弄清楚它是如何工作的,我会尽快接受它。 – johnMa