[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
Thu Jun 25 13:55:57 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/3] [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/3] 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
>From b5de81533e786bc10dda0017128b7924ecf81c8a Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Thu, 25 Jun 2026 13:55:30 -0700
Subject: [PATCH 3/3] Add test
---
.../TestDataFormatterPythonSynth.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py b/lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
index 512840b9f0655..fc0f46aa71697 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
@@ -183,6 +183,15 @@ def cleanup():
self.assertEqual(foo_var.GetChildAtIndex(1).GetName(), "fake_a")
self.assertEqual(foo_var.GetChildAtIndex(2).GetName(), "r")
+ # Test the `child` accessor with indexes of hidden children: those with
+ # indexes beyond num_children. wrapfooSynthProvider has a hidden child
+ # at index=num_children, access by the name "$$dereference$$".
+ hidden_index = wrapper_var.GetIndexOfChildWithName("$$dereference$$")
+ self.assertGreaterEqual(hidden_index, wrapper_var.num_children)
+ hidden_child = wrapper_var.child[hidden_index]
+ self.assertIsNotNone(hidden_child)
+ self.assertGreater(hidden_child.num_children, 0)
+
# now delete the synth and add the filter
self.runCmd("type synth delete foo")
self.runCmd("type synth delete wrapfoo")
More information about the lldb-commits
mailing list