Debugging in Xcode 6.2 - xcode

I am developing a Mac application in Xcode 6.2 with Swift.
All my global variables and enumerations are in a separate swift file Globals.swift. The program so far works as expected.
But I am unable to see this global variables in the debug window. On the lower left of the debug window I selected All. I see outlets, local variables, but no global variables!
What do I have to change to see them?

This seems to be an issue with Xcode since some versions.
One way is to see the global variables by issuing the below command in the right hand debugger window
(lldb) target variable variableName
OR
(lldb) ta v variableName

Related

XCode lldb autocomplete

I have searched everywhere but can't seem to get answer. I am using Xcode 6.1.1.
I recall (possibly incorrectly) autocomplete being available in the lldb debug pane of XCode. I am currently typing fully all variables and functions; there must be a better way. Is autocomplete/intellisense available in Xcode?
Many Thanks.
The autocomplete available today in Xcode debugger console is for lldb commands. You can type fr<TAB> v<TAB> instead of frame variable. The autocomplete in lldb often can complete function names, for instance br s -n MyClass::MyMeth<TAB>. Or for a source file, br s -f myfil<TAB> -l 15. But once you're entering an expression (expr, or p, or po), the code completion you're used to seeing in the text editor panes is not available.

Xcode/lldb: stop application without symbols at entry into program

In lldb command line, I can stop execution of a program (which has no debug symbols) with the --stop-at-entry option by writing:
(lldb) target create /bin/ls
Current executable set to '/bin/ls' (x86_64).
(lldb) process launch --stop-at-entry
Process 22250 launched: '/bin/ls' (x86_64)
Process 22250 stopped
* thread #1: tid = 0xc46fa, 0x00007fff5fc01028 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01028 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01028: popq %rdi
...
I would prefer, however, to work in the Xcode (5) IDE for lldb. Is the same thing possible there? I can successfully attach to a process through Menu Debug->Attach to Process-> By Process Identifier or Name. If you enter an application name there, lldb will take over that process as soon as it is launched. However, I see no way of stopping execution when the program starts up, i.e. the equivalent of --start-at-entry. Nor do I see a way of entering the respective commands in the lldb window within the IDE, as the application is not launched yet.
Is this possible in the IDE?
Not sure what you are trying to do, but lldb does have a setting to stop on shared library loads:
(lldb) settings set target.process.stop-on-sharedlibrary-events 1
which will cause the program lldb is debugging to stop when a new shared library gets loaded. Not much goes on in the process before the first shared library load, so this will catch it pretty early on.
You can put lldb Xcode-specific setting commands in ~/.lldbinit-Xcode file and they will only apply to lldb instances called from Xcode.
This helps keeping separate settings.
From lldb(1):
FILES
lldb will read settings/aliases/commands from three files at
startup, if they exist.
First, it will read a ~/.lldbinit-debugger command file. If you are
using the lldb command line interface, this is ~/.lldbinit-lldb. If
you are using lldb inside a GUI debugger like Xcode this will be
~/.lldbinit-Xcode.
Entirely doable, at least under Xcode 7.
In an existing Xcode project, create a new schema. In the schema settings, under "Run", specify "Other executable" and choose the one you want. In schema properties, you may also specify command line, working directory, custom environment, etc...
Neither target.process.stop-on-sharedlibrary-events nor settings show target.process.stop-on-exec was having the desired effect for me.
Starting at the very bottom of the stack, I saw _dyld_start, dyldbootstrap::start, and dyld::_main.
Creating a symbolic breakpoint for dyld::_main, specifying the module as dyld, worked for me to get the debugger very early in the startup process.
Trying to set breakpoints on the first two functions did not work for me. I believe that may have something to do with dyld rebasing itself inside that second function: the code isn’t running where the debugger expects it to be in memory until the third frame.

Unable to display variable values

