tatyana-krasnukha updated this revision to Diff 248404.
tatyana-krasnukha added a comment.
Removed TestFixIts.py as those changes relate to the parent revision.
Repository:
rLLDB LLDB
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75537/new/
https://reviews.llvm.org/D75537
Files:
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/Commands/CommandObjectSettings.cpp
lldb/source/Commands/Options.td
lldb/test/API/commands/settings/TestSettings.py
Index: lldb/test/API/commands/settings/TestSettings.py
===================================================================
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -522,6 +522,36 @@
self.expect("settings remove ''", error=True,
substrs=["'settings remove' command requires a valid variable name"])
+ def test_settings_clear_all(self):
+ # Save the initial state of settings.
+ command_interpreter = self.dbg.GetCommandInterpreter()
+ self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
+ result = lldb.SBCommandReturnObject()
+ command_interpreter.HandleCommand("settings show", result)
+ default_values = result.GetOutput()
+
+ # Change a dictionary.
+ self.runCmd("settings set target.env-vars a=1 b=2 c=3")
+ # Change an array.
+ self.runCmd("settings set target.run-args a b c")
+ # Change a single boolean value.
+ self.runCmd("settings set auto-confirm true")
+ # Change a single integer value.
+ self.runCmd("settings set term-width 120")
+
+ # Clear everything.
+ self.runCmd("settings clear --all")
+
+ # Apply Setup commands again.
+ for s in self.setUpCommands():
+ self.runCmd(s)
+
+ # Check that settings have their default values after clearing.
+ command_interpreter.HandleCommand("settings show", result)
+ after_clear = result.GetOutput()
+ self.maxDiff = None # Disable diff limit to compare setting dumps.
+ self.assertEqual(default_values, after_clear)
+
def test_all_settings_exist(self):
self.expect("settings show",
substrs=["auto-confirm",
Index: lldb/source/Commands/Options.td
===================================================================
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -39,6 +39,11 @@
Desc<"The file from which to read the settings.">;
}
+let Command = "settings clear" in {
+ def setclear_all : Option<"all", "a">,
+ Desc<"Clear all settings.">;
+}
+
let Command = "breakpoint list" in {
// FIXME: We need to add an "internal" command, and then add this sort of
// thing to it. But I need to see it for now, and don't want to wait.
Index: lldb/source/Commands/CommandObjectSettings.cpp
===================================================================
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Commands/CommandObjectSettings.cpp
@@ -1043,13 +1043,16 @@
};
// CommandObjectSettingsClear
+#define LLDB_OPTIONS_settings_clear
+#include "CommandOptions.inc"
class CommandObjectSettingsClear : public CommandObjectParsed {
public:
CommandObjectSettingsClear(CommandInterpreter &interpreter)
: CommandObjectParsed(
interpreter, "settings clear",
- "Clear a debugger setting array, dictionary, or string.", nullptr) {
+ "Clear a debugger setting array, dictionary, or string. "
+ "If '-a' option is specified, it clears all settings.", nullptr) {
CommandArgumentEntry arg;
CommandArgumentData var_name_arg;
@@ -1077,9 +1080,47 @@
request, nullptr);
}
+ Options *GetOptions() override { return &m_options; }
+
+ class CommandOptions : public Options {
+ public:
+ CommandOptions() = default;
+
+ ~CommandOptions() override = default;
+
+ Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) override {
+ const int short_option = m_getopt_table[option_idx].val;
+ switch (short_option) {
+ case 'a':
+ m_clear_all = true;
+ break;
+ default:
+ llvm_unreachable("Unimplemented option");
+ }
+ return Status();
+ }
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override {
+ m_clear_all = false;
+ }
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::makeArrayRef(g_settings_clear_options);
+ }
+
+ bool m_clear_all = false;
+ };
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
+
+ if (m_options.m_clear_all) {
+ GetDebugger().GetValueProperties()->Clear();
+ return result.Succeeded();
+ }
+
const size_t argc = command.GetArgumentCount();
if (argc != 1) {
@@ -1106,6 +1147,9 @@
return result.Succeeded();
}
+
+ private:
+ CommandOptions m_options;
};
// CommandObjectMultiwordSettings
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -687,6 +687,9 @@
@classmethod
def setUpCommands(cls):
commands = [
+ # First of all, clear all settings to have clean state of global properties.
+ "settings clear -all",
+
# Disable Spotlight lookup. The testsuite creates
# different binaries with the same UUID, because they only
# differ in the debug info, which is not being hashed.
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits