2012-09-21 62 views
4

在GDB(通常在.gdbinit中),我用它來記錄我添加了自定義命令是這樣的:如何記錄自定義LLDB命令(別名)?

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添加一個命令(命令別名...),但我怎麼記錄它?

回答

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

不過沒有關係,在回答你的問題是,你不能今天文檔的命令別名。

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)