简体   繁体   中英

Hide “*** First throw call stack” in xcode 5

When debug in Xcode 5. is there any way to hide the call stack and show error log only,or turn it on and off manually??I only want the error log like this:

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.'

But it always throw call stack.I have to scroll up to see the above log. Which is annoying because my macbook is a 13inch macbook.How can i hide the call stack below?

*** 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

The simplest way to go about this in the x86 simulator is to add an exception breakpoint and edit it to output $eax on break, as $eax will contain the exception reason. This way, when an exception occurs, you can see the reason as your last console output and be able to navigate the call stack for clues.

Beyond that, you could try swizzling -[NSException callStackReturnAddresses] to return an empty array.


Update

Since the $eax only works on the x86 simulator, you will need a slightly different mechanism for the 64-bit simulator and devices. One way to do this is to hop to frame 0 ( objc_exception_throw ) and search back through the stack for the memory address pointing to the reason. Through a little trial and error, I found that the 32-bit simulator has it at (*((id*)$esp+8)) and the 64-bit simulator has it at (*((id*)$rsp+7)) . This is consistent for both -[NSException raise] and +[NSException raise:format:] calls. I'll check on device tomorrow.


Update 2

Turns out it's a lot easier. The exception is always on the first register for the platform:

  • 32-bit simulator: $eax
  • 64-bit simulator: $rax
  • 32-bit device: $r0

I don't know the convention for arm64, but the exception will probably live on the first 64-bit register. If you're just going to debug on one platform, you can just use the one exception. If you're going to debug multiple platforms, you could add an action for each accepting that you'll get some error messages about unknown registers, but they should all still fit on your screen without scrolling:

在此处输入图片说明

No I don't believe you can turn off stack traces.

The truth is, as much as it 'pisses you off', they are there to help you debug the problem. Without the stack trace, it would be much more difficult to do so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM