Xcode breakpoints shifted at runtime - xcode

I have been searching for an hour or so here and on Google and cant find the answer as to how correct breakpoints being shifted during run. I have reinstalled Xcode(3.2.2), insured load lazily is off, no optimization in target settings, and every other target setting that might cause the problem. I have also destroyed all of the user project files (except for the main .pro file) and nothing seems to correct this. Yes, I am running with breakpoints on. Yes, I have done clean builds.
When I set a breakpoint, in the debugger the break stops two or 3 (or more lines) down in the source code, single stepping continues to show the wrong line. Also, in the debugger window the dark blue breakpoint symbol is gone, it does appear in an editor window.
This is driving me batty.

I had a similar problem (weirdly shifted breakpoints) but my issue turned out to be that I had the wrong target set, so the code I was modifying and setting breakpoints on wasn't even being rebuilt! But the executable would still run, using the old code, leading to what appeared to be oddly shifted breakpoints.

Sometimes Xcode gets confused about line numbering when your source files have inconsistent line endings, e.g. because you've been using different editors and may have a mixture of different line endings in your source file. You can use a tool like BBEdit or its free sibling TextWrangler to fix this problem.

With-in "Build Settings" under the project target change the "Optimization Level" for "Debug" to "None".
I found that this fixed the issue for me.

Related

How do I disable line centering in Intellij Idea Debugger?

