iOS應用崩潰(三) 崩潰日誌

2021-07-09 04:36:16 字數 2619 閱讀 5125

當我們在模擬器上除錯時,可能經常遇到下面的記憶體訪問錯誤:

該錯誤是對乙個已經釋放的物件進行操作,定位如下:

(2)、終端輸入 info malloc-history 命令,即可得到堆疊資訊,從而分析具體問題所在

(gdb) info malloc-history 0x12e4b0

(3)、也可輸入如下資訊:

(gdb) shell malloc_history

ps:記憶體使用時「exc_bad_access」的錯誤資訊也是經常遇到的,這時我們只要將上面執行檔案屬性中的 nszombieenabled 選上,也能定位該問題。

ios開發中我們會遇到程式丟擲異常退出的情況,如果是在除錯的過程中,異常的資訊是一目了然,但是如果是在已經發布的程式中,獲取異常的資訊有時候是比較困難的。

介面宣告:

#import 

@inte***ce

nduncaughtexceptionhandler : nsobject

+ (void)setdefaulthandler;

+ (nsuncaughtexceptionhandler*)gethandler;

@end

介面實現:

#import "nduncaughtexceptionhandler.h"

//返回絕對路徑

return [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) lastobject];

}void uncaughtexceptionhandler(n***ception *exception)

@implementation

nduncaughtexceptionhandler

//返回絕對路徑

return [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) lastobject];

}+ (void)setdefaulthandler

+ (nsuncaughtexceptionhandler*)gethandler

@end

呼叫事例:

[nduncaughtexceptionhandler setdefaulthandler];

nslog(@"%@", [array objectatindex:1]);

return

yes;}

崩潰資訊如下:

**********===異常崩潰報告**********===

name:

nsrangeexception

reason:

*** -[__nsarrayi objectatindex:]: index 1 beyond bounds [0 .. 0]

callstacksymbols:

0 corefoundation 0x0000000108573c65 __exceptionpreprocess + 165

1 libobjc.a

.dylib

0x000000010820cbb7 objc_exception_throw + 45

2 corefoundation 0x000000010846a17e -[__nsarrayi objectatindex:] + 190

8 frontboardservices 0x000000010dd095e5 __31-[fbsserialqueue performasync:]_block_invoke_2 + 21

9 corefoundation 0x00000001084a741c __cfrunloop_is_calling_out_to_a_block__ + 12

10 corefoundation 0x000000010849d165 __cfrunloopdoblocks + 341

11 corefoundation 0x000000010849c947 __cfrunlooprun + 887

12 corefoundation 0x000000010849c366 cfrunlooprunspecific + 470

15 uicolordemo 0x0000000107c88e4f main + 111

16 libdyld.dylib

0x000000010afcc145 start + 1

17 ??? 0x0000000000000001

0x0 + 1

**如下:

IOS崩潰日誌

1.普通崩潰日誌 參考 1 程序資訊 incident identifier 30e46451 53fd 4965 896a 457fc11ad05f 崩潰報告的唯一識別符號 是與裝置標識相對應的唯一鍵值。雖然它不是真正的裝置識別符號,但也是乙個非常有用的情報 如果你看到100個崩潰日誌的crash...

ios崩潰日誌收集 iOS崩潰日誌收集與解析

收集crash日誌方式 1.裝置上直接檢視 路徑 設定 隱私 分析 分析資料 2.xcode獲取裝置上資訊 路徑 xcode選單欄window devices and simulators 選中裝置 view device logs 3.xcode獲取發布版本崩潰資訊 路徑 xcode選單欄wind...

iOS程式崩潰日誌

void uncaughtexceptionhandler n ception exception 當然你還要在以下方法中新增呼叫 nssetuncaughtexceptionhandler uncaughtexceptionhandler 錯誤日誌收集 下面時陣列越界時返回的錯誤日誌 arr 0 ...