No more gdb in XCode console when build for iPhone simulator - iphone

Usually I use gdb backtrace to debug my application, but recently I can no longer do it when testing on iPhone simulator. The blue gdb word stops being displayed on console, and nothing happens when I type "bt" or "backtrace". I can still build and debug properly on the device though.
My XCode version is 3.2.3. Is there any way to manually activate the gdb (more importantly the backtrace)?

As Jack points out, the Pause button will manually activate gdb & the back trace, which is what you asked. You may have a bad install -- it happens, sometimes, try deleting your /Developer folder & re-installing. XCode 3.2.3 and the debugger work just fine, I use it several times a day.
In particular, CMD-Y is "build & run with debugger", whereas CMD-R is just "build & run" (no debugger, by default), so make sure you're using CMD-Y.
Aside: An issue I keep running into is, after the app quits, the red-stop-sign icon doesn't recognize that the app has finished, so I have to "stop" it again. I believe this is due to iOS-4's keeping apps running in the background.

If the program is hanging, which is what this sounds like. You can press the 'Pause' button on the Debugger Console or in the Debugger window to interrupt the app and see where it is currently executing.

Also, check and make sure your home folder .gdbinit file is in good order. Move it aside if it exists and see if the problem goes away.

Don't know if this is the exact same situation, but it may help. My iPhone was at firmware 4.0.2, but my Xcode SDK was for firmware 4.0.1. Normally Xcode would complain that I would need to upgrade to a newer Xcode that supported 4.0.2, this time it didn't.
Was banging my head why breakpoints could be set but the debugger did not stop at my breakpoint (the breakpoints were orange - signalling that symbols were not loaded). I decided to reboot my iPhone and now Xcode showed the warning (when it didn't before). Upgrading to Xcode for 4.0.2 fixed my problem of course. So perhaps your Xcode is not updated for newer firmware?

Had similar issue, but can't remember the exact circumstances. Turned out the Base SDK (in the project info build tab) was set to the device and not the simulator. Bit of a shot in the dark, but probably worthwhile verifying.

Related

Xcode 4.3 and debugging on iOS 3.x devices

I just updated Xcode to version 4.3 via the Mac App Store last week, and discovered that I can no longer debug on iOS 3.x devices. I have the iPhone 3G running iOS 3.1.3 and a 1st Gen iPad running iOS 3.2.
On both devices it appears that Xcode 4.3 installs the app and attempts to launch the app. The app displays the splash screen but never completes booting. There are no error messages or messages of any kind in the debugger output window. My only clue is when I press the pause button I can see that the device/Xcode is stuck in the following function: addimagesToAllImages which appears to be related to Apple's DYLD.
Debugging works fine on iOS 5 devices and worked on the previous Xcode 4.2 installation. I've rebooted my Mac, iOS 3.x devices with no change in behavior including clearing out all cache(s).
Anyone have any ideas as to what's going on? Thanks for the help.
Ok, I figured it out with Junior B's hint about the debugger. I went to "Manage Schemes" and selected the Scheme I'm working on and clicked "Edit". Under the "Run" section I changed the Debugger from LLVM to GDB. Now debugging on iOS 3.x and 5.x devices work fine. Also, I left the compiler to xcode's preferred setting of LLVM 3.1.
Hopefully this helps someone else that accepts xcode's upgrade adviser recommended settings and their iOS 3.x debugging breaks.
Have you installed the “iOS 3.0 - 3.2.2 Device Debugging Support” component?
From the menu bar, choose Xcode > Preferences…, then in the Preferences window choose Downloads > Components. Find the line for iOS 3.0 support and click the Install button.
Only switching from LLDB to GDB wasn't enough for me when encountering the same problem. As I had an older working commit in git, I figured out which changes in the Xcode project setting let in my case to the error. Thus I could resolve the issue by removing all occurrences of the following line from my $PROJECT.xcodeproj/project.pbxproj
GCC_THUMB_SUPPORT = NO;
Also, I reverted the value from
LastUpgradeCheck = 0430;
back to
LastUpgradeCheck = 0420;
As I have my schemes configured to be 'Shared', these settings are also stored in the project directory (subdir. 'xcshareddata' in the project .xcodeproj directory), and thus changes also visible in git. Another change I reverted were removing these two lines in '$PROJECT.xcodeproj/xcshareddata/xcschemes/$PROJECT.xcscheme':
LastUpgradeVersion = "0430"
ignoresPersistentStateOnLaunch = "NO"
Another change in the .xcsheme file were that the values of 'selectedDebuggerIdentifier' and 'selectedLauncherIdentifier' ended with '.GDB' instead of '.LLDB', but this is actually the same as you will get by following the accepted answer from Wesley.
Those changes solved for me the problem, and I could debug again on my iPhone Classic running on iOS 3.1.3.
However, I strongly recommend the use of a versioning system like Git (or at least a local backup!) before applying these edits with your favorite text editor.
Hai MyDear Friends,
I am having one simple solution as follows:
"Xcode --> Preferences --> Debugger --> check Auto clear Debug console"
results clears the console every time You run the Application

iPhone Simulator Can't Be Lauched?

When I press Run on Xcode with other tasks already running, the following message appears:
Simulator in Use.
The Simulator can't be launched because it is already in use.
I checked with some friends and when they press run, Xcode automatically stop the tasks running and run the app you want. How can I configure this here?
Thanks in advance,
Quit the simulator and try again. if not working quit the Xcode and try again.
If you have two projects open in Xcode and one is running on the simulator, you can't run the other. Go through each project window and see if any are running, and if they are, press the "Stop" button on the top left:
In most cases Josh answer solves this problem. But just now happened to me to have only one project in Xcode and trying to clean and built it did nothing.
For me (this time) the solution was to:
Right click the simulator from dock and click Quit.
I did the same for Xcode (right click on Xcode in Dock and clicked Quit).
After that just re-open Xcode and voila!
It works!!!
If the issue is you have multiple projects open and running into Simulator conflicts, someone created a little Automator script that closes the current simulator and starts the next one. Kind of a work around but might work for you.
Check out the detailed answer here.
The over attached debugger syndrome
This happens to me when I switch simulator type (ios version or device type) without pressing the stop button (application was still running on it). To fix this, switch back to the old one (if you remember witch it was :P), run then stop the application, switch to the desired simulator configuration, run, tadaaaa: the error is gone.
This can also happen if you have two projects and one is running, and you try to run the other one. The solution is to stop the other one before starting the desired one.
This ca also happen if you had some kind of crazy bug and the simulator is unresponsive, in this case the debugger remains attached, crying over it's beloved simulator. You have to close the xcode simulator and sometimes restart for this one.
I have the latest xcode version at this time and got fustrated for a while. Now I'm free from restarting the simulator, xcode, coputer, router, going to sleep and waking up the next morning... :D
Hope this helps you guys apple has a lot of weird unclassified exceptions in xcode. They could least say that the debugger is still atached to something in the memory, we are programers not ordinary users, the more errors you give us the better we understand how to avoid them.
My personal favorite si when xcode puts absolute paths to your newly added famework that go nuts triing to find out why it doesn't work on an other computer (The project in wonderland syndrome).
(and rant rant rant irony rant.. you get the idea)
Quit the xcode and simulator ,and try to restart your mac
Quit the simulator and try again.
Your mac might be opening iPhone Simulator automatically, In order to stop this you can run Terminal, OSX's version of command prompt, by navigating to ~/Applications/Terminal.app
from there you can run these commands.
top -u This command shows the mac's processes, and some information about them, from there you can see whether iPhone Simulator might be open.
sudo killall iPhone\ Simulator Deconstructing this command for you, sudo puts you into superuser mode, by having you enter your login password, killall : This command kills all processes by the name specified. iPhone\ Simulator: This being the name of the app, and in order to have a space requires the \ (space) before the second word. By running this command you will kill all processes called iPhone Simulator.
If this doesn't help, then try rebooting.
If rebooting doesn't help try re-installing XCode.
If re-installing XCode doesn't help, then try re-installing your Operating System entirely.
Good Luck!
There are three solutions for this issue:
Right click the simulator on the Doc, quit and then re-run the application from the Xcode.
If this did not work, then -
Save your code, Right click the Xcode, restart the Xcode with your project and then run again. Remember to select simulator instead of device in the target.
If this also did not work, then,
Force Close - Simulator/Xcode - Restart your mac and then run Xcode again.
Most likely - the first step would be enough!!!
To get the simulator to stop whatever is running you need to check off the box "Do not show this message again".
Example:
And then click the box.
And then you can run the simulator even if a program had already been running.
I've been having this issue as well, but for me the problem doesn't have to do with XCode or Simulator.
The problem was in my code. A process was making the CPU run at 100%, and fixing the bug in my code fixed the simulator problem.
Force Quit both, iOS Simulator and Xcode, then reopen Xcode and run project.
Two Possibilities.
1)just quit the simulator,and run the application you want to run
2)just stop the application that using the simulator and run the application you want to run
Try these steps in increasing order of persistence of the problem:
Quit the Simulator.
Clean the project, Reset Simulator, Delete 'Derived Data'.
If nothing works, Force Quit Xcode and Simulator from the Mac Menu.
Force Quitting Xcode seems to always work for me.
It was one sticky Xcode bug indeed. Now it's solved, happy coding!

