Skip to content

Commit a87d7be

Browse files
committed
[lldb] Add ToJson for OptionValueArch
1 parent 12a3165 commit a87d7be

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

lldb/include/lldb/Interpreter/OptionValueArch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class OptionValueArch : public Cloneable<OptionValueArch, OptionValue> {
3838
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3939
uint32_t dump_mask) override;
4040

41+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
42+
4143
Status
4244
SetValueFromString(llvm::StringRef value,
4345
VarSetOperationType op = eVarSetOperationAssign) override;

lldb/source/Interpreter/OptionValueArch.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3333
}
3434
}
3535

36+
llvm::json::Value OptionValueArch::ToJSON(const ExecutionContext *exe_ctx) {
37+
if (m_current_value.IsValid()) {
38+
return llvm::json::Value(m_current_value.GetArchitectureName());
39+
}
40+
41+
return {};
42+
}
43+
3644
Status OptionValueArch::SetValueFromString(llvm::StringRef value,
3745
VarSetOperationType op) {
3846
Status error;

lldb/test/API/commands/settings/TestSettings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,10 @@ def test_settings_api(self):
10441044
# Test OptionValueEnumeration
10451045
self.verify_setting_value_json("target.x86-disassembly-flavor", "intel")
10461046

1047+
# Test OptionValueArch
1048+
self.verify_setting_value_json("target.default-arch", "x86_64")
1049+
self.runCmd("settings clear target.default-arch")
1050+
10471051
def test_global_option(self):
10481052
# This command used to crash the settings because -g was signaled by a
10491053
# NULL execution context (not one with an empty Target...) and in the

0 commit comments

Comments
 (0)