From a8a8bf2b1a970be1d1f0f4e010181ebe97116998 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 7 Nov 2024 10:35:05 -0800 Subject: [PATCH] [lldb] Add builtin e alias for expression The changes in 461f859a72 (llvm/llvm-project#65974) resulted in a change in behavior not just for completion, but also for selection of inexect commands. Since many use `e` to mean `expression`, this change adds an alias for `e`. Note that the referenced change similarly aliases `h` to `help`. --- lldb/source/Interpreter/CommandInterpreter.cpp | 2 ++ .../API/functionalities/abbreviation/TestAbbreviations.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index c990972ca64bc..227ed802aa933 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -441,6 +441,8 @@ void CommandInterpreter::Initialize() { cmd_obj_sp = GetCommandSPExact("expression"); if (cmd_obj_sp) { + // Ensure `e` runs `expression`. + AddAlias("e", cmd_obj_sp); AddAlias("call", cmd_obj_sp, "--")->SetHelpLong(""); CommandAlias *parray_alias = AddAlias("parray", cmd_obj_sp, "--element-count %1 --"); diff --git a/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py b/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py index 02ee581da516d..a8cbffbb7ba4a 100644 --- a/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py +++ b/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py @@ -20,6 +20,10 @@ def test_command_abbreviations_and_aliases(self): self.assertTrue(result.Succeeded()) self.assertEqual("apropos script", result.GetOutput()) + command_interpreter.ResolveCommand("e", result) + self.assertTrue(result.Succeeded()) + self.assertEqual("expression", result.GetOutput()) + command_interpreter.ResolveCommand("h", result) self.assertTrue(result.Succeeded()) self.assertEqual("help", result.GetOutput())