iOS开发之不得不会的gdb命令

更新说明:后面发现这篇文章介绍的比较全面 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]



  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值