简体   繁体   English

Xcode 4:为什么“继续到当前行”显示为灰色?

[英]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. Xcode 3中 ,我可以通过将鼠标悬停在行号旁边单击按钮来做到这一点。

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. Xcode 4中 ,似乎可以通过右键单击行号并选择“ 继续至此处” (通过使用“ 调试”菜单并选择“ 继续到当前行”项)来实现。

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++ 注意,我不知道这是否相关,但是我正在使用c ++

Is there something I am doing wrong? 我做错什么了吗?



Thanks in advance, 提前致谢,

Kevin 凯文

It seems that this is because you are using the LLDB debugger. 看来这是因为您正在使用LLDB调试器。 As the same thing happens to me, whilst using the LLDB debugger and debugging C++ code, as you can see here: 正如我发生的一样,在使用LLDB调试器和调试C ++代码的同时,您可以在这里看到:

变灰继续LLDB和C ++

I tested this with Objective-C code, and this feature works perfectly fine whilst debugging Objective-C. 我用Objective-C代码进行了测试,并且此功能在调试Objective-C时效果很好。

继续使用LLDB和Objective-C

The green button you mentioned, for Xcode 3, also pops-up with Objective-C code (using Xcode 4). 对于Xcode 3,您提到的绿色按钮也会弹出带有Objective-C代码(使用Xcode 4)。 As you can see here: 如您所见:

绿色按钮

Perhaps it's a bug in Xcode, or Apple just wants you to program in Objective-C. 也许这是Xcode中的错误,或者Apple只希望您使用Objective-C进行编程。 It seems to be only an issue whilst using LLDB, and debugging C++ code (I am unsure of C code). 在使用LLDB和调试C ++代码时,这似乎只是一个问题(我不确定C代码)。 On the other hand, debugging with GDB works fine with both: C++ and Obj-C code. 另一方面,使用GDB进行调试可同时与C ++和Obj-C代码一起使用。

The only real options you have at the current time is: 您当前唯一的真实选择是:

Option 1: 选项1:

Use the GDB debugger instead, as the GDB debugger with Xcode supports this. 请改用GDB调试器,因为带有Xcode的GDB调试器支持此功能。

To change the debugger: 更改调试器:

Step 1: 第1步:

Click your project name under the Scheme Menu, in the top left. 在左上方的“方案”菜单下,单击您的项目名称。 步骤1-图1步骤1-图2

Step 2: 第2步:

Click "Edit Scheme..." 点击“编辑方案...”

步骤2-图1

Step 3: 第三步:

Once the Edit Scheme menu comes up, click the pop-up menu next to the "Debugger" option. 出现“编辑方案”菜单后,单击“调试器”选项旁边的弹出菜单。

步骤3-图1步骤3-图2

Step 4: 第四步:

Click the option "GDB" to use the GDB debugger. 单击选项“ GDB”以使用GDB调试器。

步骤4-图1步骤4-图2

NOTE: Once you click GDB, the "Debug Process As" option will be greyed out. 注意:单击GDB后,“调试过程为”选项将显示为灰色。

Step 5: 步骤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). 我不确定在LLDB上使用GDB调试器时的限制(我认为Xcode不支持GDB的任何最新版本,因为它们已切换到LLDB和clang)。

Option 2: 选项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. 假设您要继续直到打到第39行。

码

Set a breakpoint at line 39. 在第39行设置一个断点。

设置断点

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) 或者,您可以继续使用键盘快捷键:Command + Ctrl + Y,或使用菜单(产品->调试->继续)

继续执行程序按钮通过菜单继续

NOTE: 注意:

You need the Debug area shown (Shift-Command-Y), in order to see the "Continue program execution" button. 您需要显示的调试区域(Shift-Command-Y),才能看到“继续执行程序”按钮。

调试区

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM