How can I create an LLDB alias that evaluates its argument using the expression

I am trying to create an LLDB aliasthat evaluates expressionusing the ( %1) argument to alias. I tried many different syntax combinations, but it looks like everything that uses %1in expressioncannot be parsed.

(lldb) version
LLDB-112.1

This works as expected:

(lldb) expr (char*) strdup(argv[1])
(char *) $23 = 0x000000010061c090 "--calc"

When I create alias, containing %1, the example does not work.

(lldb) command alias dup expr (char*) strdup(%1)
(lldb) dup argv[1]
error: expected expression
error: 1 errors parsing expression

How to create an alias LLDB that evaluates its argument using expression?

+3
source share
3 answers

To use the arguments in an expression, use the regex command instead of an alias, for example:

command regex dup 's/(.+)/expr (char*) strdup(%1)/'

. .

+3

% 1, . , , :

[. Lldbinit]

command alias foo expr fooFunction(

fooFunction :

(lldb) foo bar)

; , .

0

try command alias dup expr - (char *) strdup ($ 1); then you will see

(lldb) dup "2387987"
(const char [8]) $5 = "2387987" {
  (const char) [0] = '2'
  (const char) [1] = '3'
  (const char) [2] = '8'
  (const char) [3] = '7'
  (const char) [4] = '9'
  (const char) [5] = '8'
  (const char) [6] = '7'
  (const char) [7] = '\0'

for lldb build 153

0
source

All Articles