Does Xcode have a watch window? - xcode

Does Xcode have a watch window for variables? It has a window for local variables but that's not much help when I want to watch the value of a global.
I've been spoiled by VisualStudio, I know.

Solved! Right-clicking in the local variables window brings a menu option of "Add Expression". Type your variable name and now you are watching your variable/expression.
The language of "expression" instead of the more familiar "variable" threw me quite a bit. Hard to search for a solution when I have the terminology wrong. Seems obvious now.

Xcode Expression window
Open Debug Area via View -> Debug Area -> Activate Console (Xcode 9)
Right click -> Add Expression

Related

Intellij tool window "evaluate expression" can't be opened

I'm using intellij 2020.3.2. On one session of my macos system, I can open the evaluate expression window, using the correct shortcut or cliking this :
. And I can use my debugger with normal behavior.
But I've got another session on the system (same project and seems to be same conditions), where it is impossible to open this tool window, whatever I test. I can debug, set a break point and see the value by "quick evaluate", but the evaluate expression window cannot be opened.
At this point I do not give more infos on the project cause I don't think it makes a diff...
I tried in a first place with another empty project, I have the same behavior, so it is possible that it's a macos issue, I don't know.
I also tried to reinstall the IDE on this second session, but it does the same.
After I've done some unsuccessful search, I come here and directly ask if you have any idea?
There is Show toolbar option in the Debug tool window:
After an update, problem is solved.

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 4 Set Next Statement, QuickWatch, Bookmarks,

any idea where can I find these great debugging features? I settle with bookmarks, but what about the others?
Set Next Statement
QuickWatch
ImmediateWindow
CallersGraph
Sry, i'm pretty new in xcode and mac dev.
Thnx
Set Next Statement - just drag the instruction pointer (from this post).
Have you found the "Debug Area" (View -> Debug Area)? There you can interact with the command-line debugger (e.g. gbd) via the Output pane, which is somewhat like the Immediate pane in MSVS if I remember correctly. There's also the variables pane.
I'm not sure what you call the CallersGraph, you should be more specific (at least link to the appropriate MSVS help pages).

In Xcode is there code that will open up the console for you?

Is there a way in Xcode to have your software open up the console for you? I would like to have it when my code compiles and runs in Debug to have the console open up automatically but in release for it to not open.
Thanks in advance.
A common way to achieve this is :
Open a new tab, and rename it 'Console' (or what name you want)
In this tab, show only the panes you want (in your case the console)
Go to Preferences>Behaviors
Tell Xcode to 'Show tab' and give it the name you set in 1. (you can set this at various moments, when build starts, or when app runs).
Now, each you will either compile or run your app, Xcode will switch to the tab you have set in Prefs.
You dont use code, you go to xcode pref's and do it there
This is where I came for the answer given and marked correct (although it's not clear it was what the asker quite wanted).
Arguably, a simpler version of the answer given is to set the Behaviors preferences to show the Debugger when a run starts. With the settings in the image below, this opens up the console (or the console + variable views or the variables view, depending on how it was last set - that's what 'Current Views' means).

How to enable NSZombie in Xcode?

I have an app that is crashing with no error tracing. I can see part of what is going on if I debug, but can't figure out which object is "zombie-ing".
Does anybody know how to enable NSZombie in Xcode 4?
Environment variables are now part of the "scheme".
To edit the scheme and turn on zombies:
In the "Product" menu, select "Scheme" > "Edit Scheme...".
Go to the "Run Foo.app" stage in the left panel, and the "Arguments" tab on the right.
Add NSZombieEnabled to the "Environment Variables" section and set the value to YES, as you could in Xcode 3.
In Xcode 4.1 and above, there's also a checkbox on the "Diagnostics" tab of the "Run" stage to "Enable Zombie Objects".
With Xcode 6.4:
I encountered the same problem with troubleshooting EXC_BAD_ACCESS and had hard time to find the setting with Xcode 4.2 (the latest one that comes with iOS5 SDK). Apple keeps on moving things and the settings are no longer where they used to be.
Fortunately, I've found it and it works for the device, not just Simulator. You need to open the Product menu in the Xcode, select Edit scheme and then choose the Diagnostics tab. There you have "Enable Zombie Objects". Once selected and run in debugger will point you to the double released object! Enjoy!
In short
Product->Edit Scheme->Diagnostics-> Click Enable Zombie Objects
Product > Profile will launch Instruments and then you there should be a "Trace Template" named "Zombies". However this trace template is only available if the current build destination is the simulator - it will not be available if you have the destination set to your iOS device.
Also another thing to note is that there is no actual Zombies instrument in the instrument library. The zombies trace template actually consists of the Allocations instrument with the "Enable NSZombie detection" launch configuration set.
It's a simple matter of setting an environment variable on your executable (NSZombieEnabled = YES), and then running/debugging your app as normal.If you message a zombie, your app will crash/break to debugger and NSLog a message for you.
For more information, check out this CocoaDev page: http://www.cocoadev.com/index.pl?NSZombieEnabled
Also, this process will become much easier with the release of 10.6 and the next versions of Xcode and Instruments. Just saying'. =)
Product > Profile will pop up Instruments. Select zombies from the panel and go nuts.
Go to Product - Scheme - edit scheme - Arguments - Environment Variables set NSZombieEnabled = YES
In xcode 4.2
Goto, Product -> edit scheme -> click Run yourappname.app -> Diagonostics -> Enable Zombie object.
Here's a video and explaination how to use Instruments and NSZombie to find and fix memory crashes on iOS:
http://www.markj.net/iphone-memory-debug-nszombie/
As of Xcode 3.2.5 and Snow Leopard (Mac OS X 10.6), you can run your code through the Zombies instrument: Run > Run with Performance Tool > Zombies. That allows you to see particular objects and their retain counts on a timeline.
In Xcode 4.5.2 goto Product -> Edit Scheme -> and Under the Diagnostics tab check the check box in between Objective C and Enable Zombie Objects and Click on OK
To enable Zombie logging double-click the executable in the executables group of your Xcode project. At this point click the Arguments tab and in the Variables to be set in the environment: section, make a variable called NSZombieEnabled and set its value to YES.
In XCode 4.0: To detect NSZombie in Instruments, select the Simulator as your target (can't detect NSZomboe on device). Run Instruments (CMD+I) and select "Zombies" trace template. Enjoy.
In the preferences of your executable add the environment variable NSZombieEnabled and set the value to YES.
in ur XCODE (4.3) next the play button :) (run)
select : edit scheme
the scheme management window will open
click on the Arguments tab
you should see : 1- Arguments passed on launch
2- environment variables
inside the the (2- environment variables) place
Name: NSZombieEnabled
Value: YES
And its done....
NSZombieEnabled is used for Debugging BAD_ACCESS,
enable the NSZombiesEnabled environment variable from Xcode’s schemes sheet.
Click on Product⇒Edit Scheme to open the sheet and set the Enable Zombie Objects check box
this video will help you to see what i'm trying to say.

Resources