<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Akos,<div>what do you mean by "it doesn't work too well"? Do you get any diagnostics?</div><div>A good debugging technique is to use the LLDB interactive script interpreter to repeat the steps in your script and check where you get issues such as empty or invalid objects (all our SB API objects have an IsValid() call on them).</div><div>To bootstrap yourself, you can use:</div><div>valobj = lldb.frame.FindVariable("<i>name of the variable to format here</i>")</div><div><br></div><div>At a glance I can see two issues here:</div><div><div><br></div><div></div></div><blockquote type="cite"><div><div> if valobj.GetValue() != 0:</div></div></blockquote><div><br></div><div>If your valobj is not a pointer, but a plain record, its value is going to be None (only scalars have values).</div><div>You might want to rephrase your check along the lines of:</div><div><br></div><div>if (valobj.TypeIsPointerType() == False or valobj.GetValue() != 0):</div><div><br></div><div>Also, I am pretty sure you do not need the GetPointeeData() calls here:</div><div><br></div><div><blockquote type="cite"><div> content = valobj.GetChildMemberWithName('content')</div><div> length = content.GetPointeeData(0,1).GetChildMemberWithName('length')</div><div> string = content.GetPointeeData(0,1).GetChildMemberWithName('string')</div></blockquote></div><div><br></div><div> You should be able to dereference the children of content by name even if content is a pointer.</div><div>GetPointeeData() is used when you have a pointer/array and you want to retrieve the byte values it points to/refers.</div><div>In your case, you want to retrieve a child of a variable and maintain the value-ness of whatever you get back - hence the SBValue returning calls are what you want/need.</div><div><br></div><div><div>As an aside,</div><div><br></div><div><div></div><blockquote type="cite"><div> data_val = string.GetPointeeData(i, 1)</div><div> newchar = data_val.GetUnsignedInt16(e, 0) # utf-16</div></blockquote><div><br></div></div>You should be able to get away with something along the lines of:</div><div><br></div><div>data_val = string.GetPointeeData(0,<i>length</i>) outside the while, and then access the individual uint16's as data_val.uint16[<i>index</i>]</div><div><br></div><div>This way you avoid generating a bunch of one-off SBData objects and keep the entire buffer around (of course, if your buffers are huge, the former solution might still be preferable).</div><div><br></div><div>Let me know if I can help you more with the script!</div><div><br></div><div><div><div style="border-collapse: separate; border-spacing: 0px; "><i>Enrico Granata</i></div><div style="border-collapse: separate; border-spacing: 0px; ">✉ egranata@<font class="Apple-style-span" color="#ff230e"></font>.com</div><div>✆ (408) 972-7683</div><div><br></div></div></div></body></html>