久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Xcode 4.2/iOS 5 下控制臺中沒有異常堆棧跟蹤?

No exception stacktrace in console under Xcode 4.2/iOS 5?(Xcode 4.2/iOS 5 下控制臺中沒有異常堆棧跟蹤?)
本文介紹了Xcode 4.2/iOS 5 下控制臺中沒有異常堆棧跟蹤?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

在 Xcode 3.x 和 iOS 4 下,如果在模擬器中發出未處理的異常信號,則會在控制臺輸出中生成異常堆棧跟蹤(類似于 Java 的).

Under Xcode 3.x and iOS 4, if an unhandled exception is signaled in the emulator there is an exception stack trace (similar to Java's) produced in the console output.

當我在 Xcode 4.2 下的 iOS 5 中引發未處理的異常時,運行完全相同的應用程序代碼,堆棧跟蹤不會發生.(我確實想出了如何設置異常斷點,但這不會在控制臺中產生回溯.)

When I raise an unhandled exception in iOS 5 under Xcode 4.2, running the exact same app code, the stack trace does not occur. (I did figure out how to set an exception breakpoint, but that doesn't produce the traceback in the console.)

這僅僅是我需要在某處進行的 Xcode 設置,還是功能"?Xcode 4/iOS 5 的?有沒有辦法恢復這部分功能?

Is this merely an Xcode setting I need to make somewhere, or a "feature" of Xcode 4/iOS 5? Is there some way restore this bit of functionality?

不幸的是,添加 uncaughtExceptionHandler 不起作用.這是處理程序:

Unfortunately, adding an uncaughtExceptionHandler doesn't work. Here is the handler:

void uncaughtExceptionHandler(NSException *exception) {
    NSLog(@"uncaughtExceptionHnadler -- Exception %@", [exception description]);
    // Because iOS 5 doesn't provide a traceback, provide one here
    NSLog(@"Stack trace: %@", [exception callStackSymbols]);
    // Let Flurry look at the error
    [FlurryAPI logError:@"Uncaught" message:@"Crash!" exception:exception];
}                                               

(事實證明它已經存在,為了做 Flurry 的事情,所以我只是添加了堆棧跟蹤.)

(It turns out it was already present, to do the Flurry thing, so I just added the stack trace.)

這里是啟用它的地方(就在聲明處理程序的下面幾行):

Here is where it's enabled (just a few lines below where the handler is declared):

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // Enable uncaught exception handler to dump stack and let Flurry log the exception
    NSUncaughtExceptionHandler* hdlr = NSGetUncaughtExceptionHandler();
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
    NSUncaughtExceptionHandler* newHdlr = NSGetUncaughtExceptionHandler();
    
    // TODO: Test
    NSException* ex = [NSException exceptionWithName:@"AssertionFailure" reason:@"Test" userInfo:nil]; 
    @throw ex; 

我設置了斷點以使我能夠檢查兩個檢索到的處理程序值.第一個是 nil,第二個是明顯有效的地址.但是當測試異常被拋出時,處理程序(在 iOS 5 模擬器中)永遠不會得到控制.(雖然當我在 iOS 4.2 模擬器上運行時,它確實得到了控制.)

I set breakpoints to enable me to check the two retrieved handler values. The first one is nil and the second is an apparently valid address. But when the test exception is thrown the handler (in iOS 5 simulator) never gets control. (Though when I run on the iOS 4.2 simulator it does get control.)

在 iPhone 上設置 NSExceptionHandlingMask 顯然是不可能的.先決條件 ExceptionHandling.framework 不可用.

Setting NSExceptionHandlingMask is apparently not possible on iPhone. The prereq ExceptionHandling.framework is not available.

這行得通:

int main(int argc, char *argv[]) {
    
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = -1;
    @try {
        retVal = UIApplicationMain(argc, argv, nil, nil);
    }
    @catch (NSException* exception) {
        NSLog(@"Uncaught exception: %@", exception.description);
        NSLog(@"Stack trace: %@", [exception callStackSymbols]);
    }
    [pool release];
    return retVal;
}

推薦答案

這可行:

int main(int argc, char *argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = -1;
    @try {
        retVal = UIApplicationMain(argc, argv, nil, nil);
    }
    @catch (NSException* exception) {
        NSLog(@"Uncaught exception: %@", exception.description);
        NSLog(@"Stack trace: %@", [exception callStackSymbols]);
    }
    [pool release];
    return retVal;
}

對于 ARC:

int main(int argc, char *argv[]) {

    int retVal = -1;
    @autoreleasepool {
        @try {
            retVal = UIApplicationMain(argc, argv, nil, nil);
        }
        @catch (NSException* exception) {
            NSLog(@"Uncaught exception: %@", exception.description);
            NSLog(@"Stack trace: %@", [exception callStackSymbols]);
        }
    }
    return retVal;
}

仍在等待有關為什么默認轉儲不再起作用和/或為什么(甚至更嚴重)uncaughtExceptionHandler 不起作用的某種解釋.但是,顯然這個問題只影響模擬器.

Still waiting for some sort of explanation as to why the default dump no longer works and/or why (even more serious) uncaughtExceptionHandler doesn't work. However, apparently this problem only affects the emulator.

已經指出,如果你去產品->方案 ->編輯方案,選擇運行(調試)",選擇診斷";選項卡,然后單擊Log Exceptions",這將恢復丟失的 Xcode 默認異常日志記錄,可能(我還沒有嘗試過)消除了對上述 hack 的需要.

It has been pointed out that if you go to Product -> Scheme -> Edit Scheme, select "Run (Debug)", select the "Diagnostics" tab, and click "Log Exceptions", this will restore the missing Xcode default exception logging, possibly (I haven't tried it yet) eliminating the need for the above hack.

這篇關于Xcode 4.2/iOS 5 下控制臺中沒有異常堆棧跟蹤?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
Send backspace key event to edit text(發送退格鍵事件以編輯文本)
Android: How to set password property in an edit text?(Android:如何在編輯文本中設置密碼屬性?)
Label in a editbox in android(在android的編輯框中添加標簽)
actionDone imeOption doesn#39;t work on EditText in Android 2.3(actionDone imeOption 不適用于 Android 2.3 中的 EditText)
主站蜘蛛池模板: 欧美成年黄网站色视频 | 蜜臀网| 国产精品久久久久久久免费大片 | xxxxxx国产 | 午夜精品久久久久久久99黑人 | 国产一区二区三区四区 | 亚洲精品电影 | 三级视频在线观看 | 国产成人精品久久二区二区 | 韩国精品在线 | 欧美日韩在线视频一区二区 | 亚洲综合在 | 亚洲精品国产电影 | 日韩国产精品一区二区三区 | 国产欧美在线 | av看片网站| 婷婷开心激情综合五月天 | 国产成人午夜精品影院游乐网 | 六月成人网 | 日韩亚洲视频 | www国产成人免费观看视频,深夜成人网 | 欧美精品一二区 | 成人三级影院 | 91视频大全 | 欧美一极视频 | 久久尤物免费一区二区三区 | aacc678成免费人电影网站 | 精品成人av | 欧洲成人午夜免费大片 | 久久国产精品一区 | 毛片一级电影 | 国产98在线 | 免费, | 中国一级特黄真人毛片免费观看 | 中文在线a在线 | 91高清免费观看 | 一区在线观看 | 日本高清中文字幕 | 国产成人久久精品 | 精品久久九 | 久久久成人动漫 | 久草视频网站 |