Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 27, 2008, 01:23 PM   #1
Buschmaster
macrumors 65816
 
Buschmaster's Avatar
 
Join Date: Feb 2006
Location: Minnesota
Send a message via AIM to Buschmaster
EXACT line of code that crashed my app?

Is there a way using instruments that I can see which instruction crashed my app?

Thanks.
__________________
Mint Apps: Apps with beauty and simplicity: www.mintapps.com
Buschmaster is offline   0 Reply With Quote
Old Jul 27, 2008, 02:11 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Use the debugger? If you're running in Debug mode and it crashes, open up the debugger before stopping the process and it should show you the stack trace.

Last edited by kainjow; Jul 27, 2008 at 02:16 PM.
kainjow is offline   0 Reply With Quote
Old Jul 27, 2008, 07:55 PM   #3
Buschmaster
Thread Starter
macrumors 65816
 
Buschmaster's Avatar
 
Join Date: Feb 2006
Location: Minnesota
Send a message via AIM to Buschmaster
Quote:
Originally Posted by kainjow View Post
Use the debugger? If you're running in Debug mode and it crashes, open up the debugger before stopping the process and it should show you the stack trace.
I'm pretty confused by this.

I said build and debug and then opened the debugger and when it crashed where it always does right now it showed a bunch of stuff but I didn't really figure out how to get the actual line of code out of it...
__________________
Mint Apps: Apps with beauty and simplicity: www.mintapps.com
Buschmaster is offline   0 Reply With Quote
Old Jul 27, 2008, 08:47 PM   #4
JNB
macrumors 604
 
JNB's Avatar
 
Join Date: Oct 2004
Location: In a Hell predominately of my own making
Send a message via Skype™ to JNB
Was it this one?
Code:
tell application "iPhone App" to trainwreck

JNB is offline   0 Reply With Quote
Old Jul 27, 2008, 08:49 PM   #5
TuffLuffJimmy
macrumors G3
 
TuffLuffJimmy's Avatar
 
Join Date: Apr 2007
Location: Portland, OR
Quote:
Originally Posted by JohnNotBeatle View Post
Was it this one?
Code:
tell application "iPhone App" to trainwreck

That doesn't need to be included in the app as apple has taken the liberty to thread it all through v2.0
__________________
"Next PM I get from you about this, and it gets posted as my signature." --*LTD*
TuffLuffJimmy is offline   0 Reply With Quote
Old Jul 28, 2008, 02:20 PM   #6
xsmasher
macrumors regular
 
Join Date: Jul 2008
Quote:
Originally Posted by Buschmaster View Post
Is there a way using instruments that I can see which instruction crashed my app?
You have 200 lines of code, and any one (or more) could be the culprit. You have to narrow it down, figure out what's working and what's not.

I make copious use of NSLog, so I can look at the console and get a general idea of what methods are being called. For example I may add, in the "init" method of my view class: NSLog(@"view was init-ed");

Then, when I look at the console (Run > Console on the menu) I'll see which methods were called before the crash, and how many times. If I see my app is crashing after the database is loaded, but before the screen is displayed, I now know better where to look.

You can also set breakpoints; go to a line that you think is being executed, and click in the grey area to the right of the editor. A blue arrow (a breakpoint) will appear. Now when you build and run your app, it will stop at that point and you can step through your application one line at a time until you find the line that crashes it.

One word of warning - if the crash is caused by a memory leak, it may "disappear" when stepping through by line, and reappear when you run at full speed. I had at least one EXC_BAD_ACCESS that only occurred when running normally, not when stepping through line by line. I had to add a lot of NSLogs to find that one.

The debug log may also be telling you if, for example, you're calling a method that is not defined; you should slog through it and see what is says.
xsmasher is offline   0 Reply With Quote
Old Jul 28, 2008, 05:00 PM   #7
firewood
macrumors 603
 
Join Date: Jul 2003
Location: Silicon Valley
single step

Use the stack trace in the debugger to find the function where it crashed. Put a breakpoint at the beginning of that function, restart the app, and single step one line at a time until something unexpected happens.
__________________
Apple II+, Mac 128k->512ke, Duo 210, MacBook Air 11, iPhone 5, iPad Mini Retina
firewood is offline   0 Reply With Quote
Old Jul 30, 2008, 05:50 PM   #8
caldwelljason
macrumors member
 
Join Date: Jul 2008
Console

It can also be helpful to look at the dbg console and see if there was an exception. Sometimes the exception information will give you a hint where to look.

For example, if you see that the exception that crashed the program was that the message doSomething could not be sent to object myObject, look for a place where you send that message to that type of object.

Another approach that sometimes works is to set a breakpoint in the last "known good" spot (I know I can load this view) and then step through the code, looking for things to go awry (variables to be in unexpected states, methods not called that you expected to be called, etc). Sometime you can step until you blow up and then you know where it was. This is similar to the NSLog approach, but more interactive (and more time consuming).
caldwelljason is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Source Code with Line Numbers Senor Cuete Mac Programming 12 Jan 17, 2014 02:33 AM
'eBay Exact' App Allows Users to Customize and Print 3D Items MacRumors iOS Blog Discussion 23 Jul 15, 2013 09:17 AM
What is a "line of code"? Sydde Mac Programming 39 Apr 8, 2013 07:36 PM
iTunes iOS App Store Shows "In-App Purchases" in an Extra Line Habakuk Mac Applications and Mac App Store 0 Mar 21, 2013 11:07 AM
Line App tob866622 iOS 6 0 Sep 14, 2012 07:38 AM

Forum Jump

All times are GMT -5. The time now is 02:32 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC