Xcode debugging Summary

Source: Internet
Author: User

1. Set nszombieenabled

Use the nszombieenabled function, whenCodeThe following prompt is displayed, not just exec_bad_access:

 
2008-10-03 18:10:39.933Helloworld [1026: 20b] ***-[gsfont ascender]: Message sent to deallocated instanceZero X 126550

If you want to view the above address allocation information

Enable mallocstacklogging (check mallocstacklogging in xcode4)

Shell malloc_history PID address when an error occurs

 

In addition, you can reload respondstoselector to find it.ProgramThe final function executed during the crash, and then troubleshoot.

 

2. Add a Global breakpoint

Xcode4 allows you to easily add global exception breakpoints.

Iii. Exceptions of interruption and uncaptured

1. unblocked Signal Source: kernel, other programs, itself.

Two common signals:

1). exc_bad_access attempts to access illegal memory, resulting in sigbus or SIGSEGV Signals

2). Failed to intercept the SIGABRT signal caused by obj_exception_throw.

2. Method

1). Use nsuncaughtionhandler to install a handler to intercept a non-intercept exception.

2). Use the signal function to install a handler to intercept the BSD signal. (sigkill [kill-9] And sigstop [Control + Z] cannot intercept)

Two c Functions

 
VoidSignalhandler (IntSignal)
{
//Interrupt signal
}


VoidUncaughtexceptionhandler (nsexception * exception)
{
//Exceptions not captured
}

Installation (conflict with global exception breakpoint. If there is such a breakpoint, the following Interception Function fails)

VoidInstalluncaughtexceptionhandler ()
{
Nssetuncaughtexceptionhandler (& uncaughtexceptionhandler );
Signal (SIGABRT, signalhandler );
Signal (sigill, signalhandler );
Signal (SIGSEGV, signalhandler );
Signal (sigfpe, signalhandler );
Signal (sigbus, signalhandler );
Signal (sigpipe, signalhandler );
}

 

3. specific instance

1.Http://cocoawithlove.com/2010/05/handling-unhandled-exceptions-and.html

Focus on trying to continue running the program

Tell the user about the crashes caused by these unblocked exceptions and signals, or you can record them on your own, or even avoid these crashes. However, if multiple signals are intercepted, this may fail.

We recommend that you take a look at this article.Article

2. http://parveenkaler.com/2010/08/11/crashkit-helping-your-iphone-apps-suck-less/

The focus is on record exceptions (then the main thread is returned)

-(Void) Pumprunloop
{
Self. finishpump = no;
Cfrunloopref runloop = cfrunloopgetcurrent ();
Cfarrayref runloopmodesref = cfrunloopcopyallmodes (runloop );
Nsarray * runloopmodes = (nsarray *) runloopmodesref;
While(Self. finishpump = No)
{
For(Nsstring * ModeInRunloopmodes)
{
Cfstringref moderef = (cfstringref) mode;
Cfrunloopruninmode (moderef,1.0f/1200000f,False);//Pump the loop at 120 FPS
}
}
Cfrelease (runloopmodesref );
}
  From: http://www.cnblogs.com/v2m_/archive/2011/10/21/2220251.html

1. Set nszombieenabled

With the nszombieenabled function, when the Code accesses a place where the memory has been released, it will give you the following prompt, not just exec_bad_access:

 
2008-10-03 18:10:39.933Helloworld [1026: 20b] ***-[gsfont ascender]: Message sent to deallocated instanceZero X 126550

If you want to view the above address allocation information

Enable mallocstacklogging (check mallocstacklogging in xcode4)

Shell malloc_history PID address when an error occurs

 

In addition, you can reload respondstoselector to find the final function executed when the program crashes, and then troubleshoot it.

 

2. Add a Global breakpoint

Xcode4 allows you to easily add global exception breakpoints.

Iii. Exceptions of interruption and uncaptured

1. unblocked Signal Source: kernel, other programs, itself.

Two common signals:

1). exc_bad_access attempts to access illegal memory, resulting in sigbus or SIGSEGV Signals

2). Failed to intercept the SIGABRT signal caused by obj_exception_throw.

2. Method

1). Use nsuncaughtionhandler to install a handler to intercept a non-intercept exception.

2). Use the signal function to install a handler to intercept the BSD signal. (sigkill [kill-9] And sigstop [Control + Z] cannot intercept)

Two c Functions

 
VoidSignalhandler (IntSignal)
{
//Interrupt signal
}


VoidUncaughtexceptionhandler (nsexception * exception)
{
//Exceptions not captured
}

Installation (conflict with global exception breakpoint. If there is such a breakpoint, the following Interception Function fails)

VoidInstalluncaughtexceptionhandler ()
{
Nssetuncaughtexceptionhandler (& uncaughtexceptionhandler );
Signal (SIGABRT, signalhandler );
Signal (sigill, signalhandler );
Signal (SIGSEGV, signalhandler );
Signal (sigfpe, signalhandler );
Signal (sigbus, signalhandler );
Signal (sigpipe, signalhandler );
}

 

3. specific instance

1.Http://cocoawithlove.com/2010/05/handling-unhandled-exceptions-and.html

Focus on trying to continue running the program

Tell the user about the crashes caused by these unblocked exceptions and signals, or you can record them on your own, or even avoid these crashes. However, if multiple signals are intercepted, this may fail.

We recommend that you read this article.

2. http://parveenkaler.com/2010/08/11/crashkit-helping-your-iphone-apps-suck-less/

The focus is on record exceptions (then the main thread is returned)

-(Void) Pumprunloop
{
Self. finishpump = no;
Cfrunloopref runloop = cfrunloopgetcurrent ();
Cfarrayref runloopmodesref = cfrunloopcopyallmodes (runloop );
Nsarray * runloopmodes = (nsarray *) runloopmodesref;
While(Self. finishpump = No)
{
For(Nsstring * ModeInRunloopmodes)
{
Cfstringref moderef = (cfstringref) mode;
Cfrunloopruninmode (moderef,1.0f/1200000f,False);//Pump the loop at 120 FPS
}
}
Cfrelease (runloopmodesref );
}
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.