================
@@ -23,6 +23,13 @@ STRING_EXTENSION_OUTSIDE(SBValue)
if -count <= key < count:
key %= count
return self.sbvalue.GetChildAtIndex(key)
+ elif isinstance(key, str):
+ if child := self.sbvalue.GetChildMemberWithName(key):
+ return child
+ # Support base classes, which are children but not members.
+ for child in self.sbvalue:
+ if child.name == key:
+ return child
----------------
clayborg wrote:
NOTE: Base classes will only be returned by `GetChildAtIndex(N)` if they have
something to show the user, i.e. they have instance variables or have base
classes that have instance variables. If a base class has no ivars, it will not
be returned. So if we are looking for a reliable way to get base classes, it is
better to use the exsting APIs on `lldb.SBType`.
The other thing is, do we want to add a `SBValue.__get_item__(self, arg)`
method to easily access base classes or members where we just return the value
of `SBValue.GetChildAtIndex(...)`? Then we can do:
```
var = lldb.frame.FindVariable('my_struct')
first_child = var[0]
```
Instead of:
```
first_child = None
if (len(value.bases) > 0)
first_child = value.bases[0]
else:
first_child = value.members[0]
```
https://github.com/llvm/llvm-project/pull/118814
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits