I'm in the lldb debugger within the iOS simulator and I have the address for a block. I want to try to execute it. I tried the first thing that came to mind (see below) but it didn't work. Is there a way to do this?
(lldb) po 0x2c7140
(int) $2 = 2912576 <__NSGlobalBlock__: 0x2c7140>
(lldb) po 0x2c7140(NO, @"Test")
error: called object type 'int' is not a function or function pointer
I also tried call but apparently that is not a command in llvm? It was available in gdb.
(lldb) call (void)0x2c7140(NO, @"Test")
error: 'call' is not a valid command.
I realize just now that the first attempt would have failed anyhow since po isn't going to work with a void return value, but the question still stands...
You need to cast your number to a block pointer.
(
expr
is lldb's replacement forcall
)I have not actually tested that this works, but have confirmed that lldb recognizes the cast. You may need to split it into two
expr
commands, one to do the cast and one to do the call:where
$n
is the identifier given to the result of the first expression, which will be a part of lldb's output. I believe you can simply use$
to mean "the previous result", but have not tested this.