首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何记录自定义LLDB命令(别名)?

如何记录自定义LLDB命令(别名)?
EN

Stack Overflow用户
提问于 2012-09-21 20:21:50
回答 2查看 947关注 0票数 4

在GDB中(通常在.gdbinit文件中),我用来记录我添加的自定义命令,如下所示:

代码语言:javascript
复制
define parg    <-- this define my custom command
p *($arg0*)($ebp+8+(4*$arg1))     <--- what in does
end

document parg   <--- HERE IS THE COMMENT / DOCUMENTATION ON THIS CUSTOM COMMAND
Prints current function arguments

parg <type> <index>
Prints the <index>th argument of the current function as type <type>
<index> is 0-based
end 

我知道如何在LLDB中添加命令(命令别名...),但是我如何记录它?

EN

回答 2

Stack Overflow用户

发布于 2012-09-25 05:52:57

不允许记录命令别名--它们通常非常简单,对它们运行'help‘会显示它们展开到什么位置--但是如果你用python定义一个命令,你可以在该命令中添加文档。例如,

代码语言:javascript
复制
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> def say_hello(debugger, command, result, dict):
...   print 'hello!'
...   description = '''This command says hello.'''
...   usage = 'usage: say_hello'
... 
>>> ^D
(lldb) command script add -f say_hello say_hello
(lldb) say_hello
hello!
(lldb) help say_hello
   Run Python function say_hello  This command takes 'raw' input (no need to quote stuff).

Syntax: say_hello
(lldb) 

注意第四个"...“我在空行上按回车键的位置。

有关lldb中python脚本的更多信息,请参阅http://lldb.llvm.org/python-reference.html

但是不,你的问题的答案是,你现在不能记录命令别名。

票数 3
EN

Stack Overflow用户

发布于 2015-09-29 23:07:48

您可以使用Python Reference中记录的文档字符串来记录自定义lldb命令

也可以提供

文档字符串,LLDB将在为命令提供帮助时使用它,如下所示:

代码语言:javascript
复制
(lldb) script
>>> def documented(*args):
...     '''
...     This command is documented using a docstring.
...
...     You can write anything!
...     '''
...     pass
...
>>> exit
(lldb) command script add -f documented documented
(lldb) help documented

    This command is documented using a docstring.

    You can write anything!

Syntax: documented
(lldb)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12530535

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档