aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter
diff options
context:
space:
mode:
authorEbuka Ezike <yerimyah1@gmail.com>2025-04-27 12:11:14 +0100
committerGitHub <noreply@github.com>2025-04-27 12:11:14 +0100
commitd1adb0b8cd64607ef64d8bebc3197964a06de73a (patch)
tree75443eaee10164f13bd4d275ebf2ec973d2ab274 /lldb/source/Interpreter
parente9a34e42369eb4278fdd73105eeb25ff7a4d96c6 (diff)
downloadllvm-d1adb0b8cd64607ef64d8bebc3197964a06de73a.zip
llvm-d1adb0b8cd64607ef64d8bebc3197964a06de73a.tar.gz
llvm-d1adb0b8cd64607ef64d8bebc3197964a06de73a.tar.bz2
Complete ToJSON for OptionValues (#137375)
Completes the ToJSON function for `OptionValue` types and make the interface function pure virtual --------- Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r--lldb/source/Interpreter/OptionValueArch.cpp8
-rw-r--r--lldb/source/Interpreter/OptionValueArray.cpp3
-rw-r--r--lldb/source/Interpreter/OptionValueDictionary.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueEnumeration.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueFileColonLine.cpp13
-rw-r--r--lldb/source/Interpreter/OptionValueFileSpecList.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueFormat.cpp3
-rw-r--r--lldb/source/Interpreter/OptionValueFormatEntity.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueLanguage.cpp3
-rw-r--r--lldb/source/Interpreter/OptionValuePathMappings.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueProperties.cpp2
11 files changed, 33 insertions, 9 deletions
diff --git a/lldb/source/Interpreter/OptionValueArch.cpp b/lldb/source/Interpreter/OptionValueArch.cpp
index a2fed77..ea15cca 100644
--- a/lldb/source/Interpreter/OptionValueArch.cpp
+++ b/lldb/source/Interpreter/OptionValueArch.cpp
@@ -33,6 +33,14 @@ void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
}
}
+llvm::json::Value
+OptionValueArch::ToJSON(const ExecutionContext *exe_ctx) const {
+ if (m_current_value.IsValid())
+ return llvm::json::Value(m_current_value.GetArchitectureName());
+
+ return {};
+}
+
Status OptionValueArch::SetValueFromString(llvm::StringRef value,
VarSetOperationType op) {
Status error;
diff --git a/lldb/source/Interpreter/OptionValueArray.cpp b/lldb/source/Interpreter/OptionValueArray.cpp
index 067172d..f6c14de 100644
--- a/lldb/source/Interpreter/OptionValueArray.cpp
+++ b/lldb/source/Interpreter/OptionValueArray.cpp
@@ -75,7 +75,8 @@ void OptionValueArray::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
}
}
-llvm::json::Value OptionValueArray::ToJSON(const ExecutionContext *exe_ctx) {
+llvm::json::Value
+OptionValueArray::ToJSON(const ExecutionContext *exe_ctx) const {
llvm::json::Array json_array;
const uint32_t size = m_values.size();
for (uint32_t i = 0; i < size; ++i)
diff --git a/lldb/source/Interpreter/OptionValueDictionary.cpp b/lldb/source/Interpreter/OptionValueDictionary.cpp
index 4ee8e59..19e21dd 100644
--- a/lldb/source/Interpreter/OptionValueDictionary.cpp
+++ b/lldb/source/Interpreter/OptionValueDictionary.cpp
@@ -88,7 +88,7 @@ void OptionValueDictionary::DumpValue(const ExecutionContext *exe_ctx,
}
llvm::json::Value
-OptionValueDictionary::ToJSON(const ExecutionContext *exe_ctx) {
+OptionValueDictionary::ToJSON(const ExecutionContext *exe_ctx) const {
llvm::json::Object dict;
for (const auto &value : m_values) {
dict.try_emplace(value.first(), value.second->ToJSON(exe_ctx));
diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp
index dd231f4..cf64623 100644
--- a/lldb/source/Interpreter/OptionValueEnumeration.cpp
+++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp
@@ -38,7 +38,7 @@ void OptionValueEnumeration::DumpValue(const ExecutionContext *exe_ctx,
}
llvm::json::Value
-OptionValueEnumeration::ToJSON(const ExecutionContext *exe_ctx) {
+OptionValueEnumeration::ToJSON(const ExecutionContext *exe_ctx) const {
for (const auto &enums : m_enumerations) {
if (enums.value.value == m_current_value)
return enums.cstring.GetStringRef();
diff --git a/lldb/source/Interpreter/OptionValueFileColonLine.cpp b/lldb/source/Interpreter/OptionValueFileColonLine.cpp
index 87d390d..a4f65da 100644
--- a/lldb/source/Interpreter/OptionValueFileColonLine.cpp
+++ b/lldb/source/Interpreter/OptionValueFileColonLine.cpp
@@ -46,6 +46,19 @@ void OptionValueFileColonLine::DumpValue(const ExecutionContext *exe_ctx,
}
}
+llvm::json::Value
+OptionValueFileColonLine::ToJSON(const ExecutionContext *exe_ctx) const {
+ StreamString stream;
+ if (m_file_spec)
+ stream << '"' << m_file_spec.GetPath().c_str() << '"';
+ if (m_line_number != LLDB_INVALID_LINE_NUMBER)
+ stream.Printf(":%d", m_line_number);
+ if (m_column_number != LLDB_INVALID_COLUMN_NUMBER)
+ stream.Printf(":%d", m_column_number);
+
+ return llvm::json::Value(stream.GetString());
+}
+
Status OptionValueFileColonLine::SetValueFromString(llvm::StringRef value,
VarSetOperationType op) {
Status error;
diff --git a/lldb/source/Interpreter/OptionValueFileSpecList.cpp b/lldb/source/Interpreter/OptionValueFileSpecList.cpp
index 84607eb..f252dc4 100644
--- a/lldb/source/Interpreter/OptionValueFileSpecList.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpecList.cpp
@@ -42,7 +42,7 @@ void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx,
}
llvm::json::Value
-OptionValueFileSpecList::ToJSON(const ExecutionContext *exe_ctx) {
+OptionValueFileSpecList::ToJSON(const ExecutionContext *exe_ctx) const {
std::lock_guard<std::recursive_mutex> lock(m_mutex);
llvm::json::Array array;
for (const auto &file_spec : m_current_value)
diff --git a/lldb/source/Interpreter/OptionValueFormat.cpp b/lldb/source/Interpreter/OptionValueFormat.cpp
index ab89f67..bc4e779 100644
--- a/lldb/source/Interpreter/OptionValueFormat.cpp
+++ b/lldb/source/Interpreter/OptionValueFormat.cpp
@@ -26,7 +26,8 @@ void OptionValueFormat::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
}
}
-llvm::json::Value OptionValueFormat::ToJSON(const ExecutionContext *exe_ctx) {
+llvm::json::Value
+OptionValueFormat::ToJSON(const ExecutionContext *exe_ctx) const {
return FormatManager::GetFormatAsCString(m_current_value);
}
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index addcfe0..d8b8301 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -61,7 +61,7 @@ void OptionValueFormatEntity::DumpValue(const ExecutionContext *exe_ctx,
}
llvm::json::Value
-OptionValueFormatEntity::ToJSON(const ExecutionContext *exe_ctx) {
+OptionValueFormatEntity::ToJSON(const ExecutionContext *exe_ctx) const {
std::string escaped;
EscapeBackticks(m_current_format, escaped);
return escaped;
diff --git a/lldb/source/Interpreter/OptionValueLanguage.cpp b/lldb/source/Interpreter/OptionValueLanguage.cpp
index eb8eef0..0fdaacb 100644
--- a/lldb/source/Interpreter/OptionValueLanguage.cpp
+++ b/lldb/source/Interpreter/OptionValueLanguage.cpp
@@ -29,7 +29,8 @@ void OptionValueLanguage::DumpValue(const ExecutionContext *exe_ctx,
}
}
-llvm::json::Value OptionValueLanguage::ToJSON(const ExecutionContext *exe_ctx) {
+llvm::json::Value
+OptionValueLanguage::ToJSON(const ExecutionContext *exe_ctx) const {
return Language::GetNameForLanguageType(m_current_value);
}
diff --git a/lldb/source/Interpreter/OptionValuePathMappings.cpp b/lldb/source/Interpreter/OptionValuePathMappings.cpp
index 757be83..95b8e64 100644
--- a/lldb/source/Interpreter/OptionValuePathMappings.cpp
+++ b/lldb/source/Interpreter/OptionValuePathMappings.cpp
@@ -35,7 +35,7 @@ void OptionValuePathMappings::DumpValue(const ExecutionContext *exe_ctx,
}
llvm::json::Value
-OptionValuePathMappings::ToJSON(const ExecutionContext *exe_ctx) {
+OptionValuePathMappings::ToJSON(const ExecutionContext *exe_ctx) const {
return m_path_mappings.ToJSON();
}
diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp
index ebea94d..cb71bff 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -335,7 +335,7 @@ void OptionValueProperties::DumpValue(const ExecutionContext *exe_ctx,
}
llvm::json::Value
-OptionValueProperties::ToJSON(const ExecutionContext *exe_ctx) {
+OptionValueProperties::ToJSON(const ExecutionContext *exe_ctx) const {
llvm::json::Object json_properties;
const size_t num_properties = m_properties.size();
for (size_t i = 0; i < num_properties; ++i) {