使用特定队列调用dispatch_async时的符号断点
我正在调试项目中涉及中央集中调度的问题.在调试时,有一种在将工作分派到特定队列时得到通知的方式确实很有帮助.
I'm debugging an issue in my project involving grand central dispatch. In debugging this, it would be really helpful to have a way of being notified when work is dispatched to a specific queue.
是否有某种方法可以在dispatch_async
上设置符号断点,并且可以检查调度队列参数是否与我可以访问的其他队列相同?
Is there some way of setting a symbolic breakpoint on dispatch_async
with a condition that could check whether the dispatch queue argument is the same as some other queue that I have access to?
以下是设置条件断点的方法. (我尚未在队列上完成条件,我在这里假设指针相等将可以正常工作.)
Here's how to set a conditional breakpoint. (I haven't done conditions on queues, I'm making the assumption here that pointer equality will Just Work™.)
首先获取所需队列的地址,假设它是0x12345678
.然后创建一个断点:
First get the address of the queue you want, let's say it's 0x12345678
. Then create a breakpoint:
breakpoint set -n dispatch_async -c '$register == 0x12345678'
用特定于该体系结构的表达式替换$register
.
Replace $register
with an expression specific to the architecture.
已更新为从模拟器
- x86:
*(id*)($esp+4)
- x86-64:
$arg1
(又名$rdi
)
- x86:
*(id*)($esp+4)
- x86-64:
$arg1
(aka$rdi
)
设备
- armv7:
$arg1
(又名$r0
) - arm64:
$arg1
(又名$x0
)
- armv7:
$arg1
(aka$r0
) - arm64:
$arg1
(aka$x0
)