I have an exception NSInternalInconsistencyException showing in the logs but when I launch the debugger it is not stopped where the code throws the exception.
Is there a way (there MUST be a way) to sto pthe debugger when an exception is thrown to see exactly where it fails in the code ???
[XCode] How to catch an exception in the debugger.
(7 posts) (3 voices)-
Posted 2 years ago #
-
Hi,
I forget where I found it, but I had this bookmarked :
http://www.cocoadev.com/index.pl?DebuggingTechniques
there's a section on 'Breaking on Exceptions' that is very useful..
I pretty much use 'bt' in the debugger console all the time though, and ~usually I find out where things went wrong.
HTH,
Mark
Posted 2 years ago # -
Thx Mark, are you simply entering "bt" and validate into the debug console ? When I do this nothing happen.
Posted 2 years ago # -
I'm not sure I've ever seen 'validate' in the debug console before. Make sure you are in debug configuration, not release config. Maybe we're not looking at the same thing? Usually, when my app crashes, I go to the debugger console, and I'll see a blue (gdb) prompt, where I type bt, something like this:
[Session started at 2009-11-04 15:33:31 -0800.] GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:11:58 UTC 2009) 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 "i386-apple-darwin".sharedlibrary apply-load-rules all Attaching to process 67601. (gdb)then I type 'bt', or 'backtrace' and get something like this:
(gdb) bt #0 0x90103814 in objc_msgSend_fpret () #1 0x0002ade4 in -[Sequence initOne:two:] (self=0x82dcc80, _cmd=0x5bb54, one_=0x82dcc30, two_=0xc32e6ea1) at /Users/effe/Documents/SubversionCheckOuts/cocosTesting/Classes/externalCode/cocos2d/IntervalAction.m:139 #2 0x0002ab99 in +[Sequence actionOne:two:] (self=0x660a0, _cmd=0x5bb37, one=0x82dcc30, two=0xc32e6ea1) at /Users/effe/Documents/SubversionCheckOuts/cocosTesting/Classes/externalCode/cocos2d/IntervalAction.m:109 #3 0x0002ac12 in +[Sequence actions:] (self=0x660a0, _cmd=0x56300, action1=0x82dcbc0) at /Users/effe/Documents/SubversionCheckOuts/cocosTesting/Classes/externalCode/cocos2d/IntervalAction.m:123 #4 0x00010a89 in collision_projectile_enemy (projectilesh=0x825d390, enemysh=0x8287350, contacts=0x82bb250, numContacts=1, normal_coef=1, data=0x0) at /Users/effe/Documents/SubversionCheckOuts/cocosTesting/Classes/Game/GameObjects/projectile.m:111 ... backtrace goes on with more info... which tells me I probably did something horrible on line 111 of projectile.m .
Mark
Posted 2 years ago # -
OK great, I was talking of the same thing, I entered "bt" in the console but not after a crash. Now, after a crash, it works, thanks.
Posted 2 years ago # -
Have you set a break point on "objc_exception_throw" ?
That will break on any exception.
Posted 2 years ago # -
Yes that's it. It changes your life when an exception is thrown because most of the time you can see immeditetly where in your code it fails.
Posted 2 years ago #
Reply
You must log in to post.