Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 1 addition & 9 deletions lldb/include/lldb/Interpreter/OptionValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,7 @@ class OptionValue {
virtual void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) = 0;

// TODO: make this function pure virtual after implementing it in all
// child classes.
virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) {
// Return nullptr which will create a llvm::json::Value() that is a NULL
// value. No setting should ever really have a NULL value in JSON. This
// indicates an error occurred and if/when we add a FromJSON() it will know
// to fail if someone tries to set it with a NULL JSON value.
return nullptr;
}
virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const = 0;

virtual Status
SetValueFromString(llvm::StringRef value,
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/Interpreter/OptionValueArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class OptionValueArch : public Cloneable<OptionValueArch, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OptionValueArray : public Cloneable<OptionValueArray, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueBoolean.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
return m_current_value;
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueChar.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OptionValueChar : public Cloneable<OptionValueChar, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
return m_current_value;
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class OptionValueDictionary
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueEnumeration.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class OptionValueEnumeration
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class OptionValueFileColonLine :
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueFileSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OptionValueFileSpec : public Cloneable<OptionValueFileSpec, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
return m_current_value.GetPath();
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class OptionValueFileSpecList
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class OptionValueFormat
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class OptionValueFormatEntity
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueLanguage.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class OptionValueLanguage : public Cloneable<OptionValueLanguage, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValuePathMappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OptionValuePathMappings
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

Status
SetValueFromString(llvm::StringRef value,
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class OptionValueProperties
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

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

llvm::StringRef GetName() const override { return m_name; }

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueRegex.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class OptionValueRegex : public Cloneable<OptionValueRegex, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
return m_regex.GetText();
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueSInt64.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
return m_current_value;
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueString.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class OptionValueString : public Cloneable<OptionValueString, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
return m_current_value;
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueUInt64.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class OptionValueUInt64 : public Cloneable<OptionValueUInt64, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
return m_current_value;
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/OptionValueUUID.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OptionValueUUID : public Cloneable<OptionValueUUID, OptionValue> {
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;

llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
return m_uuid.GetAsString();
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Target/PathMappingList.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PathMappingList {
// By default, dump all pairs.
void Dump(Stream *s, int pair_index = -1);

llvm::json::Value ToJSON();
llvm::json::Value ToJSON() const;

bool IsEmpty() const {
std::lock_guard<std::mutex> lock(m_pairs_mutex);
Expand Down
9 changes: 9 additions & 0 deletions lldb/source/Interpreter/OptionValueArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ 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;
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Interpreter/OptionValueArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Interpreter/OptionValueDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Interpreter/OptionValueEnumeration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 13 additions & 0 deletions lldb/source/Interpreter/OptionValueFileColonLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Interpreter/OptionValueFileSpecList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Interpreter/OptionValueFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Interpreter/OptionValueFormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Interpreter/OptionValueLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Interpreter/OptionValuePathMappings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Interpreter/OptionValueProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Target/PathMappingList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void PathMappingList::Dump(Stream *s, int pair_index) {
}
}

llvm::json::Value PathMappingList::ToJSON() {
llvm::json::Value PathMappingList::ToJSON() const {
llvm::json::Array entries;
std::lock_guard<std::mutex> lock(m_pairs_mutex);
for (const auto &pair : m_pairs) {
Expand Down
4 changes: 4 additions & 0 deletions lldb/test/API/commands/settings/TestSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,10 @@ def test_settings_api(self):
# Test OptionValueEnumeration
self.verify_setting_value_json("target.x86-disassembly-flavor", "intel")

# Test OptionValueArch
self.verify_setting_value_json("target.default-arch", "x86_64")
self.runCmd("settings clear target.default-arch")

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