Xcode 4.2 not debugging properly

I've imported an iPhone app that I have developed for iOS and am now maintaining it. I've came across a couple of bugs when trying to add to the iPhone's calendar, which I'm happy to try and sort out myself with a bit of debugging.
One problem is that when I go to run the application on the iPhone simulator, it seems to run an older version of the app than the one I am running. I've removed and added another button since then and the old button is still showing when I run it in the simulator. However, when I compile and run this on a device, it loads the correct version and displays the correct version number in the 'about' view.
But... my main problem is that it doesn't seem to debug on the device properly. The app actually works fine except for the calendar problems, but if I put a few breakpoints in so I can see exactly where this is going wrong, it just doesn't seem to step through! The app pauses, and Xcode says the app has paused! I can press step over and continue execution etc and it appears to work, but I can't see it stepping over the code, nor can I hover over variables to see their values.
I've tried reinstalling Xcode multiple times (I did have a problem installing an older version, so I had to wait until the next version was available before Xcode would install).
The stress is: Today is my last day at work, and I'd really like to get this app ready for iOS 5 before I leave.
Has anyone seen these symptoms before? Is there a debug setting that I've missed? Or is it a corrupted installation?
I wish I could help people a bit with more information, but I don't even know where to start looking here. Any code I can post? any settings? (not too familiar with this, I'm a .NET guy usually).
Thanks!
Sorry you're going through a tough moment there Connell; as you said you're not too familiar with all this, I'm laying down a few steps which might help you out. Some are pretty basic, yes, but I've resolved to these steps myself several times when I've encountered similar scenarios;
If you're testing on the simulator, do a 'Reset Content and Settings' from the 'iOS Simulator' main menu. This will remove all old data and settings and give you a clean start.
Do a 'Clean All Targets' from the Build menu. Then go to your physical project folder and delete the Build folder from it altogether before starting to build again.
Restart both XCode and the Simulator (and your Mac too if possible)
Make sure the mode is set to Debug and not Release or Distribution
Even on the device, remove the old app before putting the new one in, and restart it for good measure.
Delete all Provisioning Profiles from the device and install just the one you need.
On the code;
I've noted that the app appears to 'pause' like this a couple of times when I had accidentally created an infinite loop in the code. Double check to see whether there's something which may cause this.
Unless you haven't already done so, throw an NSLog or two in there to see if its really not being executed beyond the breakpoint.
I've had the exact same problem with a project that I started on xcode 3 and then switched to xcode 4. What fixed it for me was changing the compiler in the project settings.
The default compiler up to xcode 3 was gcc, while the default compiler on xcode 4 is LLVM gcc.
Now, I don't know exactly what's the issue that gdb could have with LLVM gcc, but switching the compiler back to gcc in my project settings and doing a clean build fixed my debugging issues.
Might be worth a try.
Have you checked which debugger is being used GDB or LLDB? Select Edit Scheme from the Product menu, and see what the Debugger setting is under the Debug scheme. You could try switching between GDB, LLDB, and None and running in between.

