[lldb-dev] [Bug 50184] New: [Feature request] Tab completion on user defined alias

2021-04-30 Thread via lldb-dev
https://bugs.llvm.org/show_bug.cgi?id=50184

Bug ID: 50184
   Summary: [Feature request] Tab completion on user defined alias
   Product: lldb
   Version: 10.0
  Hardware: PC
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P
 Component: All Bugs
  Assignee: lldb-dev@lists.llvm.org
  Reporter: tom.pou...@gmail.com
CC: jdevliegh...@apple.com, llvm-b...@lists.llvm.org

Hi !

I was advised to file a bug report after I had posted my issue on StackOverflow
:

https://stackoverflow.com/questions/67231162/lldb-tab-completion-after-user-defined-aliases/67305975#67305975

I defined the following alias in lldb : 

command alias bfn breakpoint set -n %1

Sadly, this alias does not allow Tab completion as the regular command does.

All the time gained in typing the command is lost typing whole identifiers that
are sometimes quite complex.

Nevertheless, buit-in aliases allow for completion so I assume there's a way to
achieve the same behaviour for user defined aliases.

Thanks for your time and the work you put in making great software.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


[lldb-dev] small Editline wrapper cleanup req for feedback

2021-04-30 Thread Neal Sidhwaney via lldb-dev
Some comments in 
https://reviews.llvm.org/rGfd89af6880f33ead708abe2f7d88ecb687d4e0d2 
 prompted 
me to look more into potential simplifications of our EditLine wrapper and I 
wanted to run this by anyone who is interested before making the changes.

Right now we set a bunch of callbacks in libedit that are captureless lambdas 
implicitly converted to C function pointers.  The lambdas look up an instance 
of our Editline class and invoke member functions.  The boilerplate that could 
be generated by templates is something like the following:

class Foo { // Imagine this is our Editline class that wraps libedit
public:
  unsigned char Foo1(int ch) {  // These are member functions invoked by 
lambdas we pass to libedit
return 'a';
  }
  unsigned char Bar(int ch) {
return 'b';
  }
  unsigned char Baz(int ch) {
return 'c';
  }
};

typedef unsigned char (*elFnPtr)(EditLine*, int);  // Signature of callbacks 
libedit takes (note Edit__L__ine is libedit, and Edit__l__ine is our wrapper)
typedef unsigned char (Foo::*FooMemPtr)(int ch);   // Signature of member 
functions invoked

template
tuple createEditLineCommandDescriptor(const char* 
command, const char* helpText) {
  return make_tuple(command, helpText, [] (EditLine*, int ch) {
cout << ch;
Foo foo;
((&foo)->*callback)('a');
return (unsigned char) ch;
  });
}

auto editlineCommands = {
  createEditLineCommandDescriptor<&Foo::Foo1>(“Command1", “Command1 help"),
  createEditLineCommandDescriptor<&Foo::Bar>(“Command2", “Command2 help")
};

for (auto editlineCommand : editLineCommands) {
 // call into libedit to add editlineCommand, e.g.:
 el_set(EL_ADDFN, editlineCommand.get<0>(), editLineCommand.get<1>(), 
editLineCommand.get<2>());
}

The pointer to member function is a type parameter because otherwise the 
compiler complains about the lambda needing to capture it, in which case we 
could not pass it to libedit.

I also plan to look into the wchar_t/char preprocessor logic that the original 
comment brought up but then I got distracted by shiny template stuff ;-)

Thanks!

Neal___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev