Diagnosing NSString error in Leopard

  • I noticed that my app was printing the following warning to the Xcode
    debugger console:

            *** -[NSCFString replaceCharactersInRange:withString:]: nil argument

    I found reproducible steps for the problem, but I'm not sure where in
    the code this is happening.
    So I set a breakpoint on NSLog, thinking that I could catch it in the
    act. This didn't give me much assistance, unfortunately:

    #0    0x953d9fd6 in NSLog
    #1    0x9127ecc8 in _NSDefaultTopLevelErrorHandler
    #2    0x910755ca in -[NSApplication run]
    #3    0x00d9d580 in /my application/

    Apparently the logging has been deferred for some reason.
    What would be a good way to get the debugger to stop when this error
    actually occurs?
  • On Dec 5, 2007, at 1:17 PM, John Stiles wrote:

    > What would be a good way to get the debugger to stop when this error
    > actually occurs?

    A breakpoint on objc_exception_throw should do the trick, right?

    j o a r
  • I don't think it's throwing, though.
    (I managed to catch it with a well-placed assertion, FWIW, but I'd still
    like to know.)

    j o a r wrote:
    >
    > On Dec 5, 2007, at 1:17 PM, John Stiles wrote:
    >
    >> What would be a good way to get the debugger to stop when this error
    >> actually occurs?
    >
    >
    > A breakpoint on objc_exception_throw should do the trick, right?
    >
    > j o a r
    >
    >
  • I take it back; joar's suggestion was right on the money. The breakpoint
    caught the problem immediately.
    I am used to Cocoa exceptions landing me in the debugger, since on Tiger
    I had set up a bunch of breakpoints on known trouble spots. I had
    forgotten to set this up on Leopard, though :)
    Cool! Problem solved.

    John Stiles wrote:
    > I don't think it's throwing, though.
    > (I managed to catch it with a well-placed assertion, FWIW, but I'd
    > still like to know.)
    >
    > j o a r wrote:
    >>
    >> On Dec 5, 2007, at 1:17 PM, John Stiles wrote:
    >>
    >>> What would be a good way to get the debugger to stop when this error
    >>> actually occurs?
    >>
    >>
    >> A breakpoint on objc_exception_throw should do the trick, right?
    >>
    >> j o a r
    >>
    >>

previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today