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

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.

Related

IntelliJ IDEA 2017 - Missing Debug window

My Intellij Debugger window went missing and I can't find any resources on how to get it back, the closest think I can get to my problem is a missing console window but that doesn't help. So I'm hoping someone here can help me retrieve it.
This pic shows a normal Intellij IDE (that I got from my friend) that shows the tab that's missing for me (in red) and the area in which this tab normally shows (in yellow).
And this pic shows my IDE with the missing Debugger window.
I also opened Intellij's help dialogue which claims that the window will show up when your code hits a break point but that didn't do it for me either.
Try the "restore layout" button at the left toolbar of the debugger toolwindow
Showing a tool window:
"Choose View" | "Tool Windows" | "Debug Tool Window" in the main menu.
It as simple as that.
There are multiple other things you can try, look here:
https://www.jetbrains.com/help/idea/manipulating-the-tool-windows.html#show
For example reset your Tool Windows:
You can return to the default workspace layout by choosing "Window" | "Restore Default Layout" (Shift+F12).
To enable the debug window
Click on View -> Tool Windows -> Debug
Or press (Alt+5)
This is not an answer to the specific question asked but a possible solution to My debug window has disappeared!. My situation was actually with Android Studio but should apply elsewhere.
My symptoms were:
I use multiple monitors and after a system crash my debug window
vanished.
Before the crash my debug window was in window mode on a separate
monitor. After the crash it was gone.
There was no Debug tab showing on the main window.
The Debug entry in the View menu was greyed.
The solution that finally worked was to set a break-point at a location I knew the code would hit, debug my project and make it hit the break-point. The Debug window magically appeared.
Remember to reposition the window correctly before exiting.
Try button on the right (there should be debugger, console....)
Try to Restore default layout in console/debugger screen. Its give in image please do check.
Remove the dev option from run/debug configurations from Command line.
You would have undocked, just look for "dock" sign, click on it.
Now debugger will restored to default view

xcode shortcut to go to next compiler error (ignoring warnings!)

I am aware that command + ' brings you to the next issue, but is there a way to bring you to the next compiler error and ignore the warnings?
(xcode 9)
I don't think there is a way to do that, but the closest thing you could do to that is to filter the display of issues in the Issue Navigator so it only shows errors and no warnings. Do that with one click, on the icon at the bottom right of the Issue Navigator.
Once you have done that, then the up and down arrow keys navigate you within the Issue Navigator from error to error instead of issue to issue.
To expand on auspicious99's answer, after filtering on errors in the issues pane, you can use keyboard shortcuts end to end:
cmd-5 - selects the issues pane
up/down arrows - select the error you want
cmd-j, enter - move the focus to the editor
In the navigator (the left-hand pane), choose the right-most icon that looks like a speech bubble. You'll see the build results, and when you click on them you'll be taken to the error.

Setting a conditional breakpoint in Firebug for Mac

I can't seem to set a conditional breakpoint in Firebug. Every Google search I've done indicates that I should be able to Right-click the line of code in question, at which point a "bubble" will appear asking me for the condition on which the break should be executed. Right clicking does in fact toggle the breakpoint's existence, but no bubble appears. How/where do I enter my condition?
Of course Mac mouses don't have a "right-click" button but assumed I could simulate right-click using Control. I've also tried Alt and Command to no avail.
I am running on Mac/Yosemite.
Thanks.
To be precise you need to right-click the breakpoint column or right-click inside the line and then choose Edit Breakpoint Condition... from the context menu. If you do so the condition editor should appear, which looks like this on Windows (on Mac it's black):
There is currently (Firebug 2.0.x) no keyboard shortcut for this action, so right-clicking is not working for you, it might be a bug in Firebug. In that case you should go through the steps described at Firebug's first aid page and file a bug if the steps don't help you.

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

Debugging an exception in a Cocoa app

I am working on an app with an NSTextView. When I paste random bytes into it (say, from a compiled C program) it displays gibberish, as it should. However, when I -setShowsControlCharacters:YES, the same causes a crash and gives the following error multiple times:
2008-11-22 00:27:22.671 MyAppName[6119:10b] *** -[NSBigMutableString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:]: Range or index out of bounds
I created a new project with just an NSTextView with the same property and it does not have this problem.
My question is, how can I debug my app to find the cause of the error? I have no idea where the bug originates. I am not familiar with the debugger built in to Xcode. If anyone could point me in the right direction in terms of how to track down such a bug I would be very grateful. Thanks.
Another set of useful breakpoints to set when your debugging Cocoa apps are objc_exception_throw and -[NSException raise]. In 10.5, all exceptions travel through objc_exception_throw but if you're targetting Tiger you should set a breakpoint on both.
There are more debugging techniques at http://www.cocoadev.com/index.pl?DebuggingTechniques.
It's not really clear how much you know so I'm going to try a very basic approach, please don't be offended.
I'm assuming the NSTextView is in a external nib/xib and is not created programatically.
If so open up your nib/xib in Interface builder and click on the offending NSTextView element.
Then hit Cmd-5 or Tools->Connections Inspector
From here you can see which Outlets/Actions to look for in the actual source code.
Most likely you're problem is manipulation of a "Reference Outlet" object, or in a "Sent Action" function.
Once you have an idea of which method(s)/variable(s) you need to watch you can open up the source code for those parts in Xcode. You can then set a break point at any line by click on that line number on the left hand side of the editor window.
Click on Run->Debugger. A new window should popup, click "Run and Go" in the toolbar of that window. Your app should run as normal until it hit's the break point you set in your source code. when the break point is hit you can mouse over variables in your code in the bottom half of the debugger window. The current values of the variables should popup allowing for easy inspection.
Usually you can gain the same information by using the Top Right panel of the Debugger to inspect the variable table.
When your done with that break point click "Continue" at the top of the debugger window and your program will execute till completion or the next break point.
This should get you started with debugging under Xcode.
Their are different kinds/uses of break points and all kinds of additional fancy stuff you can do in Xcode.
For more information check out this awesome CocoaHeads video.
Good Luck,
Brian G.

Resources