开发者

How to let the debugger stop anywhere?

Example: I run my app in the simulator. Then I want to figure out what exactly is going on when I touch a button. Normally I would first have to find out where the entry-point of all this madness is in order to place a breakpoint. But now lets assume my app has 700 classes and it's incredibly complex, with more than 12.000 methods. Chances are big I don't know at all where to put the breakpoint. Just in theory.

How can I make the debugger stop anywhere the next time something happens? I know I can switch it on/off while my app is running, whic开发者_JAVA技巧h is fine, but is there a way to make it behave like if every line in the app had a breakpoint on it? Hope you know what I mean. My english is horrible. Thank you.


What you need are symbolic breakpoints. For a brief explanation look here.


I am not sure if your requested technique is really usable in practice, but adding symbolic breakpoints on -[UIApplication sendEvent:] and/or -[UIApplication sendAction:to:from:forEvent:] will at least break when an event is triggered / an action is performed instead of trying to step through every line.

When it breaks, you can continue with the "step over" command as described in the other answer to find the relevant code sections. You can play around with other breakpoints that might come closer to what you are looking for.


...is there a way to make it behave like if every line in the app had a breakpoint on it?

It sounds like you're asking about the "step over" command. You set a single breakpoint so the app stops at a particular line. Then you can use the "step over" command to move over each subsequent line of code. This lets you watch each line execute in detail.

You can't run the entire app line by line because the debugger has to logically follow every command including those from the compiled libraries. If you tried to follow every command from launch it would take you several hours of wading through assembly just to get to the initial view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