Step tracing in Xcode

Discussion in 'Mac Programming' started by Nimboz, Jul 24, 2009.

  1. macrumors newbie

    Joined:
    Aug 30, 2008
    #1
    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.
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Set a debugger breakpoint. You can then step through the code one line at a time.
     
  3. thread starter macrumors newbie

    Joined:
    Aug 30, 2008
    #3
    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
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    I thought you might, you know, use the correct terms to look it up in the documentation.

    Anyway here's the Debugging Guide to help you.
     
  5. thread starter macrumors newbie

    Joined:
    Aug 30, 2008
    #5
    Ok, it was easy: Right-click on the gutter.

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

    whooleytoo

    Joined:
    Aug 2, 2002
    Location:
    Cork, Ireland.
    #6
    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! :) )
     
  7. macrumors 6502

    Cinder6

    Joined:
    Jul 9, 2009
    #7
    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.
     

Share This Page