[Lldb-commits] [lldb] [lldb] Support indexes of hidden children in SBValue.child accessor (PR #205604)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 24 14:04:13 PDT 2026


https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/205604

>From b2ee2b08ac31c1b9bfbd17f41cc2b0872524e4a9 Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Wed, 24 Jun 2026 10:31:30 -0700
Subject: [PATCH 1/2] [lldb] Support indexes of hidden children in
 SBValue.child accessor

---
 lldb/bindings/interface/SBValueExtensions.i | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i
index 63e61141afec1..c590b6ddf73f3 100644
--- a/lldb/bindings/interface/SBValueExtensions.i
+++ b/lldb/bindings/interface/SBValueExtensions.i
@@ -22,6 +22,7 @@ STRING_EXTENSION_OUTSIDE(SBValue)
                     count = len(self)
                     if -count <= key < count:
                         key %= count
+                    if key >= 0:
                         return self.sbvalue.GetChildAtIndex(key)
                 return None
 

>From e274245e0d1216b7848c6e87d0a8de556880c8fe Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Wed, 24 Jun 2026 14:03:40 -0700
Subject: [PATCH 2/2] tweak

---
 lldb/bindings/interface/SBValueExtensions.i | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i
index c590b6ddf73f3..c7e346529d352 100644
--- a/lldb/bindings/interface/SBValueExtensions.i
+++ b/lldb/bindings/interface/SBValueExtensions.i
@@ -19,9 +19,9 @@ STRING_EXTENSION_OUTSIDE(SBValue)
 
             def __getitem__(self, key):
                 if isinstance(key, int):
-                    count = len(self)
-                    if -count <= key < count:
-                        key %= count
+                    if key < 0:
+                        # Support pythonic negative indexing.
+                        key += len(self)
                     if key >= 0:
                         return self.sbvalue.GetChildAtIndex(key)
                 return None



More information about the lldb-commits mailing list