-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Add 'inspect' alias for dwim-print #155039
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
Conversation
|
@llvm/pr-subscribers-lldb Author: Michael Christensen (mdko) ChangesPeople on my team coming from GDB continually try to use "inspect" to examine data, but this command doesn't exist. In GDB, "inspect" is a synonym for "print" (https://sourceware.org/gdb/current/onlinedocs/gdb.html/Data.html#Data), so I thought it was help with ergonomics if we additionally had an "inspect" alias in LLDB (mapping to "dwim-print", which is what LLDB's "print" alias maps to as well). Full diff: https://github.com/llvm/llvm-project/pull/155039.diff 2 Files Affected:
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 650b754fd8ace..7ebcba6ffc8c9 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -432,6 +432,7 @@ void CommandInterpreter::Initialize() {
if (cmd_obj_sp) {
AddAlias("p", cmd_obj_sp, "--")->SetHelpLong("");
AddAlias("print", cmd_obj_sp, "--")->SetHelpLong("");
+ AddAlias("inspect", 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 "
diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
index 492d49f008a9e..d1ebdc1eb1564 100644
--- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -185,3 +185,16 @@ def test_direct_child_access(self):
self, "break inside", lldb.SBFileSpec("main.cpp")
)
self._expect_cmd("dwim-print number", "frame variable")
+
+ def test_aliases(self):
+ interp = self.dbg.GetCommandInterpreter()
+ for alias in ["p", "print", "inspect"]:
+ result = lldb.SBCommandReturnObject()
+ interp.ResolveCommand(alias, result)
+ self.assertTrue(result.Succeeded(), result.GetError())
+ self.assertEqual(result.GetOutput(), "dwim-print --")
+
+ result = lldb.SBCommandReturnObject()
+ interp.ResolveCommand("po", result)
+ self.assertTrue(result.Succeeded(), result.GetError())
+ self.assertEqual(result.GetOutput(), "dwim-print -O --")
|
|
This seems a slippery slope. gdb generally has 3 or 4 different ways of spelling every command; I really don't want to add them all to lldb and make it harder to spell the native lldb commands. The lldb command set isn't that hard to learn... I'm not super excited about adding this, but in any case I'd really rather not have this or any future additions of this sort be on by default. If we feel we really need to do this, then we should add an |
jimingham
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add this for all lldb users.
|
@jimingham Fair point, thanks for the quick feedback. I will abandon these changes and stick with making this a local alias. |
Summary:
Add the commands* I added to the gdb-translator (D81056005) as actual aliases:
```
show {env,args}
unset
return
inspect
where
backtrace
info {break, threads, registers, all-registers, proc mappings, shared}
dump memory
```
If these are fine/useful, we can add them to the wider Meta-set of aliases later on. Note that I did try to add "inspect" to upstream, but was rejected (llvm/llvm-project#155039). So adding these as HHVM-usable, then possibly company-wide aliases, for now.
*I can't add things like "thread N", "frame N", or "set ..." since their prefixes are already commands in LLDB, and it would be pretty invasive to make a larger wrapper command right now. Note that LLDB already ships with "t N" and "f N" aliasing to "thread select N" and "frame select N".
Reviewed By: nt591
Differential Revision: D81153595
fbshipit-source-id: 0f9f3b58fd680715236297be60223244d62f7291
People on my team coming from GDB continually try to use "inspect" to examine data, but this command doesn't exist. In GDB, "inspect" is a synonym for "print" (https://sourceware.org/gdb/current/onlinedocs/gdb.html/Data.html#Data), so I thought it was help with ergonomics if we additionally had an "inspect" alias in LLDB (mapping to "dwim-print", which is what LLDB's "print" alias maps to as well).