在GDB中(通常在.gdbinit文件中)我用来记录我添加的自定义命令,如下所示:
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中添加命令(命令别名...),但如何记录呢?
答案 0 :(得分:3)
没有任何记录命令别名的余地 - 它们通常非常简单,对它们运行'help'将显示它们扩展到的内容 - 但是如果你在python中定义一个命令,你可以添加文档到那个命令。例如,
(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
但不,你的问题的答案是你今天不能记录命令别名。
答案 1 :(得分:0)
您可以使用文档字符串记录自定义lldb命令,如Python Reference中所述:
或者,您也可以提供Python文档字符串,LLDB将使用 它在为您的命令提供帮助时,如:
(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)