[Lldb-commits] [lldb] wip: add "settings modified" command (PR #152338)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 6 09:52:59 PDT 2025
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/152338
None
>From aa9613b6e7a328af6764184e5bbd4a0f33a6d16f Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Tue, 5 Aug 2025 15:37:30 -0700
Subject: [PATCH] wip: add "settings modified" command
---
.../lldb/Interpreter/OptionValueProperties.h | 3 ++
.../source/Commands/CommandObjectSettings.cpp | 44 +++++++++++++++++++
.../API/commands/settings/TestSettings.py | 11 +++++
3 files changed, 58 insertions(+)
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",
+ ],
+ )
More information about the lldb-commits
mailing list