久久久久久久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)
主站蜘蛛池模板: 日韩中文字幕免费 | 蜜桃视频在线观看免费视频网站www | 精品91久久| 在线视频亚洲 | 欧美日韩黄色一级片 | 黄色片网此| 日韩精品一区二区三区 | av免费网站在线观看 | 91精品国产乱码久久久久久久久 | 亚洲成人一区二区三区 | 久久久久国产精品一区二区 | 天天玩天天干天天操 | 日韩综合网 | 久久一区二区三区四区 | 超碰成人免费观看 | 亚洲精品久久久久中文字幕二区 | 欧美国产激情 | 久久久女女女女999久久 | 久草在线 | 亚洲精视频 | 日韩一区二区三区精品 | 人人天天操 | 午夜影晥 | 国产成人精品免费视频大全最热 | 国产99久久久国产精品下药 | 欧美精品tv| 韩日精品一区 | 欧美日韩电影一区 | 九九福利 | 黄色精品 | 新超碰97| 韩三级在线观看 | 老司机久久 | 亚洲免费精品 | 久久久久久免费观看 | 成人a视频 | 国内精品免费久久久久软件老师 | 久久天堂 | 性高湖久久久久久久久 | 91视频在线网站 | 日韩一级免费看 |