Why does GDB debugger constantly freeze Xcode 4?

This is a really weird bug...
I'm working on an iPhone project using the camera feed and running it through an OpenGL shader to apply effects to it. However, every time I simply create a new GLfloat in the code, the debugger freezes when launched... I can't copy and paste the text because the whole of XCode freezes up, but I've cobbled it together from one of the log files:
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".2#b2a16f854957b341^2#43"Xcode.IDEFoundation.ConsoleAdaptor.Debugger17"tty /dev/ttys000
(gdb)
The phone has not frozen, because I can hit the home button and carry on doing other stuff on it. However, Xcode 4 has completely frozen with a beachball running at 99% CPU, and I have to Force Quit and start it again.
However... The really strange thing is I have an iPhone 3GS, and when I borrow someone's iPhone 4 it compiles and runs fine. When I switch back to the iPhone 3GS, it's fine for the first time only... After that, it freezes constantly again.
Is this possibly something I am doing, or is it yet another XCode 4 bug? I wanted to try switching the debugger to LLDB, but that doesn't appear in my dropdown list in the Scheme window... Even though the Xcode User Guide states that both GDB and LLDB are available:
http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Debugging/Debugging.html
Thanks!
I am working on a video processing app as well, and this is exactly the symptoms i am having.
it works in waves.
I don't know what the reason for this is, but i am slowly gathering facts to solve it:
turning off GDB in Scheme settings removes the issue
with GDB ON, "wait for app to launch" seems to solve the issue (need more testing)
after getting into "stable freeze" mode, meaning, beachball on run every single time, Committing to repository removes the issue (??)
restoring device as a new device to latest iOS through iTunes solves the issue
all of the above except turning off GDB only solves the issue temporary - it comes back after few more runs...
Try to have terminal open, AND IN THE FOREGROUND (ON TOP OF XCODE) when the program builds and begins running.
Also, if possible, try downloading xcode 4.1. This seemed to fix this annoying problem for good, AND I can actually use the debugger again !
I had this problem once before and it started happening again all day today. I've tried everything from cleaning the project to restart both my iPad and MacBook Pro and even swapping a different cable.
What worked the two times this has happened:
I cleaned the project, changed the build target, and ran it on the iPhone simulator, iPad simulator. Then returned to the original (main) build target (the actual app) and ran that on the iPhone and iPad simulators. All of those ran correctly, so I finally ran the original app on the iPad device and it worked and has kept working.
Seems like a combination of cleaning the project, changing build targets, and running on the simulator is flushing something out that previously caused XCode and my iPad device to hang and freeze.
Good luck
In my case it was the wrong Code Signing Identity
Minimizing "NSLog" statements within loops helps for applications using OpenGL ES, OpenCV, etc.

