Search code examples
c++debuggingxcode4

Xcode 4: why "Continue to current line" is grayed out?


When I am debugging my program, I often want to make it run from where it is paused to a specific line.

In Xcode 3, I was able to do that by clicking on the button appearing next to the line number when hovering it.

In Xcode 4, it seems to be possible to do that either by right clicking on the line number and select Continue to here, either by using the Debug menu and choose Continue To Current Line item.

However these options are always grayed out when I want to use them.

Note, I don't know if this is relevant but I am using c++

Is there something I am doing wrong?



Thanks in advance,

Kevin


Solution

  • It seems that this is because you are using the LLDB debugger. As the same thing happens to me, whilst using the LLDB debugger and debugging C++ code, as you can see here:

    Greyed out Continue Here with LLDB and C++

    I tested this with Objective-C code, and this feature works perfectly fine whilst debugging Objective-C.

    Continue Here with LLDB and Objective-C

    The green button you mentioned, for Xcode 3, also pops-up with Objective-C code (using Xcode 4). As you can see here:

    Green Button

    Perhaps it's a bug in Xcode, or Apple just wants you to program in Objective-C. It seems to be only an issue whilst using LLDB, and debugging C++ code (I am unsure of C code). On the other hand, debugging with GDB works fine with both: C++ and Obj-C code.

    The only real options you have at the current time is:

    Option 1:

    Use the GDB debugger instead, as the GDB debugger with Xcode supports this.

    To change the debugger:

    Step 1:

    Click your project name under the Scheme Menu, in the top left. Step 1 - Fig 1 Step 1 - Fig 2

    Step 2:

    Click "Edit Scheme..."

    Step 2 - Fig 1

    Step 3:

    Once the Edit Scheme menu comes up, click the pop-up menu next to the "Debugger" option.

    Step 3 - Fig 1 Step 3 - Fig 2

    Step 4:

    Click the option "GDB" to use the GDB debugger.

    Step 4 - Fig 1 Step 4 - Fig 2

    NOTE: Once you click GDB, the "Debug Process As" option will be greyed out.

    Step 5:

    Click OK.

    NOTE:

    I'm not sure about the limitations whilst using the GDB debugger, over LLDB (I think Xcode does not support any recent versions of GDB, as they have switched to LLDB and clang).

    Option 2:

    Create a breakpoint to where you wish to continue, and then continue to it. It really isn't that hard compared to right clicking and pressing "Continue Here" or the green button. This also provides the same functionality. With the use of keyboard shortcuts it could be just as fast (see below).

    For example:

    Say you want to continue until you hit line 39.

    Code

    Set a breakpoint at line 39.

    Setting a breakpoint

    Click "Continue program execution" button, which is the button that likes some-what like a media-play button. Alternatively you can continue using the keyboard shortcut: Command + Ctrl + Y, or use the Menu (Product->Debug->Continue)

    Continue program execution button Continue through menu

    NOTE:

    You need the Debug area shown (Shift-Command-Y), in order to see the "Continue program execution" button.

    Debug Area