[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue through new member property (PR #118814)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Sat Dec 7 11:37:58 PST 2024


================
@@ -29,6 +29,19 @@ STRING_EXTENSION_OUTSIDE(SBValue)
             '''An accessor function that returns a children_access() object which allows lazy member variable access from a lldb.SBValue object.'''
             return self.children_access (self)
 
+        def get_member_access_object(self):
+            '''An accessor function that returns an interface which provides subscript based lookup of child members.'''
+            class member_access:
+                def __init__(self, valobj):
+                    self.valobj = valobj
+
+                def __getitem__(self, key):
+                    if isinstance(key, str):
+                        return self.valobj.GetChildMemberWithName(key)
+                    raise TypeError("invalid subscript key")
----------------
kastiglione wrote:

I changed it to `member key must be a string`. Since the error is only raised when the key is not a string (a dynamic type check), I left out the semantic part of your suggested message.

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


More information about the lldb-commits mailing list