[Lldb-commits] [lldb] b951504 - [lldb] Allow aliases to aliases of raw input commands
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Fri Jan 21 17:57:41 PST 2022
Author: Dave Lee
Date: 2022-01-21T17:57:34-08:00
New Revision: b95150418fb6e2d22a0bd84abcdc1f3cc7e5a0bf
URL: https://github.com/llvm/llvm-project/commit/b95150418fb6e2d22a0bd84abcdc1f3cc7e5a0bf
DIFF: https://github.com/llvm/llvm-project/commit/b95150418fb6e2d22a0bd84abcdc1f3cc7e5a0bf.diff
LOG: [lldb] Allow aliases to aliases of raw input commands
Allow users to create aliases for aliases to raw input commands. That probably
sounds convoluted, so here's an example:
```
command alias some-setup env SOMEVAR=SOMEVALUE
```
This an alias based on `env`, which itself is an alias for `_regex-env`.
`_regex-env` is a `command regex` command, which takes raw input.
The above `some-setup` alias fails with:
```
error: Unable to create requested alias.
```
This change allows such aliases to be created. lldb already supports aliases to
aliases for parsed commands.
Differential Revision: https://reviews.llvm.org/D117259
Added:
Modified:
lldb/source/Commands/CommandObjectCommands.cpp
lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
Removed:
################################################################################
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 1ec54cf7ededa..defa21af7c170 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -485,8 +485,9 @@ rather than using a positional placeholder:"
OptionArgVectorSP option_arg_vector_sp =
OptionArgVectorSP(new OptionArgVector);
- if (CommandObjectSP cmd_obj_sp =
- m_interpreter.GetCommandSPExact(cmd_obj.GetCommandName())) {
+ const bool include_aliases = true;
+ if (CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact(
+ cmd_obj.GetCommandName(), include_aliases)) {
if (m_interpreter.AliasExists(alias_command) ||
m_interpreter.UserCommandExists(alias_command)) {
result.AppendWarningWithFormat(
diff --git a/lldb/test/API/commands/command/nested_alias/TestNestedAlias.py b/lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
index d4fc99492a698..bbe9c14f69f6d 100644
--- a/lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
+++ b/lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
@@ -46,6 +46,8 @@ def cleanup():
self.runCmd('command unalias rd', check=False)
self.runCmd('command unalias fo', check=False)
self.runCmd('command unalias foself', check=False)
+ self.runCmd('command unalias add_two', check=False)
+ self.runCmd('command unalias two', check=False)
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
@@ -96,3 +98,8 @@ def cleanup():
'Show variables for the current',
'stack frame.'],
matching=True)
+
+ # Check that aliases can be created for raw input commands.
+ self.expect('command alias two expr -- 2')
+ self.expect('command alias add_two two +')
+ self.expect('add_two 3', patterns=[' = 5$'])
More information about the lldb-commits
mailing list