[llvm-branch-commits] [lldb] release/23.x: [lldb] Fix SBValue.format property (#216802) (PR #216876)

Douglas Yung via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 20 13:49:51 PDT 2026


https://github.com/dyung updated https://github.com/llvm/llvm-project/pull/216876

>From a1b7c09ca1d024e5416d383cd01ceb7a1e100675 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <e_ezike at apple.com>
Date: Mon, 17 Aug 2026 22:18:14 +0100
Subject: [PATCH] [lldb] Fix SBValue.format property (#216802)

lldb.SBValue.format should map to GetFormat instead of GetName

(cherry picked from commit 91ba38d018aaf672fad6c7a41da8d725f659417f)
---
 lldb/bindings/interface/SBValueExtensions.i    |  2 +-
 lldb/test/API/python_api/value/TestValueAPI.py | 16 ++++++++++++++++
 lldb/test/API/python_api/value/main.c          |  1 +
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i
index c7e346529d352..342216b939fa8 100644
--- a/lldb/bindings/interface/SBValueExtensions.i
+++ b/lldb/bindings/interface/SBValueExtensions.i
@@ -69,7 +69,7 @@ STRING_EXTENSION_OUTSIDE(SBValue)
         type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''')
         size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''')
         is_in_scope = property(IsInScope, None, doc='''A read only property that returns a boolean value that indicates whether this value is currently lexically in scope.''')
-        format = property(GetName, SetFormat, doc='''A read/write property that gets/sets the format used for lldb.SBValue().GetValue() for this value. See enumerations that start with "lldb.eFormat".''')
+        format = property(GetFormat, SetFormat, doc='''A read/write property that gets/sets the format used for lldb.SBValue().GetValue() for this value. See enumerations that start with "lldb.eFormat".''')
         value = property(GetValue, SetValueFromCString, doc='''A read/write property that gets/sets value from a string.''')
         value_type = property(GetValueType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eValueType") that represents the type of this value (local, argument, global, register, etc.).''')
         changed = property(GetValueDidChange, None, doc='''A read only property that returns a boolean value that indicates if this value has changed since it was last updated.''')
diff --git a/lldb/test/API/python_api/value/TestValueAPI.py b/lldb/test/API/python_api/value/TestValueAPI.py
index dba5f959ba60d..52d444ae5c576 100644
--- a/lldb/test/API/python_api/value/TestValueAPI.py
+++ b/lldb/test/API/python_api/value/TestValueAPI.py
@@ -274,6 +274,22 @@ def test(self):
         a_null_int_ptr = frame0.FindVariable("a_null_int_ptr")
         self.assertEqual(a_null_int_ptr.GetValue(), "0x0")
 
+        a_val: lldb.SBValue = frame0.FindVariable("a_val")
+        self.assertTrue(a_val)
+        self.assertEqual(a_val.value, "10")
+        self.assertEqual(a_val.GetValue(), "10")
+
+        a_val.SetFormat(lldb.eFormatBoolean)
+        self.assertEqual(a_val.format, lldb.eFormatBoolean)
+        self.assertEqual(a_val.GetFormat(), lldb.eFormatBoolean)
+        self.assertEqual(a_val.value.lower(), "true")
+
+        # Verify the setter.
+        a_val.format = lldb.eFormatHex
+        self.assertEqual(a_val.format, lldb.eFormatHex)
+        self.assertEqual(a_val.GetFormat(), lldb.eFormatHex)
+        self.assertEqual(a_val.value.lower(), "0xa")
+
         # Check that dereferencing a null pointer produces reasonable results
         # (does not crash).
         self.assertEqual(
diff --git a/lldb/test/API/python_api/value/main.c b/lldb/test/API/python_api/value/main.c
index cdb2aa2f6147b..5798207242fd0 100644
--- a/lldb/test/API/python_api/value/main.c
+++ b/lldb/test/API/python_api/value/main.c
@@ -51,6 +51,7 @@ int main (int argc, char const *argv[])
     int32_t  sinthex = 0xE0A35F10;
 
     int i;
+    int a_val = 10;
     MyInt a = 12345;
     struct MyStruct s = {11, 22};
     struct MyBiggerStruct f = { 33, 44, 55 };



More information about the llvm-branch-commits mailing list