aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectCommands.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2022-03-31 14:11:39 -0700
committerJim Ingham <jingham@apple.com>2022-03-31 14:15:14 -0700
commit1f7b58f2a50461493f083b2ed807b25e036286f6 (patch)
tree7c9ccdb080c62c88870ba0f0c652c5a5510ebe30 /lldb/source/Commands/CommandObjectCommands.cpp
parentfe528e72163371e10242f4748dab687eef30a1f9 (diff)
downloadllvm-1f7b58f2a50461493f083b2ed807b25e036286f6.zip
llvm-1f7b58f2a50461493f083b2ed807b25e036286f6.tar.gz
llvm-1f7b58f2a50461493f083b2ed807b25e036286f6.tar.bz2
Add a setting to not require --overwrite to overwrite commands.
Protecting against accidental overwriting of commands is good, but having to pass a flag to overwrite the command when developing your commands is pretty annoying. This adds a setting to defeat the protection so you can do this once at the start of your session and not have to worry about it again. Differential Revision: https://reviews.llvm.org/D122680
Diffstat (limited to 'lldb/source/Commands/CommandObjectCommands.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 51385e0..1d4687b 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1445,7 +1445,7 @@ protected:
m_short_help = std::string(option_arg);
break;
case 'o':
- m_overwrite = true;
+ m_overwrite_lazy = eLazyBoolYes;
break;
case 's':
m_synchronicity =
@@ -1467,7 +1467,7 @@ protected:
m_class_name.clear();
m_funct_name.clear();
m_short_help.clear();
- m_overwrite = false;
+ m_overwrite_lazy = eLazyBoolCalculate;
m_synchronicity = eScriptedCommandSynchronicitySynchronous;
}
@@ -1480,7 +1480,7 @@ protected:
std::string m_class_name;
std::string m_funct_name;
std::string m_short_help;
- bool m_overwrite = false;
+ LazyBool m_overwrite_lazy;
ScriptedCommandSynchronicity m_synchronicity =
eScriptedCommandSynchronicitySynchronous;
};
@@ -1499,7 +1499,6 @@ protected:
ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
-
StringList lines;
lines.SplitIntoLines(data);
if (lines.GetSize() > 0) {
@@ -1562,8 +1561,19 @@ protected:
result.AppendError("'command script add' requires at least one argument");
return false;
}
- // Store the options in case we get multi-line input
- m_overwrite = m_options.m_overwrite;
+ // Store the options in case we get multi-line input, also figure out the
+ // default if not user supplied:
+ switch (m_options.m_overwrite_lazy) {
+ case eLazyBoolCalculate:
+ m_overwrite = !GetDebugger().GetCommandInterpreter().GetRequireCommandOverwrite();
+ break;
+ case eLazyBoolYes:
+ m_overwrite = true;
+ break;
+ case eLazyBoolNo:
+ m_overwrite = false;
+ }
+
Status path_error;
m_container = GetCommandInterpreter().VerifyUserMultiwordCmdPath(
command, true, path_error);
@@ -1637,7 +1647,7 @@ protected:
std::string m_cmd_name;
CommandObjectMultiword *m_container = nullptr;
std::string m_short_help;
- bool m_overwrite = false;
+ bool m_overwrite = eLazyBoolCalculate;
ScriptedCommandSynchronicity m_synchronicity =
eScriptedCommandSynchronicitySynchronous;
};