https://bugs.llvm.org/show_bug.cgi?id=45988
Bug ID: 45988
Summary: SBValue.GetNumChildren() returns wrong value for
double indirections
Product: lldb
Version: 10.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: lldb-dev@lists.llvm.org
Reporter: ja...@google.com
CC: jdevliegh...@apple.com, llvm-b...@lists.llvm.org
SBValue::GetNumChildren seems to look through two pointer indirections, but
SBValue::GetChildAtIndex only through one.
If we have a value with pointer to a pointer to a struct, then GetNumChildren()
on that value will return the number of fields of the struct, but
GetChildAtIndex(0) will return the pointer to the struct and GetChildAtIndex(1)
will return the Invalid SBValue sentinel.
Repro:
```
$ cat a.cc
struct Inner
{
int a;
int b;
};
struct Outer
{
Inner *inner;
};
int main()
{
Inner inner{42, 56};
Outer outer{&inner};
return 0; // break here
}
$ cat a.py
import lldb
import os
debugger = lldb.SBDebugger.Create()
debugger.SetAsync(False)
target = debugger.CreateTargetWithFileAndTargetTriple("a.out",
"x86_64-pc-linux")
main_bp = target.BreakpointCreateByLocation("a.cc", 16)
process = target.LaunchSimple (None, None, os.getcwd())
thread = process.selected_thread
frame = thread.GetSelectedFrame()
print(frame.EvaluateExpression("&(outer.inner)").GetNumChildren())
print(frame.EvaluateExpression("&(outer.inner)").GetChildAtIndex(0))
print(frame.EvaluateExpression("&(outer.inner)").GetChildAtIndex(1))
$ python a.py
2
(Inner *) *$1 = 0x00007ffedf89e290
No value
```
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev