iPhone Dev: Xcode debugger does not stop on breakpoints

◇◆丶佛笑我妖孽 提交于 2019-11-28 05:26:33

I cannot find 'GCC 4.0 - Code Generation' options anywhere. I've looked hi and low in both Target and Executable Info pages. The only option I see is to select the compiler version, and GCC 4.0 is selected, but that is a one-line section with no additional options.

That's an Xcode bug in 3.1.1 and 3.1.2 if the Active SDK is out of synch with the target's Base SDK. Set the Target's Base SDK to Simulator, make sure your Active SDK is Simulator, and try again.

If you really want this answered, you're going to have to post more information about your project: a screen shot of the Build Settings, or text from the Debugger Console.

UPDATED: Also note in Xcode > Preferences > Debugging: alt text http://idisk.mac.com/cdespinosa/Public/GDB%20Log.png

Check the box, enter a reasonable path into the path field, try your debug scenario, then file a bug at http://bugreporter.apple.com with the log attached and a description of your scenario, or ask the good people over at xcode-users@lists.apple.com. The gdb log contains all the information about how the debugger is interacting with your application.

oldbeamer

In the Xcode preferences go into the debugging section and turn off 'Load symbols lazily'.

That fixed it for me a few months ago when I first run into this problem.

This is sort of a "is it plugged in" answer, but hey, sometimes that is the problem: Are breakpoints enabled? Sometimes when I debug, I forget to click the button in the debugging toolbar that enables and disables breakpoints.

The GCC 4.0 - Code Generation section only shows up when you set the Active SDK to Device - iPhone OS 2.x. Go figure. They disappear when the Active SDK is the simulator.

You should change your Active SDK to Device, change the settings, and then change back to Simulator. The settings made under Device should also hold for Simulator. This also works with eg. setting a -DDEBUG flag for preprocessing.

(Update: I was only half right. See Chris Espinosa's accepted answer re: this SDK bug. It's not that the GCC 4.0 section shows up when the Active SDK is set to "Device," it's that your Base SDK and Active SDK must match up to access these settings).

Benjamin Autin

Another simple suggestion:
Are the breakpoints light blue are dark blue?

Xcode allows you to deactivate breakpoints and these are indicated with a light blue arrow (like it has been dimmed).

Try running the project by hitting Command-Option-Y (this forces Xcode to start the program with the debugger).

The buttons on the menu bar of Xcode can be somewhat misleading. If the button says 'Run', it doesn't run the program in the debugger. If it says 'Go' it runs the program however it was last built (ie release or debug). Command-Option-Y starts the program specifically in the debugger.

Also, make sure your breakpoints are enabled. You can right click on them to check. Also, in the Debugger window, there should be an option on the toolbar for Activate or Deactivate Breakpoints. Make sure they're activated.

This may be an exceptionally obvious answer, but it could work. Have you tried adding breakpoints in code other than main() ? For instance, in the App Delegate's applicationDidFinishLaunching method? I know it SHOULD go through main first, but since that code in main is not normally modified for iPhone apps, it might be a bit flaky. It's worth a try, anyway.

Also, to find the GCC 4.0 - Code Generation options, click the triangle to open the Targets group, and click on your app's name underneath Targets. Click on the Info button up in the top of the Xcode window and you'll get the settings for your app. Go to Build. Make sure the Show: dropdown is set to All Settings. If you scroll down from there, it should be one of the lists you can edit (after Versioning and before GCC 4.0 - Language)

When the program is running, can you do a CTRL-C in the Console window (while cursor is there). If you interrupt the program type info br which should give a list of the active breakpoints, question then is, are they what you set?

There are two gdb configuration files that can be good to have a look at.

  • /etc/gdb.conf

Mine have MD5 (/etc/gdb.conf) = 31b58e1ecf038554faadf777d63e9085

  • ~/.gdbinit

I have no, do you have one?

Have you verified that your build configuration is using your development certificate for code signing?

If you are using an Ad Hoc certificate, it'll still build and run fine, but shortly after launching the app, Xcode will detach from the device so no breakpoints will ever hit. You can quickly tell whether it has detached or not if you look in the bottom left of the main Xcode window after you've clicked Build & Go - if you aren't using the actual development device certificate, you'll see a message that says something like "Invalid Hex Code Received from Device".

I looks like you are running the program as root, that doesn't seem to be right...

In your build setting list, you don't cover the most crucial one:

alt text http://idisk.mac.com/cdespinosa/Public/Generate%20Debug%20Symbols.png

Make sure Generate Debug Symbols is checked for the Debug configuration, and make sure that the Debug configuration is active when you Build and Debug.

Two other things to try:

1) Uncheck Fix and Continue. Your detailed gdb log indicates that it may be on. Make sure you are looking at the target settings and not the project settings when confirming this.

2) Try not running as root. It's unclear why you need to. It is possible that Xcode running as root has interactions with the simulator; frankly we don't use that configuration much so I wouldn't know.

The log shows everything operating pretty normally. You have a built binary that's being launched in the Simulator; it's the right architecture and well-formed; you have debug symbols; you have a breakpoint, and the breakpoint is being set. We're taking your word for it (as we don't see your source) that the breakpoint is actually on a line of code that is being executed.

If you are using an Ad Hoc certificate, it'll still build and run fine, but shortly after launching the app, Xcode will detach from the device so no breakpoints will ever hit.

This helped me.

I have to ask, as I had the same problem, is this a 'real' mac? There is this exact problem with the voodoo hacintosh kernal. If you are using the voodoo kernal, boot with std_dyld=1 and all will be well

This really works on voodoo kernel, booting with std_dyld=1 make Xcode stop at breakpoint. Amazing tip, really. Many thanks to you John your a kind of life saver !!! I used OSX86Tools to add this boot flag automatically. Polo

I tried pretty much everything in this thread and restarting the device solved my problem.

I just had the same problem. I don't have a real solution yet, but I figured out, that in my case it is device dependent. The error only happens on my iPod Touch 4G. When I switch to my iPhone 3G, everything works fine and the breakpoints work again.

I don't know if this has anything to do with the problem, but may be the iPod4 has problem due to the installed iOS 5 beta 2. Usually when I encounter a bug in iOS 5 it's fine to just reboot the device. However... rebooting the iPod4 didn't help in my case...

Solution:

This problem bugged me now for some weeks, but I finally found a solution for my case:

  1. Make sure the SDK on your Mac is the same (or newer) as the iOS version on your device.
  2. Reboot the device while it is connected via USB and Xcode is running.

I had a similar situation.. after 6 hours of debugging and project file comparison, it finally worked. The situation was I had a 2 year old project originally made in Xcode 3.1 days. I tried to run it in Xcode 4.5.1 with breakpoints and it never worked.

Here is what I did to fix it..

1) In the Project>Build Settings.. Search for Debug. 2) Build active Architecture only > Change Debug to Yes 3) Generate Debug Symbols > Yes 4) Preprocessor Macros > Debug = 1

It runs fine now.

Apple should really improve the overall Xcode experience. I understand its free (hey, you get what you pay for), but still, the bugs in it is almost insulting to developers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!