Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb][lldb-dap] explicitly set the expr as an alias for expression. #134562

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

da-viper
Copy link
Contributor

@da-viper da-viper commented Apr 6, 2025

dap console does not recognise expr as a command because it is not explicitly set.

It works fine in normal lldb because it is gotten from approximate match which is not available in the SBAPI

dap console does not recognise `expr` as a command because it is not explicitly set.

It works fine in normal lldb because it is gotten from approximate match which is not available in the SBAPI
@da-viper da-viper requested a review from JDevlieghere as a code owner April 6, 2025 21:41
@llvmbot llvmbot added the lldb label Apr 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 6, 2025

@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)

Changes

dap console does not recognise expr as a command because it is not explicitly set.

It works fine in normal lldb because it is gotten from approximate match which is not available in the SBAPI


Full diff: https://github.com/llvm/llvm-project/pull/134562.diff

1 Files Affected:

  • (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+4-1)
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 112d2f20fda41..a4071f5f0a602 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -444,6 +444,7 @@ void CommandInterpreter::Initialize() {
   if (cmd_obj_sp) {
     // Ensure `e` runs `expression`.
     AddAlias("e", cmd_obj_sp);
+    AddAlias("expr", cmd_obj_sp);
     AddAlias("call", cmd_obj_sp, "--")->SetHelpLong("");
     CommandAlias *parray_alias =
         AddAlias("parray", cmd_obj_sp, "--element-count %1 --");
@@ -1376,7 +1377,9 @@ bool CommandInterpreter::GetAliasFullName(llvm::StringRef cmd,
 }
 
 bool CommandInterpreter::AliasExists(llvm::StringRef cmd) const {
-  return m_alias_dict.find(cmd) != m_alias_dict.end();
+  std::string alias_name;
+  return GetAliasFullName(cmd, alias_name);
+  // return m_alias_dict.find(cmd) != m_alias_dict.end();
 }
 
 bool CommandInterpreter::UserCommandExists(llvm::StringRef cmd) const {

dap console does not recognise `expr` as a command because it is not explicitly set.

It works fine in normal lldb because it is gotten from approximate match which is not available in the SBAPI
@jimingham
Copy link
Collaborator

The lldb command line was designed so that it always does shortest complete match, and there are a lot of common commands that people only type partially. Adding one more expr alias isn't such a big deal, but adding special purpose aliases for all the shortenings people want to use is not supportable (and might collide with other aliases users have set).
So we need a better solution to this DAP problem than just adding aliases.

@da-viper
Copy link
Contributor Author

da-viper commented Apr 7, 2025

Another solution I could think of is prioritising, the repl command type instead of the repl variable type.
in

// Variables take preference to commands in auto, since commands can always
// be called using the command_escape_prefix
return term_is_variable ? ReplMode::Variable
: term_is_command ? ReplMode::Command
: ReplMode::Variable;
}

or add the previously defined aliases in docs explicitly as aliases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants