Author: Nerixyz
Date: 2026-08-05T13:06:24+02:00
New Revision: 9fbe25d98ff36d5820e8b15981e9950b40ad3f49

URL: 
https://github.com/llvm/llvm-project/commit/9fbe25d98ff36d5820e8b15981e9950b40ad3f49
DIFF: 
https://github.com/llvm/llvm-project/commit/9fbe25d98ff36d5820e8b15981e9950b40ad3f49.diff

LOG: [lldb][Python] Fix SBProcessInfoList subscript and iterator (#214038)

Found this in #214000 when looking through the generated `__init__.py`.


[`SBProcessInfo::GetProcessInfoAtIndex`](https://lldb.llvm.org/python_api/lldb.SBProcessInfoList.html#lldb.SBProcessInfoList.GetProcessInfoAtIndex)
takes a reference to an info that it fills instead of returning one. So
we need to pass that `ProcessInfo` to it.

Added: 
    

Modified: 
    lldb/bindings/interface/SBProcessInfoListExtensions.i
    lldb/test/API/functionalities/gdb_remote_client/TestPlatformListProcesses.py

Removed: 
    


################################################################################
diff  --git a/lldb/bindings/interface/SBProcessInfoListExtensions.i 
b/lldb/bindings/interface/SBProcessInfoListExtensions.i
index 59d7828d5b3ca..224e2475b0820 100644
--- a/lldb/bindings/interface/SBProcessInfoListExtensions.i
+++ b/lldb/bindings/interface/SBProcessInfoListExtensions.i
@@ -8,7 +8,9 @@
     def __iter__(self):
       '''Iterate over all the process info in a 
lldb.SBProcessInfoListExtensions object.'''
       for i in range(self.GetSize()):
-          yield self.GetProcessInfoAtIndex(i)
+          p = SBProcessInfo()
+          self.GetProcessInfoAtIndex(i, p)
+          yield p
 
     def __getitem__(self, idx):
       '''Get the process info at a given index in an lldb.SBProcessInfoList 
object.'''
@@ -18,7 +20,9 @@
       if not (-count <= idx < count):
         raise IndexError("list index out of range")
       idx %= count
-      return self.GetProcessInfoAtIndex(idx)
+      p = SBProcessInfo()
+      self.GetProcessInfoAtIndex(idx, p)
+      return p
     %}
 #endif
 }

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestPlatformListProcesses.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestPlatformListProcesses.py
index be0e3f5f8c501..a33d3ca9056ac 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestPlatformListProcesses.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestPlatformListProcesses.py
@@ -46,9 +46,23 @@ def qsProcessInfo(self):
         processes.GetProcessInfoAtIndex(0, process_info)
         self.assertEqual(process_info.GetProcessID(), 95117)
         self.assertEqual(process_info.GetName(), "foo")
+        self.assertEqual(processes[0].GetProcessID(), 95117)
 
         processes.GetProcessInfoAtIndex(1, process_info)
         self.assertEqual(process_info.GetProcessID(), 95126)
         self.assertEqual(process_info.GetName(), "foo")
+        self.assertEqual(processes[1].GetProcessID(), 95126)
+
+        any_process = False
+        for i, info in enumerate(processes):
+            any_process = True
+            if i == 0:
+                self.assertEqual(info.GetProcessID(), 95117)
+            elif i == 1:
+                self.assertEqual(info.GetProcessID(), 95126)
+            else:
+                self.fail("More than two processes returned")
+
+        self.assertTrue(any_process)
 
         platform.DisconnectRemote()


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to