Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lldb/include/lldb/Interpreter/OptionValueEnumeration.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class OptionValueEnumeration
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;

Status
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
Expand Down
14 changes: 12 additions & 2 deletions lldb/source/Interpreter/OptionValueEnumeration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ void OptionValueEnumeration::DumpValue(const ExecutionContext *exe_ctx,
}
}

llvm::json::Value
OptionValueEnumeration::ToJSON(const ExecutionContext *exe_ctx) {
for (const auto &enums : m_enumerations) {
if (enums.value.value == m_current_value)
return enums.cstring.GetStringRef();
}

return std::to_string(static_cast<uint64_t>(m_current_value));
}

Status OptionValueEnumeration::SetValueFromString(llvm::StringRef value,
VarSetOperationType op) {
Status error;
Expand Down Expand Up @@ -105,6 +115,6 @@ void OptionValueEnumeration::AutoComplete(CommandInterpreter &interpreter,
}
return;
}
for (size_t i = 0; i < num_enumerators; ++i)
request.AddCompletion(m_enumerations.GetCStringAtIndex(i).GetStringRef());
for (size_t i = 0; i < num_enumerators; ++i)
request.AddCompletion(m_enumerations.GetCStringAtIndex(i).GetStringRef());
}
3 changes: 3 additions & 0 deletions lldb/test/API/commands/settings/TestSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,9 @@ def test_settings_api(self):
# Test OptionValueLanguage
self.verify_setting_value_json("repl-lang", "c++")

# Test OptionValueEnumeration
self.verify_setting_value_json("target.x86-disassembly-flavor", "intel")

def test_global_option(self):
# This command used to crash the settings because -g was signaled by a
# NULL execution context (not one with an empty Target...) and in the
Expand Down
Loading