Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Thread specific breakpoints in Xcode?

I'm debugging a crash where a non-main thread uses UIKit drawing methods. I'd like to set a conditional breakpoint on -[UIView layoutSubviews] that only triggers, if it's executed in a non-main thread. Is this possible?

like image 948
Ortwin Gentz Avatar asked Dec 08 '10 10:12

Ortwin Gentz


1 Answers

You can set per-thread breakpoints using the gdb console. For example:

b -[UIView layoutSubviews] thread 2

(You use the gdb "info threads" commands to see what threads exist and what identifier gdb uses for them).

I don't think there's a way to set a breakpoint for every thread except the main thread (thread 1), but if you have a reasonable number of threads you could set breakpoints for each of them individually if necessary.


update:

If the per-thread thing isn't working out because of GCD, another approach you could take would be to just set a regular breakpoint, and set gdb commands for that breakpoint to dump out a backtrace ("where") and then "continue".

like image 185
David Gelhar Avatar answered Sep 22 '22 19:09

David Gelhar