llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/118814.diff


2 Files Affected:

- (modified) lldb/bindings/interface/SBValueExtensions.i (+4-2) 
- (modified) lldb/test/API/python_api/value/TestValueAPI.py (+3-5) 


``````````diff
diff --git a/lldb/bindings/interface/SBValueExtensions.i 
b/lldb/bindings/interface/SBValueExtensions.i
index bee9c27775d453..f743b8b9bc786f 100644
--- a/lldb/bindings/interface/SBValueExtensions.i
+++ b/lldb/bindings/interface/SBValueExtensions.i
@@ -7,7 +7,7 @@ STRING_EXTENSION_OUTSIDE(SBValue)
             return self.GetDynamicValue (eDynamicCanRunTarget)
 
         class children_access(object):
-            '''A helper object that will lazily hand out thread for a process 
when supplied an index.'''
+            '''A helper object that will lazily hand out child values when 
supplied an index or name.'''
 
             def __init__(self, sbvalue):
                 self.sbvalue = sbvalue
@@ -23,6 +23,8 @@ STRING_EXTENSION_OUTSIDE(SBValue)
                     if -count <= key < count:
                         key %= count
                         return self.sbvalue.GetChildAtIndex(key)
+                elif isinstance(key, str):
+                    return self.sbvalue.GetChildMemberWithName(key)
                 return None
 
         def get_child_access_object(self):
@@ -49,7 +51,7 @@ STRING_EXTENSION_OUTSIDE(SBValue)
             return self.GetNumChildren()
 
         children = property(get_value_child_list, None, doc='''A read only 
property that returns a list() of lldb.SBValue objects for the children of the 
value.''')
-        child = property(get_child_access_object, None, doc='''A read only 
property that returns an object that can access children of a variable by index 
(child_value = value.children[12]).''')
+        child = property(get_child_access_object, None, doc='''A read only 
property that returns an object that can access children of a variable by index 
or by name.''')
         name = property(GetName, None, doc='''A read only property that 
returns the name of this value as a string.''')
         type = property(GetType, None, doc='''A read only property that 
returns a lldb.SBType object that represents the type for this value.''')
         size = property(GetByteSize, None, doc='''A read only property that 
returns the size in bytes of this value.''')
diff --git a/lldb/test/API/python_api/value/TestValueAPI.py 
b/lldb/test/API/python_api/value/TestValueAPI.py
index 512100912d6fe7..eb6dbfe6362a43 100644
--- a/lldb/test/API/python_api/value/TestValueAPI.py
+++ b/lldb/test/API/python_api/value/TestValueAPI.py
@@ -140,10 +140,8 @@ def test(self):
         val_i = target.EvaluateExpression("i")
         val_s = target.EvaluateExpression("s")
         val_a = target.EvaluateExpression("a")
-        self.assertTrue(
-            val_s.GetChildMemberWithName("a").GetAddress().IsValid(), 
VALID_VARIABLE
-        )
-        self.assertTrue(val_s.GetChildMemberWithName("a").AddressOf(), 
VALID_VARIABLE)
+        self.assertTrue(val_s.child["a"].GetAddress().IsValid(), 
VALID_VARIABLE)
+        self.assertTrue(val_s.child["a"].AddressOf(), VALID_VARIABLE)
         self.assertTrue(val_a.Cast(val_i.GetType()).AddressOf(), 
VALID_VARIABLE)
 
         # Test some other cases of the Cast API.  We allow casts from one 
struct type
@@ -210,7 +208,7 @@ def test(self):
         weird_cast = f_var.Cast(val_s.GetType())
         self.assertSuccess(weird_cast.GetError(), "Can cast from a larger to a 
smaller")
         self.assertEqual(
-            weird_cast.GetChildMemberWithName("a").GetValueAsSigned(0),
+            weird_cast.child["a"].GetValueAsSigned(0),
             33,
             "Got the right value",
         )

``````````

</details>


https://github.com/llvm/llvm-project/pull/118814
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to