Skip to content

Commit 37b0b0f

Browse files
authored
[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()`.
1 parent a460aa1 commit 37b0b0f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lldb/bindings/interface/SBDebuggerExtensions.i

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,17 @@ STRING_EXTENSION_OUTSIDE(SBDebugger)
4545
lldb::FileSP GetErrorFileHandle() {
4646
return self->GetErrorFile().GetFile();
4747
}
48+
49+
#ifdef SWIGPYTHON
50+
%pythoncode %{
51+
class staticproperty:
52+
def __init__(self, func):
53+
self.func = func
54+
def __get__(self, instance, owner):
55+
return self.func()
56+
@staticproperty
57+
def version():
58+
return SBDebugger.GetVersionString()
59+
%}
60+
#endif
4861
}

lldb/test/API/python_api/debugger/TestDebuggerAPI.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,11 @@ def remove_bar(dbg_id):
286286
('remove bar ret', False), # remove_bar should fail, because it's already invoked and removed
287287
('foo called', original_dbg_id), # foo should be called
288288
])
289+
290+
def test_version(self):
291+
instance_str = self.dbg.GetVersionString()
292+
class_str = lldb.SBDebugger.GetVersionString()
293+
property_str = lldb.SBDebugger.version
294+
295+
self.assertEqual(instance_str, class_str)
296+
self.assertEqual(class_str, property_str)

0 commit comments

Comments
 (0)