4

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 にコマンドを追加する方法 (コマンド エイリアス ...) は知っていますが、それを文書化するにはどうすればよいですか?

4

2 に答える 2

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) 

空の行でリターンを押した 4 行目の "..." 行に注意してください。

lldb での Python スクリプトの詳細については、http://lldb.llvm.org/python-reference.html を参照してください。

しかし、いいえ、あなたの質問に対する答えは、現在、コマンド エイリアスを文書化することはできないということです。

于 2012-09-24T21:52:56.903 に答える
0

Python リファレンスに記載されているように、docstring を使用してカスタム lldb コマンドを文書化できます。

オプションで、Python docstring を指定することもできます。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)
于 2015-09-29T15:07:48.000 に答える