iPhone Device Debugging

Is it possible to actually use the Xcode debugger when running an iPhone app on the device rather than the simulator? i.e., can I have the device stop at breakpoints that I set in my code and step through the code as it runs on the device?
EDIT: I should mention that I am a registered developer with Apple and have a valid certificate. In fact, I can build and run iPhone applications on my device just fine. However, even in Debug mode, my application will not stop on breakpoints or output to the console when I run it on my device. If it helps, my application will function normally in debug mode (e.g., stopping at breakpoints) when I run in the simulator.
EDIT 2: I've tried resetting my phone, completely removing and reinstalling Xcode, creating a new project, changing all the settings mentioned in the answers on this page (as well as others), cleaning and building my project, Build and Debug... If I click Pause, it says "Error from Debugger: Quit". :( Maybe I'll try to debug on this device using Xcode on another computer and see what happens.
EDIT 3: Well, I tried using another computer using a fresh install of Xcode in a new project, and I still can't get device debugging to work. I have a suspicion that it's my iPhone or cable perhaps? I'd like to think that I'm not so incompetent that I've missed something so embarrassingly obvious, but I've double- and triple-checked all of the suggestions mentioned here.
EDIT 4: FINALLY got device debugging to work. I have a feeling that something low-level on my device was causing issues...nothing I did worked on my system. However, I installed Xcode on another system and device debugging on the same device (with the same cable) worked flawlessly. Directly after that, device debugging began working on my original machine, leading me to believe that some strange hardware flag was screwed up and somehow "reset" on the second machine. In any case, it works now... Thanks for all the help. :)
Also, I'm unsure if it's better to leave this question unanswered or pick the most "helpful" answer...
Yes -- just use a device build. You have to get certificates and provision it.
This is a good description:
http://boga.wordpress.com/2008/07/16/debugging-ipod-provision-profilescertificates/
Make sure to start debugging by pressing "Cmd-Y"... and not "Cmd-R" :-)
You may try last trick in case nothing can help.
If your application launched successful on your device from XCode but did not stop at breakpoints - try press "pause" button after start in debug mode. If you will see application paused properly (do not react to user's action) add new breakpoint then press "run" to continue application execution. In some cases it may helps to stop at new breakpoint.
Yes, just set your project to build for the Device.
If you need to setup debugging for jailbroken iPhone (up to 2.2.1) (not pay 99 to Apple yet) follow next steps:
Install MobileInstallationPatch for your iPhone via Cydia (use Search Tab)
Switch off PROVISIONING_PROFILE at XCode: Go to /Developer/Platforms/iPhoneOS.platform/Info.plist, add next keys:
<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>
You may also add these keys to any
project particularly at XCode, Project
Build Settings, User-Defined
variables.
Add key to your project Info.plist at XCode
SignerIdentity = Apple iPhone OS Application Signing
Don't forget to install and add to your project settings self-signing certificate from Apple
http://developer.apple.com/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW2
"Build and Go", you can connect iPhone and start debugging.
Important! You may need to install and launch at least one legal app (any free one) from App Store first (before "Build and Go" step). Otherwise your application will be successfully installed by XCode to your device but may not be launched. Try this troubleshoot first in case of problem with app launching.
Yes. Debugger and performance tools work fine on the device. That's where I do most of my debugging.
Xcode>preferences>debugging uncheck load symbols lazily
fixed the breakpoints not holding in device problem for me.