Environment: Xcode Version 5.0.1 (5A2034a)
Scenario:
1) I've create a simple Apple-supplied iOS project template.
2) I create a local string value with an initial value; plus a local integer variable with value.
3) I did a debug 'po' & 'p' for the object and integer.
Xcode's debugger apparently doesn't see these values.
The following are a couple of snippets of the debugger's environment:
As you can see, the debugger's symbol-generator is ON and the optimization is set to NO (zero).
1) Here's another example.
Note: NSLog() does work.
Notice the 'Turkey' for 'testString' value. Why this value?
'Turkey' was used in ANOTHER project and has no relevance to this one sample project.
It appears that I'm getting variable bleed from some xcode environment peculiar to Xcode 5;
...not found/experienced in Xcode 4.
Okay, this is weird. I've tried the NSLog() and got the values displayed. Then just for kicks I did a 'po' again and got the correct value.
However I still have the 'Turkey' value:
2) Here's a second example.
Starting with a new application from the Apple-supplied view template:
This time, the NSLog() works but again, can't get the 'po' value.
I still haven't figured out the pattern here.
What else can I do?
How can I get my debugger 'po' & 'p' commands to show data?
Or... why am I'm getting inconsistent debugger behavior (Xcode5 appears to work okay; re 'NSLog()')?
I had this recurrent problem so I tried logging via a different account to find the problem disappeared.
So there's something wrong with my Xcode account; specifically:
So I emptied the Xcode folder found under ~/Library/Developer and restarted Xcode.
Apparently the problem(s) is/are solved.

XCode 4.6 doesn't show current value of integers

When stepping through a loop, NSLog(#"%d",intvar) shows the intvar is increasing, but hovering over it still shows 0. Here, the intvar is 8 and the breakpoint has been triggered, but the debugger displays 0.
Is there some debug flag to set somewhere in the project or target? When I debug, I want to be able to see the current value of any variable or object. But XCode doesn't have an easily settable "debug mode compile" or watches, like standard IDEs do.
Sometimes it doesn't even show a value for an integer, but just the name.
The Local pane is also still at 0, and sometimes it doesn't show a value at all.
All the variables' scope is method-wide, and I'm only debugging inside this method.
Is there a setting to make debugging work in Xcode or is it a bug?
Even I have XCode 4.6, and it worked fine for me, Check the screenshot.
You must have changed some setting,
**Wait for a while, trying to resolve*

how to using NSZombieEnabled on intrument Xcode 3.2.5

i have some problem in memory management, and then i try to fix it using intrument tool.
Base on mark j video on you tube
about using NSZombieEnabled in intrument, i try to do like that. The problem is i never find a checkbox to set NSZombieEnabled active in my instrument. In this case i use xcode 3.2.5 and still on IOS 4.2.
This is the screenshot from the instrument that show no one check box for NSZombieEnabled activated :
am i doing something wrong??
help me please
thank you
Try running your application on simulator and see if you get the option in instruments. You may refer this tutorial to see how it is done in XCode 3.2 or you may refer the accepted answer in this thread for XCode 4.
Why not installing the new xCode 4? There you can easily set the EnvironmentVariables in the Scheme under the tab Arguments for Debug.
To check if it is actually set I use this code...
if(
getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled")
) {
NSLog(#"--------------------------------------->NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!");
}
There is a simple way to enable NSZombie if you are dealing with XCode version 4 through implementation of the following simple step:
Please click on the scheme drop down bar named Product choose -> edit scheme -> arguments tab and then add NSZombieEnabled in the Environment Variables column and YES in the value column...Now you are done with enabling NSZombie to find bugs in program.
When you run your app,you get an error message where the app crashes setting NSZombie state to enabled,but originally before enabling NSZombie,you might find it difficult to find out what's exactly wrong,like crash at autorelease pool,gdb break currently using objective-c,BAD_ACCESS errors etc... By enabling NSZombie you can find what is exactly the problem such as improper deallocation and trying to re-access,or improper release of memory etc..The errors may be of the following kind:
-[ExampleProgramViewController alertView:didDismissWithButtonIndex:]: message sent to deallocated instance 0x7068f70

Resources