Debugger stopping at a non existent breakpoint in Xcode 4 - xcode

Since upgrading to Xcode 4 my app stops at what I think are non existent break points. When it breaks there is no breakpoint showing in the breakpoint navigator and the editor says:
Thread:1 Stopped at breakpoint 17
Anyone else seeing this? Is this something new, maybe?

Maybe it's an Xcode bug but I still have a solution.
You can use LLDB to see and manipulate all the actual breakpoints.
Just type the following commands in the lldb window:
(lldb) is the prompt.
(lldb) help -> for help
(lldb) help breakpoint -> for breakpoint subcommand's help
(lldb) breakpoint list -> list all the breakpoints.
(lldb) breakpoint delete -> Delete the specified breakpoint(s). If no breakpoints are
specified, delete them all.
(lldb) breakpoint delete 7.1 -> delete breanpoint 7.1
and, you can use this command to continue the program:
(lldb) c

user278859's answer is basically really a true answer, as this seems to be a bug in Xcode 4. I just had the same problem. I set a breakpoint at one place in a UIWebView delegate's shoudlStartLoadWithRequest-method (no other active breakpoints in the project) and the debugger stops in another method (in this case repeatedly webViewDidFinishLoad:) of the same object.
So I'd say this is an Xcode bug. Found no way of fixing this btw., other than removing the above breakpoint ... Screenshot:

Press Command + alt + B to see all breakpoints.
Select the breakpoint that you want to remove and press delete.

Ok, I deleted the only breakpoint in the offending class which was no where near the line where the debugger was breaking and the problem went away.
Fasttracks, thanks for the suggestion. I am using xCode 4 and command+alt+b no longer works. There is now a Breakpoint Navigator where all the brekpoints are listed. There was no breakpoint in the list that corresponded to the line where the break was happening.

I have the same problem before, I think its an Xcode bug. You may check if there any unwanted breakpoints created by Xcode in Breakpoint Navigator (cmd 6), delete them and it should be fine.

Xcode 4 introduced an Exception breakpoint which seems to be on by default.
i.e. when there's an exception it breaks.
This will catch an exception even if you haven't clicked the Breakpoints button.
You can check via the Debug Navigator whether it's been triggered - you'll see an "objc_exception_throw".

Open the Breakpoints view: alt+shift+5 and then right click in the empty space and hit "delete all". It will actually remove the not existent breakpoints.

I found one additional case when such breakpoint is activated:
If you set breakpoint on the code, which is actually is not compiled for selected target this part of code is not highlighted or marked, and breakpoint is set actually elsewhere in this file where debugger consider is as close as it can.
So you need to be sure that code, where breakpoint is set is compiled :-)

Not knowing what exactly Swift error breakpoint is...I had enabled it by doing such:
Guess what happens?!
It will act like a breakpoint on errors thrown by your own code, i.e. wherever you use a throw statement.
For more see here and here

Related

Identify a Breakpoint by Breakpoint Number Xcode

While using the debugger in Xcode, I got the following error:
"Execution was interrupted, reason: breakpoint 6.3"
So, I'd like to remove breakpoint 6.3. How can I figure out which one has the number 6.3? I have looked in the breakpoint summary panel, tried right clicking on each one, but I don't see any way to identify each these number.
There seems no way to identify the breakpoints by number in the Xcode Breakpoint Navigator.
However, you can easily remove the breakpoint in the debugger console. In your case "6" is the breakpoint number and "3" is one of the breakpoint locations.
breakpoint list
shows all breakpoints.
breakpoint delete 6
deletes breakpoint 6 (with all locations).
breakpoint disable 6.3
disables only location 3 of breakpoint 6.

How do you add a breakpoint in Xcode?

I have written my first Hello World Objective C program.
How do I add a breakpoint and inspect a variable?
I can see a Breakpoints button but can't insert one.
Command + \ to add breakpoint at current line
You don't need to right click or any such thing. To enable the breakpoints in your code all you have to do is click on a particular line number. You'll get a breakpoint symbol in your code there.
You can add multiple breakpoints to your code. The breakpoints button on top is used to put all your breakpoints ON (during debugging) or OFF (when necessary)
I'll be addressing a section on breakpoints in my blog ( http://techtalktone.wordpress.com ) soon.
Hope this helps :D
Maybe this is useful for you: Xcode Debugging Guide
use menu entry Product->Debug->Add Breakpoint at Current line
that menu also shows the shortcuts for similar actions

Breakpoints dont work

When I set break point at some line and press Build&Go my breakpoints become yellow and my program continues. Nothing happens. I`ve unchecked Object Lazy ..., optimization levels, active target is Debug, load debugging symbols is checked. I also want to mention that my debugger never worked before.
Try "Build and Debug" instead.
Try to refresh the files you are working on, make sure you have build automatically set, clear all breakpoints, restart eclipse this might help.

enable line numbers of stack trace in xcode console [duplicate]

this was the answer from the brad larson on this
SO question
If you add two breakpoints, you should be able to debug these exceptions. To do this, go to Run | Show | Breakpoints and create two global breakpoints (I do them globally because they are so useful in all my applications). The first should be named "objc_exception_throw" and its location should be "libobjc.A.dylib". The second should be "-[NSException raise]" and its location should be "CoreFoundation".
Now, if you start debugging your application with breakpoints enabled, it should break on the throw of these exceptions. You should then be able to see the chain of events that led to the exception within the debugger.
now in this answer i want to ask how do i add location mentioned???
I think Brad's answer is pretty clear; hopefully this can help if you're not finding it clear.
In Xcode, from the top menu click on Run > Show > Breakpoints. A new window pops up.
Select "global breakpoints" in the left hand menu. There should be a box on the right under the "Breakpoint" column with the text "Double-Click for symbol". Single-click in this box and type in "objc_exception_throw".
Then, single-click in the space next to "objc_exception_throw" under the "location" column. A box will appear for you to type in the location (in this case, "libobjc.A.dylib"). I've made a screenshot that will hopefully help:
In Xcode 4 this great breakpoint can be added via "+" button on Breakpoints section (⌘ + 6)
in Xcode 6 -- from top menu
Debug > Breakpoints > Create Exception Breakpoint
I would also like to recommend adding the +[NSException raise:format:arguments:] breakpoint and its location should be CoreFoundation.

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