Skip to content

Commit a298abc

Browse files
committed
[lldb] Add "settings modified" command
1 parent c548c47 commit a298abc

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

lldb/include/lldb/Interpreter/OptionValueProperties.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ class OptionValueProperties
163163
return false;
164164
}
165165

166+
auto begin() const { return m_properties.begin(); }
167+
auto end() const { return m_properties.end(); }
168+
166169
protected:
167170
Property *ProtectedGetPropertyAtIndex(size_t idx) {
168171
assert(idx < m_properties.size() && "invalid property index");

lldb/source/Commands/CommandObjectSettings.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,48 @@ class CommandObjectSettingsList : public CommandObjectParsed {
507507
}
508508
};
509509

510+
// CommandObjectSettingsModified -- List modified variables
511+
512+
class CommandObjectSettingsModified : public CommandObjectParsed {
513+
public:
514+
CommandObjectSettingsModified(CommandInterpreter &interpreter)
515+
: CommandObjectParsed(interpreter, "settings modified",
516+
"List modified debugger settings.") {}
517+
518+
~CommandObjectSettingsModified() override = default;
519+
520+
protected:
521+
void HandleProperties(OptionValueProperties *properties, Stream &strm) {
522+
if (!properties)
523+
return;
524+
525+
for (const auto &property : *properties) {
526+
auto value_sp = property.GetValue();
527+
if (!value_sp)
528+
continue;
529+
530+
if (auto *subproperties = value_sp->GetAsProperties()) {
531+
HandleProperties(subproperties, strm);
532+
continue;
533+
}
534+
535+
if (value_sp->OptionWasSet()) {
536+
property.DumpQualifiedName(strm);
537+
strm.PutCString(" = ");
538+
value_sp->DumpValue(&m_exe_ctx, strm, OptionValue::eDumpOptionValue);
539+
strm.EOL();
540+
}
541+
}
542+
}
543+
544+
void DoExecute(Args &args, CommandReturnObject &result) override {
545+
result.SetStatus(eReturnStatusSuccessFinishResult);
546+
547+
if (auto properties_sp = GetDebugger().GetValueProperties())
548+
HandleProperties(properties_sp.get(), result.GetOutputStream());
549+
}
550+
};
551+
510552
// CommandObjectSettingsRemove
511553

512554
class CommandObjectSettingsRemove : public CommandObjectRaw {
@@ -1070,6 +1112,8 @@ CommandObjectMultiwordSettings::CommandObjectMultiwordSettings(
10701112
CommandObjectSP(new CommandObjectSettingsShow(interpreter)));
10711113
LoadSubCommand("list",
10721114
CommandObjectSP(new CommandObjectSettingsList(interpreter)));
1115+
LoadSubCommand("modified", CommandObjectSP(new CommandObjectSettingsModified(
1116+
interpreter)));
10731117
LoadSubCommand("remove",
10741118
CommandObjectSP(new CommandObjectSettingsRemove(interpreter)));
10751119
LoadSubCommand("replace", CommandObjectSP(

lldb/test/API/commands/settings/TestSettings.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,3 +1052,14 @@ def test_global_option(self):
10521052
# NULL execution context (not one with an empty Target...) and in the
10531053
# special handling for load-script-from-symbol-file this wasn't checked.
10541054
self.runCmd("settings set -g target.load-script-from-symbol-file true")
1055+
1056+
def test_modified(self):
1057+
self.runCmd("settings set notify-void true")
1058+
self.runCmd("settings set target.process.optimization-warnings false")
1059+
self.expect(
1060+
"settings modified",
1061+
substrs=[
1062+
"notify-void = true",
1063+
"target.process.optimization-warnings = false",
1064+
],
1065+
)

0 commit comments

Comments
 (0)