kastiglione created this revision. kastiglione added reviewers: aprantl, JDevlieghere, jingham, labath, werat. Herald added a subscriber: jeroen.dobbelaere. Herald added a project: All. kastiglione requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
Redefine the `p` alias to the `dwim-print` command instead of `expression`. See https://reviews.llvm.org/D138315 for the introduction of `dwim-print`. To summarize, `dwim-print` is, as the name suggests, a command for printing. How a value gets printed, is decided by `dwim-print`. In some cases, `dwim-print` will print values using the same means as `frame variable` (because it's generally more reliable and faster that `expression` evaluation), and in other cases `dwim-print` uses the same code path as `expression`. This change has been tested in two different ways: 1. Re-aliasing `p` to `dwim-print`, as in this patch 2. Redefinining the `expression` command to `CommandObjectDWIMPrint` Previously, many of the lldb's tests used `p`, and which meant a test run with `p` aliases to `dwim-print` was a good way to test `dwim-print`. However most of those tests were updated to use `expression` explicitly (in anticipation of this change). Now, the best way to test `dwim-print` is the second approach: diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 373c894f34f5..9c943cd30c7c 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -539,7 +539,7 @@ void CommandInterpreter::LoadCommandDictionary() { REGISTER_COMMAND_OBJECT("diagnostics", CommandObjectDiagnostics); REGISTER_COMMAND_OBJECT("disassemble", CommandObjectDisassemble); REGISTER_COMMAND_OBJECT("dwim-print", CommandObjectDWIMPrint); - REGISTER_COMMAND_OBJECT("expression", CommandObjectExpression); + REGISTER_COMMAND_OBJECT("expression", CommandObjectDWIMPrint); REGISTER_COMMAND_OBJECT("frame", CommandObjectMultiwordFrame); REGISTER_COMMAND_OBJECT("gui", CommandObjectGUI); REGISTER_COMMAND_OBJECT("help", CommandObjectHelp); When the test suite is run with this change, there are two main categories of test failures for specific to features that `dwim-print` intentionally doesn't support: 1. Top level expressions (`--top-level`/`-p`) 2. Multiline expressions In cases where the behavior of `expression` is needed, users can use `expression` at those times. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D145189 Files: lldb/source/Interpreter/CommandInterpreter.cpp Index: lldb/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/source/Interpreter/CommandInterpreter.cpp +++ lldb/source/Interpreter/CommandInterpreter.cpp @@ -413,17 +413,21 @@ alias_arguments_vector_sp = std::make_shared<OptionArgVector>(); - cmd_obj_sp = GetCommandSPExact("expression"); + cmd_obj_sp = GetCommandSPExact("dwim-print"); if (cmd_obj_sp) { AddAlias("p", cmd_obj_sp, "--")->SetHelpLong(""); AddAlias("print", cmd_obj_sp, "--")->SetHelpLong(""); - AddAlias("call", cmd_obj_sp, "--")->SetHelpLong(""); if (auto *po = AddAlias("po", cmd_obj_sp, "-O --")) { po->SetHelp("Evaluate an expression on the current thread. Displays any " "returned value with formatting " "controlled by the type's author."); po->SetHelpLong(""); } + } + + cmd_obj_sp = GetCommandSPExact("expression"); + if (cmd_obj_sp) { + AddAlias("call", cmd_obj_sp, "--")->SetHelpLong(""); CommandAlias *parray_alias = AddAlias("parray", cmd_obj_sp, "--element-count %1 --"); if (parray_alias) {
Index: lldb/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/source/Interpreter/CommandInterpreter.cpp +++ lldb/source/Interpreter/CommandInterpreter.cpp @@ -413,17 +413,21 @@ alias_arguments_vector_sp = std::make_shared<OptionArgVector>(); - cmd_obj_sp = GetCommandSPExact("expression"); + cmd_obj_sp = GetCommandSPExact("dwim-print"); if (cmd_obj_sp) { AddAlias("p", cmd_obj_sp, "--")->SetHelpLong(""); AddAlias("print", cmd_obj_sp, "--")->SetHelpLong(""); - AddAlias("call", cmd_obj_sp, "--")->SetHelpLong(""); if (auto *po = AddAlias("po", cmd_obj_sp, "-O --")) { po->SetHelp("Evaluate an expression on the current thread. Displays any " "returned value with formatting " "controlled by the type's author."); po->SetHelpLong(""); } + } + + cmd_obj_sp = GetCommandSPExact("expression"); + if (cmd_obj_sp) { + AddAlias("call", cmd_obj_sp, "--")->SetHelpLong(""); CommandAlias *parray_alias = AddAlias("parray", cmd_obj_sp, "--element-count %1 --"); if (parray_alias) {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits