I could resolve this problem just now but assuming others might have the same problem, I post the "solution" here anyway.
When building a project in XCode using "Build and Debug" and then running it the iPhone simulator would exit without printing an error message to the console. Like for example I would access an invalid pointer and it would just terminate without printing Program received signal: “EXC_BAD_ACCESS”.
I used to use SDK 2.X and never experienced this and now I switched to 3.2 and this bug totally sucks.
Anyway. The "solution", if you want to call it that, is to set a breakpoint on the line where you access your invalid pointer, open the debugger, step over it and in the next cycle step into it. After that press continue and then close the debugger and simulator.
Then running the project using the "Build and Debug" button on the "Debugger Console" was fixed, i.e. when the simulator crashes it now prints "EXC_BAD_ACCESS" just like it used to in SDK 2.X.
Xcode will "normally" continue on an untrapped exception and display the appropriate message in the Debugger Console. However, if you have set "Run->Stop on Objective-C Exceptions" it will first pause in gdb before displaying the message. I would imagine that you may have set this breakpoint at some time - there are a few related breakpoints you can set in .gdbinit that will have a similar effect.
Related
I am trying to run a build of a macOS app on a virtual machine. Currently the app is crashing at launch and there is no way for me to diagnose the problem without an output. I noticed that a crash report is generated at "/Users/User/Library/Logs/DiagnosticReports".
Is there a way to "print" to the Crash Report so I could know which functions executed before the crash?
Xcode can not detect the cause of the crash if the crash happens before attaching the debugger.
So you may consider using the macOS built-in Console app to check log and activities which locates in:
/System/Applications/Utilities
Then you can see the crash logs and other logs in a live mode :)
Here is a quick tutorial for the Console app
I've been using Xcode to develop iPhone Apps for a couple of years now. In the last couple of months I've updated to Xcode 4.2 for iOS 5 development.
On previous versions of Xcode I've found it very rare that I get a crash without any log of where the error happened. With Xcode 4.2 / iOS 5 I find that I regularly get crashes without any log. I just end up with the code stopped in main.m with a message like "program received signal SIGABRT" (or a couple of other messages) but no log messages at all. (I'm looking in the "All Output" window at the bottom of the Xcode gui).
For example, my last one was where I used the initWithNibName:bundle: method but typed in the incorrect nib name. The code passed this line without error, but when I got to the pushViewController:animated: method the code crashed with the SIGABRT message but no log messages. It took a while for me to find my typo...
I'm sure in previous versions of Xcode I would see a far more informative message...
Is there something I'm missing in Xcode 4.2? Should I enable some extra debugging feature? Any way to get it to give more useful crash information? Or is this a know problem with iOS 5 / Xcode 4.2?
Thanks for any pointers...
You are not alone, I have found this too. I often find there is not enough information in the log to diagnose the crash with the lastest xcode. I have two tips that might help.
Run on the actual device. I often find for some reason I get more detailed logs when it crashes on the device.
Worst case, you can go into the organiser and check the crash logs of the device, this will give you what thread crashed and what you call stacks looked like when it crashed.
Switch between the GDB and LLVM compiler and or debugger. I havent experitmented enough with this but I believe this has helped on occasion.
i have run my application in device but application is crashed and print following message
error from debugger: the program being debugged is not being run.
so please tell me what to do?
my application gonna launch properly but not not debugging first time (gonna crash) than from second time i start application work proper without crashing
my application install in device. we can`t debug in device...
The first thing i do when i get that is a Clean All usually solves that. If you don't see the Clean All button right click your Xcode toolbar, customize, and drag the Clean All button to your toolbar from there.
-Check that the provisioning profile installed on your device haven't expired (would see a red dot in the organizer - Window->Organizer).
-Try restarting XCode.
Do you mean device? If so then it could mean the device is not launching the application correctly. Make sure your developer profile and everything in the build settings is correctly set. This may sound obvious but also make sure the device is unlocked and open.
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.
Are there any crash logs generated by iPhone Simulator?
the Simulator crashes a lot but not leaving any traces in Console... the crash log will be useful.
The console will show the NSLog() output from an app running in the simulator. The crash logs are saved to file.
I have found some in my home directory under
~/Library/Logs/DiagnosticReports/
They have a file extension of .crash
Something I haven't yet figured out is how to get them to generate even if the debugger grabs the EXC_BAD_ACCESS signal.
Update
Currently, (OSX 10.11.6), the .crash logs in ~/Library/Logs/DiagnosticReports, are when the emulator itself crashes. Logs for an app crashing (but the emulator device is still running fine), are in:
~/Library/Logs/CoreSimulator
Per crash, there is a sub-folder with a unique id. Sort by date, so that your recent crash is the first sub-folder. Inside that, start by looking at stderr.log and system.log.
Also directly under CoreSimulator, see CoreSimulator.log and Simulator.log.
I am pretty sure that you can see this in the OS X Console app located in Utilities. If I'm wrong though, be sure to vote me the heck down so I delete this.
UPDATE:
Specifically (as of OSX 10.11.6),
When an app crashes on emulator, a subfolder (with a unique id) is added to:
~/Library/Logs/CoreSimulator
Within that, start by examining stderr.log and system.log.
When the emulator itself crashes, a subfolder is added to:
~/Library/Logs/DiagnosticReports
Don't confuse this path with
/Library/Logs
(lacking ~ at start), which has different reports about your mac.
Here’s something that worked for me in a special case... My app was crashing with SIGKILL as it terminated. I would see the exception in main.m for a few seconds, and then the app would finish terminating – thus, no chance to get the back trace.
I did a lot of searching on “where does simulator store its crash logs” and never managed to find an answer. However, the following trick came in quite handy and I was able to grab the crash log on the fly:
Basically, open /Applications/Utilities/CrashReporterPrefs.app and change the setting to “Developer”. This will cause CrashReporter to display a popup with the crash log after your app crashes.
I found this in the “Viewing iOS Simulator Console and Crash Logs” section in this doc from Apple:
http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/ios_development_workflow/125-Using_iOS_Simulator/ios_simulator_application.html
The crash crash logs will appear under ~/Library/Logs/CrashReporter.
If the iPhone simulator program crashes (not the iPhone app running within the simulator), then there will be an entry for iPhoneSimulator.
If the iPhone App within the simulator crashes, the crash log will appear with the display name of the app.
When Xcode gets crash logs from a connected device, it stores them in sub-folders of ~/Library/Logs/CrashReporter/MobileDevice
This is much more reliable. In only a few steps I was able to find the source line number & method name:
cd to the dir having the .app & .dSYM files
run /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin MyApp.app/MyApp
set print asm-demangle on
set print symbol-filename on
p/a 0×00015c64 -> address got by opening the crash log in “Console” app or just double clicking the the .crash file.
For me, it was an expression that I had added to the debugger watch window. When a breakpoint was getting hit, the bad expression was causing XCode to segfault.
You may also want to take a look at this related answer: https://stackoverflow.com/a/14984297/679240
None of the answers above worked on the "Big Sur" OS version. The only way to find the log was through the "Console" app (Application/Utilities/Console)