Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Starting with Martin R answer I improved it as follow:</p> <ol> <li><p>If the pointer is not a simple variable, e.g.:</p> <pre><code>struct { int* at; size_t size; } a; </code></pre> <p>Then "parray a.at 5" fails.</p> <p>I fixed this by replacing "FindVariable" with "GetValueForVariablePath".</p></li> <li><p>Now what if the elements in your array are aggregates, e.g.:</p> <pre><code>struct { struct { float x; float y; }* at; size_t size; } a; </code></pre> <p>Then "parray a.at 5" prints: a.at->x, a.at->y, a.at[2], a.at[3], a.at[4] because GetChildAtIndex() returns members of aggregates.</p> <p>I fixed this by resolving "a.at" + "[" + str(i) + "]" inside the loop instead of resolving "a.at" and then retrieving its children.</p></li> <li><p>Added an optional "first" argument (Usage: parray [FIRST] COUNT), which is useful when you have a huge number of elements.</p></li> <li><p>Made it do the "command script add -f parray.parray parray" at init</p></li> </ol> <p>Here is my modified version:</p> <pre><code>import lldb import shlex def parray(debugger, command, result, dict): args = shlex.split(command) if len(args) == 2: count = int(args[1]) indices = range(count) elif len(args) == 3: first = int(args[1]), count = int(args[2]) indices = range(first, first + count) else: print 'Usage: parray ARRAY [FIRST] COUNT' return for i in indices: print lldb.frame.GetValueForVariablePath(args[0] + "[" + str(i) + "]") def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand('command script add -f parray.parray parray') </code></pre>
    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. 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