Author: Jonas Devlieghere
Date: 2025-06-27T08:30:02-07:00
New Revision: 37b0b0f7d2b67fedd347a4011582802303657e69

URL: 
https://github.com/llvm/llvm-project/commit/37b0b0f7d2b67fedd347a4011582802303657e69
DIFF: 
https://github.com/llvm/llvm-project/commit/37b0b0f7d2b67fedd347a4011582802303657e69.diff

LOG: [lldb] Add class property for the version string (#145974)

Add a class property for the version string. This allows you to use
access the version string through `lldb.SBDebugger.version` instead of
having to call `lldb.SBDebugger.GetVersionString()`.

Added: 
    

Modified: 
    lldb/bindings/interface/SBDebuggerExtensions.i
    lldb/test/API/python_api/debugger/TestDebuggerAPI.py

Removed: 
    


################################################################################
diff  --git a/lldb/bindings/interface/SBDebuggerExtensions.i 
b/lldb/bindings/interface/SBDebuggerExtensions.i
index ff2a0359b1363..7895fcdd72468 100644
--- a/lldb/bindings/interface/SBDebuggerExtensions.i
+++ b/lldb/bindings/interface/SBDebuggerExtensions.i
@@ -45,4 +45,17 @@ STRING_EXTENSION_OUTSIDE(SBDebugger)
     lldb::FileSP GetErrorFileHandle() {
         return self->GetErrorFile().GetFile();
     }
+
+#ifdef SWIGPYTHON
+    %pythoncode %{
+        class staticproperty:
+            def __init__(self, func):
+                self.func = func
+            def __get__(self, instance, owner):
+                return self.func()
+        @staticproperty
+        def version():
+            return SBDebugger.GetVersionString()
+    %}
+#endif
 }

diff  --git a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py 
b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
index 646ccce36530d..43f45f330ee2a 100644
--- a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -286,3 +286,11 @@ def remove_bar(dbg_id):
             ('remove bar ret', False), # remove_bar should fail, because it's 
already invoked and removed
             ('foo called', original_dbg_id), # foo should be called
         ])
+
+    def test_version(self):
+        instance_str = self.dbg.GetVersionString()
+        class_str = lldb.SBDebugger.GetVersionString()
+        property_str = lldb.SBDebugger.version
+
+        self.assertEqual(instance_str, class_str)
+        self.assertEqual(class_str, property_str)


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to