更新說明:後面發現這篇文章介紹的比較全面
http://blog.csdn.net/ch_soft/article/details/6740000
文章轉載於:http://www.ethangao.com/?p=273,謝謝作者分享。
gdb不是萬能的,可是沒有gdb卻是萬萬不能的。這裡給大家簡單介紹下iOS開發中最基本的gdb命令。
po
po是print-object的簡寫,可用來列印所有NSObject對象。使用舉例如下:
(gdb) po
self
<LauncherViewController: 0x552c570>
(gdb) po
[self view]
<UIView: 0x544eb80; frame = (0 0; 320 411); autoresize = W+H; layer = <CALayer: 0x544ebb0>>
(gdb) print-object
[self view]
<UIView: 0x544eb80; frame = (0 0; 320 411); autoresize = W+H; layer = <CALayer: 0x544ebb0>>
p
p是print的簡寫,可以用來列印所有的簡單類型,如int, float,結構體等。使用舉例如下:
(gdb) p
self
$1 = (LauncherViewController *) 0x552c570
(gdb) p
[[self view] size]
Unable to call function “objc_msgSend” at 0x1e7e08c: no return type information available.
To call this function anyway, you can cast the return type explicitly (e.g. ‘print (float) fabs (3.0)’)
(gdb) p
(CGSize)[[self view] size]
$1 = {
width = 320,
height = 411
}
(gdb) print
(CGSize)[[self view] size]
$2 = {
width = 320,
height = 411
}
call
call即是調用的意思。其實上述的po和p也有調用的功能。因此一般只在不需要顯示輸出,或是方法無傳回值時使用call。使用舉例如下:
(gdb) call
[[self view]sizeToFit]
Unable to call function “objc_msgSend” at 0x1e7e08c: no return type information available.
To call this function anyway, you can cast the return type explicitly (e.g. ‘print (float) fabs (3.0)’)
(gdb) call
(void)[[self view]sizeToFit]
(gdb) call
[[self view] size]
Unable to call function “objc_msgSend” at 0x1e7e08c: no return type information available.
To call this function anyway, you can cast the return type explicitly (e.g. ‘print (float) fabs (3.0)’)
(gdb) call
(void)[[self view] size]