Skip to content

Commit b1465cd

Browse files
author
walter erquinigo
committed
[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
1 parent d7fa921 commit b1465cd

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lldb/include/lldb/Interpreter/CommandInterpreter.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,9 @@ class CommandInterpreter : public Broadcaster,
324324
lldb::CommandObjectSP &command_obj_sp,
325325
llvm::StringRef args_string = llvm::StringRef());
326326

327-
// Remove a command if it is removable (python or regex command)
328-
bool RemoveCommand(llvm::StringRef cmd);
327+
/// Remove a command if it is removable (python or regex command). If \b force
328+
/// is provided, the command is removed regardless of its removable status.
329+
bool RemoveCommand(llvm::StringRef cmd, bool force = false);
329330

330331
bool RemoveAlias(llvm::StringRef alias_name);
331332

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,11 +1374,12 @@ bool CommandInterpreter::RemoveAlias(llvm::StringRef alias_name) {
13741374
return false;
13751375
}
13761376

1377-
bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
1377+
bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd, bool force) {
13781378
auto pos = m_command_dict.find(std::string(cmd));
13791379
if (pos != m_command_dict.end()) {
1380-
if (pos->second->IsRemovable()) {
1381-
// Only regular expression objects or python commands are removable
1380+
if (force || pos->second->IsRemovable()) {
1381+
// Only regular expression objects or python commands are removable under
1382+
// normal circumstances.
13821383
m_command_dict.erase(pos);
13831384
return true;
13841385
}

0 commit comments

Comments
 (0)