Search code examples
lldb

Inject variable value in lldb command


Is it possible to do that with lldb:

(lldb) p my_var
(uint64_t) $9 = 2
(lldb) set set target.max-children-count 4

But instead of 4, I would like to call the set command with the current value of my_var, in this case 2.


Solution

  • In most lldb commands, backtick blocks are evaluated and the result substituted in their place. For instance,

    (lldb) sett show stop-line-count-before
    stop-line-count-before (int) = 3
    (lldb) p 5
    (int) $1 = 5
    (lldb) sett set stop-line-count-before `$1`
    (lldb) sett show stop-line-count-before
    stop-line-count-before (int) = 5