llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/152338.diff


3 Files Affected:

- (modified) lldb/include/lldb/Interpreter/OptionValueProperties.h (+3) 
- (modified) lldb/source/Commands/CommandObjectSettings.cpp (+44) 
- (modified) lldb/test/API/commands/settings/TestSettings.py (+11) 


``````````diff
diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h 
b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index 91a3955962372..a68c233e189fd 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -163,6 +163,9 @@ class OptionValueProperties
     return false;
   }
 
+  auto begin() const { return m_properties.begin(); }
+  auto end() const { return m_properties.end(); }
+
 protected:
   Property *ProtectedGetPropertyAtIndex(size_t idx) {
     assert(idx < m_properties.size() && "invalid property index");
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp 
b/lldb/source/Commands/CommandObjectSettings.cpp
index 7bbb0dd567ab1..5960feb8c4778 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -507,6 +507,48 @@ class CommandObjectSettingsList : public 
CommandObjectParsed {
   }
 };
 
+// CommandObjectSettingsModified -- List modified variables
+
+class CommandObjectSettingsModified : public CommandObjectParsed {
+public:
+  CommandObjectSettingsModified(CommandInterpreter &interpreter)
+      : CommandObjectParsed(interpreter, "settings modified",
+                            "List modified debugger settings.") {}
+
+  ~CommandObjectSettingsModified() override = default;
+
+protected:
+  void HandleProperties(OptionValueProperties *properties, Stream &strm) {
+    if (!properties)
+      return;
+
+    for (const auto &property : *properties) {
+      auto value_sp = property.GetValue();
+      if (!value_sp)
+        continue;
+
+      if (auto *subproperties = value_sp->GetAsProperties()) {
+        HandleProperties(subproperties, strm);
+        continue;
+      }
+
+      if (value_sp->OptionWasSet()) {
+        property.DumpQualifiedName(strm);
+        strm.PutCString(" = ");
+        value_sp->DumpValue(&m_exe_ctx, strm, OptionValue::eDumpOptionValue);
+        strm.EOL();
+      }
+    }
+  }
+
+  void DoExecute(Args &args, CommandReturnObject &result) override {
+    result.SetStatus(eReturnStatusSuccessFinishResult);
+
+    if (auto properties_sp = GetDebugger().GetValueProperties())
+      HandleProperties(properties_sp.get(), result.GetOutputStream());
+  }
+};
+
 // CommandObjectSettingsRemove
 
 class CommandObjectSettingsRemove : public CommandObjectRaw {
@@ -1070,6 +1112,8 @@ 
CommandObjectMultiwordSettings::CommandObjectMultiwordSettings(
                  CommandObjectSP(new CommandObjectSettingsShow(interpreter)));
   LoadSubCommand("list",
                  CommandObjectSP(new CommandObjectSettingsList(interpreter)));
+  LoadSubCommand("modified", CommandObjectSP(new CommandObjectSettingsModified(
+                                 interpreter)));
   LoadSubCommand("remove",
                  CommandObjectSP(new 
CommandObjectSettingsRemove(interpreter)));
   LoadSubCommand("replace", CommandObjectSP(
diff --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index bc864942055c0..2dceb49e9eab8 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -1052,3 +1052,14 @@ def test_global_option(self):
         # NULL execution context (not one with an empty Target...) and in the
         # special handling for load-script-from-symbol-file this wasn't 
checked.
         self.runCmd("settings set -g target.load-script-from-symbol-file true")
+
+    def test_modified(self):
+        self.runCmd("settings set notify-void true")
+        self.runCmd("settings set target.process.optimization-warnings false")
+        self.expect(
+            "settings modified",
+            substrs=[
+                "notify-void = true",
+                "target.process.optimization-warnings = false",
+            ],
+        )

``````````

</details>


https://github.com/llvm/llvm-project/pull/152338
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to