-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb][lldb-dap] Add ToJSON for OptionValueEnumeration #137007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
da-viper
merged 2 commits into
llvm:main
from
da-viper:add-to-json-for-option-value-enums
Apr 24, 2025
Merged
[lldb][lldb-dap] Add ToJSON for OptionValueEnumeration #137007
da-viper
merged 2 commits into
llvm:main
from
da-viper:add-to-json-for-option-value-enums
Apr 24, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This automatically enables dumping enum settings in the python api
@llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) ChangesThis automatically enables dumping enum settings in the python api Full diff: https://github.com/llvm/llvm-project/pull/137007.diff 3 Files Affected:
diff --git a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
index 7dc6eea4e69de..924fcc10cbb00 100644
--- a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
+++ b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
@@ -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;
diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp
index 8088695243545..bd91f6e2ad446 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 llvm::formatv("%", PRIu64, 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());
}
diff --git a/lldb/test/API/commands/settings/TestSettings.py b/lldb/test/API/commands/settings/TestSettings.py
index b9b66ea953971..f05a285b47d16 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -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
|
JDevlieghere
approved these changes
Apr 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
JDevlieghere
approved these changes
Apr 24, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
This automatically enables reading enum settings in the SB API
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
This automatically enables reading enum settings in the SB API
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
This automatically enables reading enum settings in the SB API
Ankur-0429
pushed a commit
to Ankur-0429/llvm-project
that referenced
this pull request
May 9, 2025
This automatically enables reading enum settings in the SB API
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This automatically enables dumping enum settings in the python api