[lldb-dev] Custom arguments completion for commands created by LLDB plugins

Raphael “Teemperor” Isemann via lldb-dev lldb-dev at lists.llvm.org
Mon Oct 7 03:35:28 PDT 2019


To my knowledge there is no way to have completions for custom commands. If you just want completions for nested commands (e.g., having a “custom add” and “custom remove” commands and want completions for completing “add” and “remove”), then this should work if you build the nested command using the SBCommand::Add[Multiword]Command functions. However, that won’t allow you to provide arbitrary completions for arguments.

Regarding your planned change: Adding a new virtual method would break the ABI of SBCommandPluginInterface and the SBAPI is supposed to have a stable ABI. So I guess we have two options.
1. break the ABI for this class and somehow let people know they need to recompile their plugins for the next release.
2. add a new overload to the existing AddCommand methods and allow passing some kind of interface for completions. Custom command classes just inherit from both interfaces if they want to provide their own completions.

I’m fine with either option, but if we end up going for option 1, then IMHO we might as well change the API of this class as it’s current DoExecute function is just wrong. It returns an undocumented ‘bool’ value which seems to provide redundant information to the success status of the result parameter and we pass it a `char **` parameter which actually has `const char **` semantics as changing it corrupts LLDB’s internal `Args` data structure.

In any case I would prefer if we wait with landing this API until I fully cleaned up LLDB's completion logic and we got around to set in stone the new HandleCompletion API (which gives us an overview of what kind of completions clients want to receive and in what format). Both should happen for LLDB 10 if everything goes right, so this shouldn’t delay adding this feature.

- Raphael

(Resending this as my other email got blocked by lldb-dev somehow)

> On 6. Oct 2019, at 02:55, Matheus Marchini via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Is there a way to create custom argument completion handlers for
> commands introduced by LLDB plugins? I want to add completion for some
> commands on llnode (https://github.com/nodejs/llnode), but I couldn't
> find a way to do so using the C++ public API.
> 
> Based on this comment
> (https://github.com/llvm/llvm-project/blob/d420616313a3b4bc95a9effa00363cf3ad953e61/lldb/include/lldb/Interpreter/CommandCompletions.h#L44-L47)
> I was expecting some API to add custom completion handlers, but I
> guess the comment is intended for internal development only?
> 
> If there isn't a way to do that today, I'm thinking about adding it as
> a new method to SBCommandPluginInterface, unless someone objects to
> it.
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev




More information about the lldb-dev mailing list