How can I create a LLDB alias that evaluates its argument using `expression`

alias, command, debugging, expression, lldb

Solution

To make arguments in expression work, use command regex instead of alias, like this:

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

For more details, see this answer.

Problem

I'm trying to create a LLDB `alias` that evaluates an `expression` using the argument (`%1`) to the `alias`. I've tried many, many different syntax combinations, but it seems like anything that uses `%1` in an `expression` fails to parse. ``` (lldb) version LLDB-112.1 ``` This works as expected: ``` (lldb) expr (char*) strdup(argv[1]) (char *) $23 = 0x000000010061c090 "--calc" ``` When I create an `alias` containing `%1` the example fails. ``` (lldb) command alias dup expr (char*) strdup(%1) (lldb) dup argv[1] error: expected expression error: 1 errors parsing expression ``` How can I create a LLDB alias that evaluates its argument using `expression`?

Original source

Related problems