<div dir="ltr">I was recently using lldb to connect to a debug build of ruby to inspect the heap. In order to do this I was doing something like this<div><br></div><div>-----------</div><div>heaps_used = lldb.frame.EvaluateExpression('ruby_current_vm->objspace->heap_pages.used').GetValueAsUnsigned(0)<br>
</div><div><div> </div><div>for i in xrange(heaps_used):</div><div> page = lldb.frame.EvaluateExpression('*ruby_current_vm->objspace->heap_pages.sorted[%i]' % i)</div></div><div>-----------</div><div><br>
</div><div>What I noticed was that for each EvaluateExpression a temporary $0, $1, $2, etc.. variable is created. If I ended up calling my python code multiple times more and more variables seemed to pile up and every EvaluateExpression call seemed to take longer and longer.</div>
<div><br></div><div>I tried calling EvaluateExpression how I would call expr from the lldb command line setting my own variable, so something like</div><div><br></div><div>lldb.frame.EvaluateExpression('int $test = 5')</div>
<div><br></div><div>But that seemed to error out. So is there some other way in the API that is better for accessing global variables that won't slow down. Is this something actually wrong with the debugger? I can create an actual test case similar to the test suite in lldb if that would be helpful.</div>
<div><br></div><div>Thanks,</div><div>Scott Knight</div><div><br></div></div>