I can't get this simple LLDB alias to work

后端 未结 1 569
忘掉有多难
忘掉有多难 2021-01-06 08:56

I want to create an LLDB alias ps, such that

 ps foo

becomes

 print [self foo]

I\'ve been watching the L

相关标签:
1条回答
  • 2021-01-06 09:16

    It seems arguments (%1, %2, etc) doesn't work to alias an expression. There is a workaround by using a regular expression instead:

    command regex ps 's/(.+)/print [self %1]/'
    

    It makes an alias ps for the above regular expression:

    (lldb) ps firstName
    print [self firstName]
    (NSString *) $1 = 0x06e64e20 @"John"
    

    However this will last till the debug session ends. You'll have to enter it again for the next debug session. If you want your ps command to persist through debug sessions, you'll have to save it in your ~/.lldbinit file (if it doesn't exist, create one).

    See llvm blog for more deails about regex command.

    0 讨论(0)
提交回复
热议问题