PDA

View Full Version : Step tracing in Xcode




Nimboz
Jul 24, 2009, 07:41 AM
Hi,

I'm an absolute beginner in C and have just started using Xcode recently. It works great, but one functionality I miss from the years old "Turbo C++" is tracing the steps on a keypress it would highlight which codeblock/statement will be executed in sequence. VERY VERY helpful for beginners like me to understand how things work.

I'm sure something similar must be available in XCode?

Thanks in advance.



robbieduncan
Jul 24, 2009, 08:23 AM
Set a debugger breakpoint. You can then step through the code one line at a time.

Nimboz
Jul 24, 2009, 08:27 AM
Set a debugger breakpoint. You can then step through the code one line at a time.

Erm..how to do that?

btw, in Turbo C, you don't have to set beakpoints, it just shows you how the compiler will execute the code step by step.

Many thanks

robbieduncan
Jul 24, 2009, 08:29 AM
I thought you might, you know, use the correct terms to look it up in the documentation.

Anyway here's the Debugging Guide (http://developer.apple.com/DOCUMENTATION/DeveloperTools/Conceptual/XcodeDebugging/000-Introduction/Introduction.html#//apple_ref/doc/uid/TP40007057-CH1-SW1) to help you.

Nimboz
Jul 24, 2009, 09:08 AM
I thought you might, you know, use the correct terms to look it up in the documentation.

Anyway here's the Debugging Guide (http://developer.apple.com/DOCUMENTATION/DeveloperTools/Conceptual/XcodeDebugging/000-Introduction/Introduction.html#//apple_ref/doc/uid/TP40007057-CH1-SW1) to help you.

Ok, it was easy: Right-click on the gutter.

"Built-in Breakpoints" is what I want I guess, will have to test each now.

whooleytoo
Jul 24, 2009, 11:45 AM
I don't know of any "Build and debug, and break on first line" option in Xcode.

It probably doesn't make much sense to have one, in your average Cocoa app, as the 'entry point' is a little vague. Where would the first "auto breakpoint" be? In main.m, you'd be stepping into assembly code in NSApplicationMain(). If the breakpoint was in applicationDidFinishLaunching, you might miss some other code block you wanted to debug before that.

Hence, it probably makes the most sense to set the first breakpoint yourself. If that's the only problem you're having with Xcode, you're doing well (a lot better than I did! :) )

Cinder6
Jul 24, 2009, 11:59 AM
You're starting to run into the difference between a CLI app and a GUI app. In CLI apps, your users wait for your program. In GUI apps, your program waits for your users. Because of this, you don't really know what's going to get executed first, aside from the stuff in main()--but that will be the same 99% of the time.