<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 14, 2018, at 8:22 PM, Florin Trofin via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<br class=""><br class="">I came across the formatter example in unicode_strings.py where in utf16_summary() I see this code:<br class=""><br class=""><font face="monospace, monospace" class="">string_data = value.process.ReadMemory(pointer, length, error)<br class=""># utf8 is safe to emit as-is on OSX<br class="">return '"%s"' % (string_data.decode('utf-16').encode('utf-8'))</font><br class=""><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><font face="arial, helvetica, sans-serif" class="">I am trying to replicate that in my own formatter and I'm having difficulty converting the pointer to an addr_t which is what ReadMemory wants. In my case </font><font face="monospace, monospace" class="">pointer</font><font face="arial, helvetica, sans-serif" class=""> comes from:</font></div><font face="arial, helvetica, sans-serif" class=""><br class=""></font><font face="monospace, monospace" class="">self.rep.GetChildMemberWithName("__l").GetChildMemberWithName("__data_")<br class=""><br class=""></font><div class="">(this is a basic_string which has a union:</div><font face="monospace, monospace" class="">struct __rep<br class="">{<br class=""> union {<br class=""> __long __l; // Used for long strings<br class=""> __short __s; // Used for short strings - stores in place<br class=""> __raw __r; // ??<br class=""> };<br class="">};</font><br class=""><br class="">and __long is defined as:<br class=""><br class=""><font face="monospace, monospace" class="">struct __long {<br class=""> pointer __data_;<br class=""> size_type __size_;<br class=""> size_type __cap_;<br class="">};</font><div class=""><br class=""></div><div class="">So __data_ is a basic_string::pointer (plain C pointer).</div><div class=""><br class=""></div><div class="">How do I convert this pointer to the addr_t that I need? I believe that the <span style="font-family:monospace,monospace" class="">GetChildMemberWithName </span>returns an SBValue. I tried <font face="monospace, monospace" class="">pointer.GetPointeeData(0, 1).GetLoadAddress()</font> but I'm not getting the corect results.<br class=""></div></div></div></blockquote><div><br class=""></div>__data_ will contain the pointer value. Just do:</div><div><br class=""></div><div>pointer.<span style="font-size: 11px; background-color: rgb(255, 255, 255);" class="">GetValueAsUnsigned()</span></div><div><span style="font-size: 11px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div><span style="font-size: 11px; background-color: rgb(255, 255, 255);" class=""><br class=""></span><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class="">Thanks!<br class=""><br class="">Florin</div></div>
_______________________________________________<br class="">lldb-dev mailing list<br class=""><a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev<br class=""></div></blockquote></div><br class=""></body></html>