When debugging program in Idea (I'm using 14.1.5 Community Edition), it attempts to put the line I'm currently on close to the center of the screen. And it does so every single step. However, I find this default behavior very annoying, it looks like the code is jumping around.
I wonder if there a way to customize the debugger view in a way that the code would be fixed (as long as I'm not leaving one screen of code) and the current line highlighting would be moving around? (I didn't find it in the Debugger section of the settings.)
Many thanks.
You want to disable "Focus application on breakpoint" which is in the settings under Build,Execution, Deployment > Debugger - it's the first checkbox. It's help documentation reads:
If this check box is selected, on hitting a breakpoint, IntelliJ IDEA will show the location of this breakpoint in the editor and will attempt to bring its frame to the front.
This should do the trick.

Why would Xcode stop drawing tabs when indent level is greater than three?

For some reason Xcode 4.5 and 4.4.1 have both stopped displaying indented text at the proper level if there are more than three Tab characters of leading whitespace on the lines.
Easier to show than describe:
There are five leading tabs on the line the arrow is pointing to, but Xcode is drawing it as if there were only three. Using the left and right arrow keys confirms the Tabs are there.
I have deleted the derived data associated with my projects, deleted the project.xcworkspace file and xcuserdata directories within the project package, mucked around with various combinations of Indentation settings in Xcode's Preferences, all to no avail.
Newly created projects exhibit the same behavior. Changing the Source Editor font preferences have no effect either. This is in OS X 10.8.1.
Help -- my brain can't understand the code when it doesn't "look right"! What else can I try?
So, I filed a Radar, then heard back from a friend of mine who was having the same problem. Are you using the new SourceCode Pro font from Adobe? Your screenshot makes it look like you might be. Try switching back to a different theme and restarting Xcode? That's what I did, and it seems to be fine.
Eventually I removed (after quitting Xcode) the entire UserData folder in ~/Library/Developer/Xcode and that seems to have fixed the problem.
Hopefully it won't take more than another half hour to restore all the key equivalents and syntax coloring that I am accustomed to.
Leaving the question 'alive' in case it happens to someone else.

Breakpoints in XCode debugger

I don't understand what's going on with the XCode debugger. I am using Xcode 3.1.2 and GCC 4.0 on 10.5. Sometimes, Occasionally, I test a C++ program, all active breakpoints become disabled. No breakpoints are taken - the program runs to completion. The dark blue breakpoint icons change to light blue or yellow with a blue border. Looking at the breakpoints list (CMD-Opt-B ) after the change, the breakpoints that were tagged with a checkmark are now tagged with a hyphen. (how do I get a "checkmark" icon with markdown?)
This is after they have been functioning normally. Sometime later, they will usually begin functioning normally again. I don't know what is responsible for either change. I have closed/reopened the debugger, files, and the full project. Most often, the proper beakpoint status is restored when I trivially change a source file and do a "Build & Debug" (Cmd-Y), but that doesn't always fix things
I have seen the reports of problems about "GLIBCXX_DEBUG_" here and elsewhere. That isn't my problem because I am using GCC 4.0, and don't use those flags. I have also seen reports of a similar problem with a really old XCode. Again, I don't believe that applies to me. Any ideas?
When the breakpoint markers turn yellow it means that you have more than one program being actively debugged by GDB. Try exiting all the programs except for the one you are currently debugging.
A yellow breakpoint symbol indicates the breakpoint is not loaded into the debugger. This can happen if you have more than one project running is what the previous answer was implying. Can also go yellow if you Run with breakpoints off instead of on.

Xcode Debugger: Why is it only showing me assembler?

I'm just starting out with Cocoa development in Xcode, doing the hello world example. I'm up to step 6 of the section "runtime debugging", which is
Using the Step Over button in the debugger toolbar, begin stepping through the code. As each line of code executes, you can examine the program’s state. The value of a variable is sometimes drawn in red to indicate that the value was modified in the last step.
Notice that the debugger pauses before executing the indicated line. After each pause, you can add additional breakpoints or choose Debug > Restart to terminate the application and start a new debugging session.
now what I've been pulling my hair out for over the last hour is the fact that this debugger will only show me assembly code. I can manually select my source code file, but as soon as I click "Step over" I'm right back in assembler view. I can't for the life of me figure out how to turn the assembler off, and make it show me my source code!
I know this article is a hundred years old, but in case anyone is wondering how to address this issue in more recent Xcode versions (as opposed to Xcode 3), you'll find the appropriate setting labeled Always Show Disassembly under Debug>Debug Workflow in Xcode 6 and up. Ensure the option is NOT checked.
In Xcode 5, the option was labeled Show Disassembly When Debugging under Debug>Debug Workflow. Ensure that "Show Disassembly When Debugging" is unchecked.
Back in Xcode 4, the Show Disassembly When Debugging setting was found under Product>Debug Workflow. Again, ensure that the option remains unchecked.
This was driving me crazy, too.
NOTE: The information above is still valid for Xcode 14+. I've applied updates to this answer as new versions of Xcode have been released. Fortunately, the option has remained unchanged since Xcode 6 (so far).
There are two other things to make sure of:
That you're looking at one of your own functions/methods. If the stack frame you're looking at is a function or method from one of the frameworks, you're going to see assembly no matter how you have Xcode configured.
That you are running a Debug build. Strip debug symbols (as in a Release build), and you'll be looking at assembly even for your own code, no matter what.
I actually figured this out before I posted, but I wanted to save others potential future headaches, (and also in case I forget later) as I could not find the answer to this by searching stack overflow, but I did find that I'm not alone.
From the run menu, select "Debugger Display" > "Source Only", or "Debugger Display" > "Source and Disassembly"

Why aren't Xcode breakpoints functioning?

I have breakpoints set but Xcode appears to ignore them.
First of all, I agree 100% with the earlier folks that said turn OFF Load Symbols Lazily.
I have two more things to add.
(My first suggestion sounds obvious, but the first time someone suggested it to me, my reaction went along these lines: "come on, please, you really think I wouldn't know better...... oh.")
Make sure you haven't accidentally set "Active Build Configuration" to "Release."
Under "Targets" in the graphical tree display of your project, right click on your Target and do "Get Info." Look for a property named "Generate Debug Symbols" (or similar) and make sure this is CHECKED (aka ON). Also, you might try finding (also in Target >> Get Info) a property called "Debug Information Format" and setting it to "Dwarf with dsym file."
There are a number of other properties under Target >> Get Info that might affect you. Look for things like optimizing or compressing code and turn that stuff OFF (I assume you are working in a debug mode, so that this is not bad advice). Also, look for things like stripping symbols and make sure that is also OFF. For example, "Strip Linked Product" should be set to "No" for the Debug target.
In Xcode 7, what worked for me was:
Make sure that the Target > Scheme > Run - is in Debug mode (was Release)
Make sure to check the option "Debug executable":
Go to the Xcode Debugging preferences.
Make sure that "Load Symbols lazily" is NOT selected.
I was just having this same issue (again). After triple-checking "Load symbols lazily" and stripping and debug info generation flags, I did the following:
quit Xcode
open a terminal window and cd to the project directory
cd into the .xcodeproj directory
delete everything except the .pbxproj file (I had frank.mode1v3 and frank.pbxuser)
You can accomplish the same task in finder by right/option-clicking on the .xcodeproj bundle and picking "Show Package Contents".
When I restarted Xcode, all of my windows had reset to default positions, etc, but breakpoints worked!
One of the possible solutions for this could be ....go to Product>Scheme>Edit scheme>..Under Run>info>Executable
check "Debug executable".
For Xcode 4.x:
Goto Product>Debug Workflow and uncheck "Show Disassembly When Debugging".
For Xcode 5.x
Goto Debug>Debug Workflow and uncheck "Show Disassembly When Debugging".
Another reason
Set DeploymentPostprocessing to NO in BuildSettings - details here
In short -
Activating this setting indicates that binaries should be stripped and
file mode, owner, and group information should be set to standard
values. [DEPLOYMENT_POSTPROCESSING]
See this post: Breakpoints not working in Xcode?. You might be pushing "Run" instead of "Debug" in which case your program is not running with the help of gdb, in which case you cannot expect breakpoints to work!
Issue
Background
Xcode: 13.0
code: Objective-C
Issue: added breakpoint, but not work
(possible) Reason and Solution
Reason: Xcode bug
Solution: Product ->Clean Build Folder, then retry debug (multiple time)
Reason: disabled Debug
Solution: enable it: Product->Scheme->Edit Scheme->Run->Info
Build Configuration set to Debug
choose/select/enable: Debug executable
Reason: disabled all breakpoint
Solution: enable it: Debug panel -> click breakpoint icon
Reason: debug info be optimized
Solution: not optimize
click Project -> Build Settings -> Apple Clang - Code Generation -> Optimization Level -> Debug make sure is None[-O0]
Related
XCode's Symbolic breakpoint not work
Background
XCode crash log
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument'
add XCode symbolic breakpoint
-[__NSCFConstantString stringByAppendingString:]:
but breakpoint not working
Solution
change to:
-[NSString stringByAppendingString:]
related doc: stringByAppendingString:
Solution for me with XCode 9.4.1 (did not stop at any breakpoint):
Under build Target -> Build Settings -> Optimization Level:
Switched from "Optimize for speed" -> "No optimization" (now it's slower but works)
What solved it in my case was quite simple, in Xcode - Product - Clean Build Folder followed by Product - Run (not the Play Xcode button).
(Had the issue on Xcode 11 -beta 4 after switching to unit testing with Xcode play button long press)
This had me in Xcode 9 for half a frustrating day. It ended up been a simple debug setting.
Go Debug > Debug Workflow and make sure 'Always Show Disassembly' is turned off. Simple as that. :(
Came to this page with the same problem (C code in Xcode 6 not stopping at breakpoints) and none of the solutions above worked (the project was practically out of the box, settings-wise, so little chance for any of the debugger settings to be set to the wrong value)...
After wasting quite some time reducing the problem, I finally figured out the culprit (for my code):
Xcode (/LLVM) does not like Bison-style #line preprocessor commands.
Removing them fixed the problem (debugger stopped at my breakpoints).
For Xcode 4:
go Product -> Debug -> Activate Breakpoints
This is applicable for all Xcode version. Shortcut key is: command key + Y. Press this key combination to activate/deactivate breakpoints.
I have a lot of problems with breakpoints in Xcode (2.4.1). I use a project that just contains other projects (like a Solution in Visual Studio). I find sometimes that breakpoints don't work at all unless there is at least one breakpoint set in the starting project (i.e. the one containing the entry point for my code). If the only breakpoints are in "lower level" projects, they just get ignored.
It also seems as if Xcode only handles breakpoint operations correctly if you act on the breakpoint when you're in the project that contains the source line the breakpoint's on.
If I try deleting or disabling breakpoints via another project, the action sometimes doesn't take effect, even though the debugger indicates that it has. So I will find myself breaking on disabled breakpoints, or on a (now invisible) breakpoint that I removed earlier.
I've had my breakpoints not work and then done Build / Clean All Targets to get them working again.
I think the problem could be incompatibility between device versions and Xcode. I have this problem when attempting to debug on my iPhone 4S running iOS 5.0.1. I am still using Xcode 3.2.5. I got the symbols from the handset by selecting "use this device for development" in the Organiser window. This phone refuses to breakpoint however. My old 3GS will breakpoint, same Xcode project, same settings... just different device and it's running iOS 4.0. I guess this is an Xcode bug in 3.2.5, since I have the symbols. Having tried all the solutions posted here so far, I have decided the solution to my problem is to go ahead and upgrade to XCode 4. Perhaps you cannot debug effectively unless your base SDK is at least as high as the system on which to debug. Maybe that's obvious - can anyone confirm?
Edit: I will update when I can confirm this is true.
Deleting my Build folder solved the problem for me.
If all else fails, instead of a breakpoint, you can call the following function:
void BreakPoint(void) {
int i=1;
#if !__OPTIMIZE__
printf("Code is waiting; hit pause to see.\n");
while(i);
#endif
}
To resume, manually set i to zero, then hit the resume button.
It has happened the same thing to me in XCode 6.3.1.
I managed to fix it by:
Going to View->Navigators->Show Debug Navigators
Right click in the project root -> Move Breakpoints (If selected the User option)
(I also Selected the option share breakpoints, even though I'm not sure if that necessary).
After doing that change I set the Move breakpoints options back to the project, and unselecting the Share breakpoints option, and still works.
I don't exactly know why but this get my breakpoints back.
For this, and also for Xcode 6 and above make sure that the breakpoint state button is activated (the blue arrow-like button):
In Xcode 4
- Product menu > Manage Schemes
- Select the scheme thats having debugging problems (if only one choose that)
- Click Edit button at bottom
- Edit Scheme dialog appears
- in left panel click on Run APPNAME.app
- on Right hand panel make sure youre on INFO tab
- look for drop down DEBUGGER:
- someone had set this to None
- set to LLDB if this is your preferred debugger
- can also change BUILD CONFIGURATION drop down to Debug
- but I have other targets set to AdHoc which debug fine once Debugger is set
I found the problem. Somehow the "Show Disassembly when debugging" was enabled in my XCode which creates that problem. When I disabled it, all my debugger stopped in my source code.
You can find it under: Product->Debug Workflow->Show Disassembly when debugging.
You can Activate / Disactivate Breakpoints in dropdown menu
I tried all the above things but for me only deactivating the debugging breakpoints once and then activating them worked.
When setting your break point, right click and you should get several options about how the break point is handled (log vars and continue, pause execution, etc)
Also make sure the "Load Symbols lazily" is not selected in the debug preferences.
(Applies to Xcode 3.1, not sure about past/future versions)
Also make sure that the AppStore distribution of the app is not also installed on the device.
Another thing to check is that if you have an "Entitlements" plist file for your debug mode (possibly because you're doing stuff with the Keychain), make sure that plist file has the "get-task-allow" = YES row. Without it, debugging and logging will be broken.
There appears to be 3 states for the breakpoints in Xcode. If you click on them they'll go through the different settings. Dark blue is enabled, grayed out is disabled and I've seen a pale blue sometimes that required me to click on the breakpoint again to get it to go to the dark blue color.
Other than this make sure that you're launching it with the debug command not the run command. You can do that by either hitting option + command + return, or the Go (debug) option from the run menu.
I have Xcode 3.2.3 SDK 4.1 Breakpoints will fail at random. I have found if you clean the build and use the touch command under build they work again.

Resources