我不能得到这个简单的LLDB别名工作 [英] I can't get this simple LLDB alias to work

查看:134
本文介绍了我不能得到这个简单的LLDB别名工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个LLDB别名ps,这样

I want to create an LLDB alias ps, such that

 ps foo

成为

 print [self foo]

我一直在观看LLDB聊天(iTunes上的WWDC会话321),根据这一点看起来像这样的别名应该是这样的:

I've been watching the LLDB talk (WWDC session 321 on iTunes), and based on that, it looks like the alias to do that should be this one:

command alias ps print [ self %1 ]

但它不工作。在这里,我给了我的应用程序委托一个简单的count方法返回一个整数:

but it doesn't work. Here I've given my app delegate a simple "count" method that returns an integer:

(lldb) command alias ps print [ self %1 ]
(lldb) ps count
error: invalid operands to binary expression ('AppDelegate *' and 'int')
error: 1 errors parsing expression
(lldb) print [ self count ]
(int) $6 = 2
(lldb) 

我缺少什么?

推荐答案

似乎参数(%1,%2等)不起作用别名表达使用正则表达式有一个解决方法:

It seems arguments (%1, %2, etc) doesn't work to alias an expression. There is a workaround by using a regular expression instead:

command regex ps 's/(.+)/print [self %1]/'

它为上述正则表达式创建一个别名ps:

It makes an alias ps for the above regular expression:

(lldb) ps firstName
print [self firstName]
(NSString *) $1 = 0x06e64e20 @"John"

但是,这将持续到调试会话结束。您将不得不再次输入下一个调试会话。如果您希望您的ps命令通过调试会话持久化,则必须将其保存在〜/ .lldbinit文件中(如果不存在,请创建一个)。

However this will last till the debug session ends. You'll have to enter it again for the next debug session. If you want your ps command to persist through debug sessions, you'll have to save it in your ~/.lldbinit file (if it doesn't exist, create one).

请参阅 llvm博客有关正则表达式命令的更多细节。

See llvm blog for more deails about regex command.

这篇关于我不能得到这个简单的LLDB别名工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