[FEATURE REQUEST] Add more breakpoint types to Xcode

There are many situations where debug breaking points are not the right tool. What I often need is a log that shows what gets called, with how much frequency, and in which order.

There are so many times where I have to add print statements, re compile, re run, see that I didn't include all the print statements I needed, and repeat a couple of times.

My proposal (with zero knowledge of technical feasibility), is that much like we have break points, add "print break points" for logging without modifying code.

It would be nice too, if I could also, add a "timer break point", where I can tag a function definition, and every time it gets called, it's are timed.

Again, no idea if this is possible, but it would be extremely helpful for me, and I'm guessing to many other devs as well.

Thoughts?

For the first thing you're asking about, what gets called and how often, you can use Instruments. It regularly samples your app so you can see where it is spending its time. It does not record the back trace at every sample point though.

To determine when particular routines are called, you can add signposts to your code. This can be more efficient than post-mortems of printf logs.

Signposts can also be used to time methods.

For "add "print break points" for logging without modifying code." you can add a breakpoint action which logs and automatically continues. You don't need to modify any code, and Xcode stores these breakpoints and their actions - you can even check them into source control if you want. Conditional breakpoints with actions aren't very quick though - they are faster than logging by hand, but they do affect the runtime of your program.

May I add that I believe you can do that right now. You can turn any standard breakpoint in Xcode into a non-stopping print breakpoint. By creating a standard breakpoint, edit Breakpoint to open the popover, then add action and select log message, then type your message. You can use variables and expressions here as well. However I prefer to use print statements for that.

Now, when you run your app, Xcode will print your custom log to the console every time that line is hit, but the app will never pause, and you never had to recompile.

Is that working? You can also edit both breakpoints, with automatically continue, and add a debugger command action instead of a log message.

Interested to see how you use the breakpoints.

If you want to know what gets called, with how much frequency, in which order, and how long it took without writing a single line of code, instruments time profiler is my go tool for that.

Albert
  Worldwide Developer Relations.

[FEATURE REQUEST] Add more breakpoint types to Xcode
 
 
Q