[lldb-dev] Command Aliases

Enrico Granata egranata at apple.com
Tue Oct 22 18:13:29 PDT 2013


Hey Micheal,
while I don’t think we are going to accept in mainline a builtin “info” command like the one you suggested, this kind of idea seems to lead to a promising path for making tools out of which this kind of facility could then be manually crafted by users for all sorts of multiword commands.

It sounds like we need general facilities for multiword commands definition by users. Something like

(lldb) command multiword add info

And then you should be able to tell any command-defining command (e.g. command script add, command alias, command regex) that whatever command it is crafting, it is actually a subcommand, e.g.

(lldb) command alias —subcommand info — break breakpoint list

That would cause a hierarchy to be created where there is a multiword “info” command at the root, with a break subcommand, whose implementation is breakpoint list

| -info
| —— break ==> breakpoint list

With that, you could easily define your info command hierarchy in your .lldbinit and anyone who wants to define their own multiword commands hierarchies would naturally be allowed to do so.

Needless to say, one should protect system commands, such that you could not say

(lldb) command alias —subcommand process doevilthings “some other command here"

or

(lldb) command multiword add process

or worse

(lldb) command multiword delete process

Right now our story here is fairly lacking (you can define python commands that then can “fake” multiwordedness), so if you want to work on this kind of proper multiword support, that would be great!

Enrico Granata
📩 egranata@.com
☎️ 27683

On Oct 22, 2013, at 5:53 PM, Michael Sartain <mikesart at gmail.com> wrote:

> I'd really like to add aliases for the following commands from gdb:
> 
> info b[reak]                  ; breakpoint list 
> info ar[gs]                   ; frame variable
> info lo[cals]                 ; frame variable --no-args
> info r[egisters]              ; info registers
> info al[l-registers]          ; info all-registers $rax $rcx 
> info all-registers rax rsp    ; register read rax rsp
> info sh[ared]                 ; image list 
> info sy[mbol] 0x1234          ; image lookup --address 0x1234
> 
> These all have spaces in them, which I believe means they won't work with the existing alias system. Would it make the most sense to add a new "CommandObjectMultiwordInfo" object in the Command Interpreter and break all the info stuff out there, or is it feasible to add the ability to recognize multiword aliases so something like this would work:
> 
>     command alias "info break" breakpoint list
> 
> Also, it appears that command regex commands don't show up in help -a. See example down below. Is this expected behavior?
> Thanks!
>  -Mike
> 
> (lldb) help command regex
> ...
> EXAMPLES
>     (lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/'
> (lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/'
> (lldb) help -a
> ...
> expression        -- Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope.
> f                 -- 
> frame             -- A set of commands for operating on the current thread's frames.
> ...
> (lldb) help f
>      This command takes 'raw' input (no need to quote stuff).
> 
> Syntax: f
> 
> 'f' is an abbreviation for 'f'
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20131022/9ae61893/attachment.html>


More information about the lldb-dev mailing list