简体   繁体   中英

iPhone - Debugging EXC_BAD_ACCESS crashes

From times to times, while debugging an Application, I see this error on Xcode:

Program received signal: “EXC_BAD_ACCESS”.

and the debugger does not stop on the problematic line. In fact the debugger just shows me a page with a bunch assembly language code and that's it.

I have to have paranormal powers to figure out where the exact problem is.

Is there a way to force Xcode to give me more "nutritive" error messages – that can detail the problem – and stop on the offending line when such errors occur?

thanks for any help.

When the crash happens, open the Debugger in Xcode (Run -> Debugger). There should be 3 to 4 panes like this:

http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeDebugging/art/debugger_disassembly.jpg

On the top-left pane (the "stack trace"), select the topmost row which is not gray.

(Note: Sometimes the stack trace can only find internal functions because of bad memory management triggered in the run loop. Try to Build -> Build and Analyze to eliminate all potential memory management bugs first.)

You can enable NSZombies see here and I've found a good way to see where the actual problem is, is to run and debug the program with the debugger open.

This way when the program stops executing it more often then shows the line that was executing when the program crashed.

I wrote up a blog that tells you how to use some compiler switches that help a lot in finding crashes that are the result of releasing objects before you are done with them.

http://loufranco.com/blog/files/debugging-memory-iphone.html

Build and Analyze is ok, but not as good as scan-build (which it is based on). Instructions for installing that are here:

http://loufranco.com/blog/files/scan-build-better-than-build-analyze.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM