How to execute a block (identified by a pointer) from lldb

I am in the lldb debugger in an iOS simulator and I have an address for the block. I want to try to execute it. I tried the first thing that occurred to me (see below), but it did not work. Is there any 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 the call , but apparently this 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 understand that the first attempt failed, because po will not work with the return value of void, but the question still stands ...

+3
source share
1 answer

You need to indicate your number on the block pointer.

expr ((void (^)(BOOL,NSString*))0x2c7140)(NO, @"Test")
       |        |    |          |        |
  Return type  Argument types  Address  Call

( expris lldb replacement for call)

, , , lldb . expr, , - :

expr (void (^)(BOOL,NSString*))0x2c7140
expr $n(NO, @"Test")

$n - , , lldb. , $ " ", .

+10

All Articles