[Lldb-commits] [lldb] b1465cd - [lldb] Create a way to force remove commands
walter erquinigo via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 26 17:31:27 PDT 2023
Author: walter erquinigo
Date: 2023-04-26T19:31:19-05:00
New Revision: b1465cd49efcbc114a75220b153f5a055ce7911f
URL: https://github.com/llvm/llvm-project/commit/b1465cd49efcbc114a75220b153f5a055ce7911f
DIFF: https://github.com/llvm/llvm-project/commit/b1465cd49efcbc114a75220b153f5a055ce7911f.diff
LOG: [lldb] Create a way to force remove commands
Some LLDB set ups need to hide certain commands for security reasons, so I'm adding a flag that allows removing non-user commands.
Differential Revision: https://reviews.llvm.org/D149312
Added:
Modified:
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/source/Interpreter/CommandInterpreter.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index e428614fbedb1..f6a9a4d90bc1d 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -324,8 +324,9 @@ class CommandInterpreter : public Broadcaster,
lldb::CommandObjectSP &command_obj_sp,
llvm::StringRef args_string = llvm::StringRef());
- // Remove a command if it is removable (python or regex command)
- bool RemoveCommand(llvm::StringRef cmd);
+ /// Remove a command if it is removable (python or regex command). If \b force
+ /// is provided, the command is removed regardless of its removable status.
+ bool RemoveCommand(llvm::StringRef cmd, bool force = false);
bool RemoveAlias(llvm::StringRef alias_name);
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 09fc8e216bc00..cee17df7a4b9d 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1374,11 +1374,12 @@ bool CommandInterpreter::RemoveAlias(llvm::StringRef alias_name) {
return false;
}
-bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
+bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd, bool force) {
auto pos = m_command_dict.find(std::string(cmd));
if (pos != m_command_dict.end()) {
- if (pos->second->IsRemovable()) {
- // Only regular expression objects or python commands are removable
+ if (force || pos->second->IsRemovable()) {
+ // Only regular expression objects or python commands are removable under
+ // normal circumstances.
m_command_dict.erase(pos);
return true;
}
More information about the lldb-commits
mailing list