Xcode 7.0.1 (7A1001) debugger "Unable to read data" - ios

I am learning the Swift programming language using Xcode 7.0.1. Now I have an error in my application which I try to debug, but the debugger is useless to me, because it cannot show the values of variables.
See the picture below:
I am 100% sure the button has a label.
I did not find the solution so far.

There is a lot of information that you can get from the LLDB. You need to have this open and it provides window that you can issues commands to as you are debugging to inspect variables. e.g the command p is print.
From your example this would then be
"p operation " and the variable "operation" will be printed.
I am grossly simplifying the LLDB btw
LLDB Apple docmentation
LLDB commands

Related

Why am I unable to view values in debug area?

After adding an expression -in the debug area-:
I am facing an issue, which is: when reaching the desired line (via a breakpoint), the value is always appears as "Invalid expression", with a message logged to the console:
Shared Swift state for (My Project Name) has developed fatal errors
and is being discarded.
REPL definitions and persistent names/types will be lost.
To double check that the variable has a value (also as a workaround to see what is the actual value of the variable), I tried to log it via dump() and it seems that it does has a value.
Although there is a workaround -as I mentioned, by using dump()-, I wonder what is the reason of causing this issue?
I am not pretty sure if it could be a bug in the Xcode; I am using Xcode version 8.3.2.
Remark: If you have no idea what is adding an expression into the debug area, you might want to check this Q&A.

How can I print variables when debugging an extension?

I'm connecting to my UNNotificationServiceExtension implementation by using Debug > Attach to Process by PID or Name (which took me forever to figure out), though when my breakpoints are hit and I try to po a variable, I get output like the following:
(lldb) po response // `response` is a `NSURLResponse`, so I would expect it to be available to the debugger by way of `Foundation`.
warning: Swift error in module
MyExtensionProxy(0x00000001000e8000).
Debug info from this module will be unavailable in the debugger.
warning: Swift error in module
MyExtension(0x0000000100118000).
Debug info from this module will be unavailable in the debugger.
error: in auto-import:
failed to get module 'MySharedFramework' from AST context
(lldb)
I can't find any information on how to resolve these framework runtime errors, so debugging is just about impossible. How can I make these modules available in the debugger and be able to po my objects?
Using Xcode 8.1
Was just going trough the same process myself. Gonna post this here for you and all the other searches. After eliminating all possibilities this small thing did the trick -
When you click "Debug > Attach to Process by PID or Name" you get this little popup window to insert your PID or Process Name. In this window there's a combo box titled "Toolchain". For me, it was set to "Xcode 8.1". Clicking this combo box opens more possibilities, among them was "Xcode 8.1 (Swift 2.3)". Picking this setting allowed me to see runtime variables in my Swift modules.

Xcode debugging (breakpoint) issue

I'm writing an iOS app in Objective-C for iOS 8.4 with Xcode 6.4. I have a variable (actually an item in an array) changing in unexpected ways.
In order to find out what is going on, I would like to have a way to make the program pause when a change on the variable is about to happen (or just happened), using some kind of “special break point”.
Is this possible, if YES how?
What you want is a Watchpoint (see "Setting Watchpoints" here).
Basically they monitor memory for writes and break the program when that happens.
I think you can only set them from the debugging console, not the Xcode UI, with:
(lldb) watchpoint set variable myinstancevar
or
(lldb) w s v myinstancevar

cocos2d: my APP crashes but XCode doesn't give me any crash report

It used to work fine but now I get this message when loading a certain scene and then the APP crashes.
2012-12-01 18:33:55.104 AppName[9561:707] cocos2d: CCSpriteFrameCache: Trying to use file 'art1-hd.png' as texture
I have no idea on where to start debugging this. Is there a way to get a more precise error message to understand why this happens?
Btw, I have changed my code signing identity to developer and XCode doesn't yet give me any trace of it on the console other than the plain message above. I checked as well the device logs on the Xcode-Organizer section but no trace.
I whish there was something like in Java + Eclipse, where I could get a precise STACKTRACE of where the crash happened.
Any suggestion on how to get a precise stacktrace (E.g. with function name generating the crash)?
PS: I have set strip debug symbols to "NO" in DEBUG, and to "YES" in Release, but I am builing on my own test iPod and hence I think it is automatically build for "Debug" (the section says build for running and testing which is confusing as the project settings allows only debug and release). But I think the problem is not here.. but in the issues above before the PS:
EDIT: If I look into the debug navigator I don't see any stacktrace of methods, as I want, but just threads.. I need to figure out how to use the global exceptions.
I have no idea on where to start debugging this.
You have the cocos2d source code. I would start there.
Search for "trying to use file" in CCSpriteFrameCache to understand what the cause of this message is (which I agree is confusing, why shouldn't you use that file?).
As for the stack trace, it's available as soon as you add a global exception breakpoint. If the breakpoint triggers in OpenAL code make sure to set it to catch only Objective-C exceptions.

LLDB equivalent to GDB's "info malloc-history <address>" command?

I am trying to resolve a "message sent to deallocated instance " error in iOS.
See the LLDB-GDB command map (http://lldb.llvm.org/lldb-gdb.html) - you have to import a script, and the command is named malloc_info now. Obviously, malloc stack logging still needs to be turned on in the scheme options.
(lldb) script import lldb.macosx.heap
(lldb) malloc_info --stack-history 0x10010d680
Unfortunately, it doesn't show dealloc's - didn't GDBs malloc-history show that as well?
Use instruments, you'll get the exact line -
(In XCode) Run it through "Product" -> "Profile".
This will start Instruments, there you should choose "Zombies" and reproduce the bug event.
You'l get a pop-up once a zombie is called, press the chevron to see the exact line.
Problem is usually a bad __bridge (optional bridges __brige_retained / __bridge_transfer / __bridge)
You used to be able to use the malloc_history command-line tool from a shell and give it the process ID and address of interest. It appears this command is no longer installed by the latest Xcode's command line tools. :-(

Resources