How to document an LLDB user command (alias)?

In GDB (usually in a .gdbinit file), I use to document my added custom commands as follows:

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 

I know how to add a command to LLDB (command alias ...), but how to document it?

+4
source share
2 answers

There are no restrictions for documenting command aliases - they are usually quite simple, and "help" works on them, showing what they expand to, but if you define a command in python, you can add documentation to this command. For instance,

 (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) 

Pay attention to the fourth line "...", in which I pressed the return button on an empty line.

For more information about python scripts in lldb see http://lldb.llvm.org/python-reference.html

But no, the answer to your question is that today you cannot document the command alias.

+3
source

You can document custom lldb commands with docstrings, as described in the Python Reference :

Alternatively, you can also provide a Python toolkit, and LLDB will use this to provide help for your team, as in:

 (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
source

Source: https://habr.com/ru/post/1435496/


All Articles