breakpoints not breaking in xcode

When I set breakpoints in xcode by clicking in the gutter, the code runs right by them and does not stop. I am in debug mode, so it is not something that simple. When i start the code all the breakpoints turn orange. Is there some setting or something I need to enable to get breakpoints to work?

Powerbook g4 667

Posted on Dec 18, 2006 10:53 AM

Reply
11 replies

Dec 18, 2006 2:04 PM in response to Alex Barrie

Hi Alex,

This may be a simple case of missing the obvious so please forgive me if you've already tried this.

Under the build menu, there is an option for build and debug (Command + Y) which is also accessible via the toolbar by click and holding the hammer with the green play symbol. This build option will allow your breakpoints to function.

It sounds to me that you are choosing build and run which will test your program but not use breakpoints.

Martin.

Dec 18, 2006 4:36 PM in response to Martin Buck

Like Alex, I have problems with gdb not stopping at some of the breakpoints I set. I do recognize the difference between Build&Run and Build&Debug, and I am using the latter. Sometimes the debugger stops where I put a breakpoint, sometimes it stops, but on a different line, sometimes it doesn't stop at all, and sometimes it won't let me place a breakpoint on the line I want.

As one would guess, it helps to write one statement per line, break up complex statements, and expand macros. Even so (and also turning off code optimization), I still find that a lot of my breakpoints just won't work. And then, there are the frequent occasions on which the debugger stops at a breakpoint but then dies and gives me no useful information, or shows a nonrecursive function calling itself, or tells me a variable is out of scope when it clearly should be IN scope.

Frankly, I waste less time creating my own debugging statements than trying to figure out what gdb is doing. That's disappointing, and I wonder if there are some good resources on learning to use Xcode/gdb more effectively? Is there, for instance, a reference that explains messages like "Frame identical to previous; corrupt stack?" and provides some hints on what classes of bug are likely to elicit particular error or crash modes?

PowerBook Mac OS X (10.4.8)

Dec 20, 2006 12:29 PM in response to ousel

Auto-vectorization only takes effect if the optimization level is 2 or higher so setting the optimization level to 0 turns off auto-vectorization. Regarding the other build settings you mentioned, turning them off wouldn't hurt during debugging, but most of those settings are turned off initially so they are normally not a problem. Setting the optimization level to 0 is the most important thing you can do to get the results you want when debugging.

Mac OS X (10.4)

Dec 20, 2006 2:05 PM in response to Mark Szymczyk

I am in debug mode, not run mode. I tried cleaning all the targets and rebuilding them and that did not fix the problem.

I did some playing around and here is a more detailed description of the problem:

If I run the code, pause it real fast and set a breakpoint anywhere in the code from the debug window when the code is paused then all my breakpoints work. If I then remove that breakpoint that I set in the debug window while the code was paused then none of my other breakpoints that I set in the editor window will work anymore.

Some other information that may or may not be relevant: It is a large project with a bunch of targets that compile into static libraries. the main code then links together all those libraries and code from one library might access code in another.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

breakpoints not breaking in xcode

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.