Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your <code>Data</code> looks like it is probably UTF-16. I made a quick C program that looks kind of like your question description and played around a little in the interactive Python interpreter. I think this might be enough to point you in the right direction for writing your own formatter?</p> <pre><code>int main () { struct String *mystr = AllocateString(); mystr-&gt;AllocatorInstance.len = 10; mystr-&gt;AllocatorInstance.Data = (void *) malloc (10); memset (mystr-&gt;AllocatorInstance.Data, 0, 10); ((char *)mystr-&gt;AllocatorInstance.Data)[0] = 'h'; ((char *)mystr-&gt;AllocatorInstance.Data)[2] = 'e'; ((char *)mystr-&gt;AllocatorInstance.Data)[4] = 'l'; ((char *)mystr-&gt;AllocatorInstance.Data)[6] = 'l'; ((char *)mystr-&gt;AllocatorInstance.Data)[8] = 'o'; FreeString (mystr); } </code></pre> <p>Using the <code>lldb.frame</code>, <code>lldb.process</code> shortcuts (only valid when doing interactive <code>script</code>), we can read the <code>Data</code> into a python string buffer easily:</p> <pre><code>&gt;&gt;&gt; valobj = lldb.frame.FindVariable("mystr") &gt;&gt;&gt; address = valobj.GetChildMemberWithName('AllocatorInstance').GetChildMemberWithName('Data').GetValueAsUnsigned() &gt;&gt;&gt; size = valobj.GetChildMemberWithName('AllocatorInstance').GetChildMemberWithName('len').GetValueAsUnsigned() &gt;&gt;&gt; print address 4296016096 &gt;&gt;&gt; print size 10 &gt;&gt;&gt; err = lldb.SBError() &gt;&gt;&gt; print err error: &lt;NULL&gt; &gt;&gt;&gt; membuf = lldb.process.ReadMemory (address, size, err) &gt;&gt;&gt; print err success &gt;&gt;&gt; membuf 'h\x00e\x00l\x00l\x00o\x00' </code></pre> <p>From this point you can do any of the usual python array type things - </p> <pre><code>&gt;&gt;&gt; for b in membuf: ... print ord(b) ... 104 0 101 0 108 0 108 0 111 0 </code></pre> <p>I'm not sure how you can tell Python that this is UTF-16 and should be internalized correctly as wide-chars, that's more a Python question than lldb question -- but I think your best bet here is to not use the <code>SBValue</code> methods (because your <code>Data</code> pointer has an uninformative type like <code>void *</code>, like I did in my test program), but to use the <code>SBProcess</code> memory read method.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload