Skip to content

[lldb] Fix SBValue.format property - #216802

Merged
da-viper merged 1 commit into
llvm:mainfrom
da-viper:fix-format-branch
Aug 17, 2026
Merged

da-viper merged 1 commit into
llvm:mainfrom
da-viper:fix-format-branch

Conversation

@da-viper

Copy link
Copy Markdown
Contributor

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

lldb.SBValue.format should map to GetFormat instead of GetName
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/216802.diff

3 Files Affected:

  • (modified) lldb/bindings/interface/SBValueExtensions.i (+1-1)
  • (modified) lldb/test/API/python_api/value/TestValueAPI.py (+16)
  • (modified) lldb/test/API/python_api/value/main.c (+1)
diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i
index 6d583aa28da3a..1748eaec44da9 100644
--- a/lldb/bindings/interface/SBValueExtensions.i
+++ b/lldb/bindings/interface/SBValueExtensions.i
@@ -70,7 +70,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 beb3a6fce65f7..cdc8c46723803 100644
--- a/lldb/test/API/python_api/value/TestValueAPI.py
+++ b/lldb/test/API/python_api/value/TestValueAPI.py
@@ -273,6 +273,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 };

@bulbazord bulbazord left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

@da-viper
da-viper merged commit 91ba38d into llvm:main Aug 17, 2026
15 checks passed
@da-viper da-viper added this to the LLVM 23.x Release milestone Aug 17, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in LLVM Release Status Aug 17, 2026
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in LLVM Release Status Aug 17, 2026
@da-viper

Copy link
Copy Markdown
Contributor Author

/cherry-pick 91ba38d

@llvmbot

llvmbot commented Aug 17, 2026

Copy link
Copy Markdown
Member

/pull-request #216876

dyung pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 20, 2026
lldb.SBValue.format should map to GetFormat instead of GetName

(cherry picked from commit 91ba38d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

3 participants