iOS開發之不得不會的gdb命令

來源:互聯網
上載者:User

更新說明:後面發現這篇文章介紹的比較全面
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]


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.