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
Related
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.
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
Let's say I have 10 breakpoints and I want to clear one but not the other 9.
If I toggle the breakpoint on the one that I want to remove, it is resurrected the next time I restart the app. The only way that I know to permanently get rid of it is to clear ALL the breakpoints, which I would rather not do since I would have to reset the other 9.
Is there a better way in ANY VS version?
The breakpoint's state is only temporarily altered if you change it while you're debugging and it's a multi-bound breakpoint. This is actually a feature of Visual Studio. See the last post here.
If you're not debugging, and you remove it, then it won't come back. Alternately, as others have suggested, you can remove it permanently using the breakpoint management window.
Hitting Ctrl+Alt+B will bring up a list of all breakpoints in your solution, from which you can manually toggle or delete them with a right-click.
Open the breakpoints window (Debug -> Windows -> Breakpoints), select the breakpoint you want to delete and press the delete key (or click the cross icon).
If you are toggling the breakpoint using the keyboard (F9 using my keyboard mappings), it sometimes doesn't remove it properly. Pressing F9 again will remove it fully (this is due to the breakpoint being set on multiple threads and toggling it whilst debugging only disables the main breakpoint but not the ones for the other threads).
If you want to delete a breakpoint with F9 or by clicking the red glyph, that breakpoint needs to be childless. Otherwise, the breakpoint will persist through its surviving child breakpoints. (Child breakpoints can form when you set breakpoints during debug.)
You could check this question, " Disable/remove child Breakpoints? ", for a macro to remove child breakpoints. I think you shouldn't call the macro during a Debug session though, as this might result in your breakpoints to not be hit.
The following code can be used as a macro to remove the breakpoint on the currently selected line. (Note that Visual Studio automatically selects the line of a breakpoint when it is hit.)
Sub RemoveBreakPoint()
Dim debugger As EnvDTE.Debugger = DTE.Debugger
Dim children As EnvDTE.Breakpoints
Dim sel As Integer = DTE.ActiveDocument.Selection.ActivePoint.Line
For Each bp As EnvDTE.Breakpoint In debugger.Breakpoints
If bp.File <> DTE.ActiveDocument.FullName Then
Continue For
End If
For Each bpc As EnvDTE.Breakpoint In bp.Children
If bpc.FileLine = sel Then
bp.Delete()
Exit For
End If
Next
Next
End Sub
You can assign a keyboard shortcut to it for easy access. (Tools > Options > Environment > Keyboard.)
Cross-post from https://stackoverflow.com/a/35935390/257470 , but it's even more relevant here.
There are some answers here, but in my opinion proposed actions are distractive to use during debugging (I don't want to lose my focus).
My flow with sticky breakpoints during breakpoints is as follows:
During debug, DISABLE the breakpoint instead of removing it.
Possible ways of disabling a breakpoint:
hover with cursor and click the two cycle icon;
or use context menu on it;
or keyboard short-cut CTRL+F9.
Later on, during development, I remove a disabled breakpoint when I see one.
PS. It's also a good practice to remove all breakpoints once in a while.
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.
Often, when I have a breakpoint on some line in Visual Studio, The program will run and stop there. great. I will then click the red circle (or press F9) to remove it. Obviously I don't want my program to keep stopping there. The problem is that the next time I refresh the page the breakpoint is back! The only way to permanently remove it is to open the breakpoints window and remove it there. Why does this happen and how can I change this behavior?
I have noticed that these breakpoints which keep coming back have a little plus next to them in the breakpoints window which when you click on - open up many sub lines of breakpoints. What is the deal with that?
Thanks,
Adin
Helpful Key combo: to permanently delete all breakpoints, press CTRL + SHIFT + F9.
Just clear the breakpoint while the debugger is off. When you clear or add a breakpoint while debugging, the action only lasts for that debugging session.
The plus in the breakpoints window is there when one user-supplied breakpoint binds in multiple places. This can happen when a single file is loaded multiple times in the same debugging session, for example. The + lets you look at each of the places it bound.
#Joel: modifying breakpoints during a debugging session does not make your change temporary, although there are circumstances (like the original question), where the actual behavior can be non-obvious.
I've post suggestion to MS to fix it:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=391642
It appears since Visual Studio allows multiple breakpoints on a single line, i.e. in separate sub-clauses, architecturally it allows multiple identical breakpoints. The interface does not necessarily reflect this and you will see the removal of a breakpoint as graphically removing it, but not programmatically removing all instances of it.
Looking at the Debug > Windows > Breakpoints window shows for a given set of breakpoints on a line, they are stored in a sub-tree under that line item. Removing a breakpoint while watching this list will reveal the behaviour, that only one of a series of identical breakpoints is removed from the list associated with that line. By removing the breakpoint line item and with it all sub items it will completely remove all instances of the breakpoint.
Wipe the breakpoint out using the Breakpoints Window (Ctrl + Alt + B).
While debugging, when you hit the breakpoint, look at the BreakPoint window for the one that is bold.
Then, right-click it and choose Delete.