How to add a breakpoint to objc_exception_throw?

33,242

Solution 1

I think Brad's answer is pretty clear; hopefully this can help if you're not finding it clear.

In Xcode, from the top menu click on Run > Show > Breakpoints. A new window pops up.

Select "global breakpoints" in the left hand menu. There should be a box on the right under the "Breakpoint" column with the text "Double-Click for symbol". Single-click in this box and type in "objc_exception_throw".

Then, single-click in the space next to "objc_exception_throw" under the "location" column. A box will appear for you to type in the location (in this case, "libobjc.A.dylib"). I've made a screenshot that will hopefully help:

alt text

Solution 2

In Xcode 4 this great breakpoint can be added via "+" button on Breakpoints section (⌘ + 6)

enter image description here

Solution 3

in Xcode 6 -- from top menu

Debug > Breakpoints > Create Exception Breakpoint

Solution 4

I would also like to recommend adding the +[NSException raise:format:arguments:] breakpoint and its location should be CoreFoundation.

Share:
33,242

Related videos on Youtube

Rahul Vyas
Author by

Rahul Vyas

Sr. iOS Developer, Gamer

Updated on July 05, 2022

Comments

  • Rahul Vyas
    Rahul Vyas almost 2 years

    this was the answer from the brad larson on this SO question

    If you add two breakpoints, you should be able to debug these exceptions. To do this, go to Run | Show | Breakpoints and create two global breakpoints (I do them globally because they are so useful in all my applications). The first should be named "objc_exception_throw" and its location should be "libobjc.A.dylib". The second should be "-[NSException raise]" and its location should be "CoreFoundation".

    Now, if you start debugging your application with breakpoints enabled, it should break on the throw of these exceptions. You should then be able to see the chain of events that led to the exception within the debugger.

    now in this answer i want to ask how do i add location mentioned???

    • buildsucceeded
      buildsucceeded over 12 years
      Anyone have screenshots/menu paths for XCode 4?
    • Andy Sinclair
      Andy Sinclair over 12 years
      Check out this thread on the Apple Dev Forums for instructions on how to do this in XCode 4: devforums.apple.com/thread/68421
  • Rob Segal
    Rob Segal over 13 years
    Works great. Thanks for the detail.
  • Don
    Don about 13 years
    In Xcode 4, there is a breakpoint navigator where you can add these.
  • Ameer Sheikh
    Ameer Sheikh over 10 years
    This same approach can be used in XCode 5
  • DanSkeel
    DanSkeel about 9 years
    Also you can install script that prints exception description in console, must have!
  • DanSkeel
    DanSkeel about 9 years
    Also you can install script that prints exception description in console, must have!
  • Josh
    Josh about 7 years
    The other answers have changed, this answer is the correct one as of April 2017/Xcode8