iOS - GDB & Breakpoint 調試:

EXC_BAD_ACCES  
malloc: *** mmap(size=4294955008) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

編譯報錯


方法一:

0.Xcode菜單 Product  =>  Scheme  =>  Edit Scheme =》Arguments => Environment Variables 中加

Name                                  Value
NSZombieEnabled                        YES
MallocStackLoggingNoCompact            YES
MallocStackLogging                     YES

1.Xcode菜單 Product  =>  Scheme  =>  Edit Scheme =》 Info => Debugger   裏面選擇 LLDB

2.在控制檯:

模擬器 po [$eax name]     //name 爲要打印的參數 還有class等參數
真機 po [$r0 name] 




方法二、malloc_error_break 加 Breakpoint 斷點

在斷點查看處(Breakpoint)左下角"+"號裏選  "Add Symbolic Breakpoint" 然後在彈出的框中輸入錯誤的類型如 "malloc_error_break" 點Done確定。
在已加的斷點上右鍵 Move Breakpoint To 裏面選擇 User 。

Xcode菜單 Product  =>  Scheme  =>  Edit Scheme =》 Info => Debugger   裏面選擇 GDB

到此斷點設置完成,當某個地方因爲內存原因斷點便會停在那個地方。


發佈了80 篇原創文章 · 獲贊 13 · 訪問量 18萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章