diff options
author | Ebuka Ezike <yerimyah1@gmail.com> | 2025-04-24 07:38:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-24 07:38:35 +0100 |
commit | fb0000b6624a5f2df25d10e3667111e96dd1abd5 (patch) | |
tree | c1dc68845a57b5f256d3cf674be0f9a11e755e89 /lldb/source/Interpreter | |
parent | dbb0605f87d8b10171fba6291dd184f5fbf17683 (diff) | |
download | llvm-fb0000b6624a5f2df25d10e3667111e96dd1abd5.zip llvm-fb0000b6624a5f2df25d10e3667111e96dd1abd5.tar.gz llvm-fb0000b6624a5f2df25d10e3667111e96dd1abd5.tar.bz2 |
[lldb][lldb-dap] Add ToJSON for OptionValueEnumeration (#137007)
This automatically enables reading enum settings in the SB API
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r-- | lldb/source/Interpreter/OptionValueEnumeration.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp index 8088695..dd231f4 100644 --- a/lldb/source/Interpreter/OptionValueEnumeration.cpp +++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp @@ -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; @@ -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()); } |