XCode debugging sets a Global breakpoint and quickly locates the row of the problematic code

Source: Internet
Author: User

XCode debuggingTip settingsGlobalThe line where the breakpoint is located and the problem code is located is described in this article.DebuggingWhen the program is running, we would like to immediately know which line of the error code is. Instead of setting a breakpointDebuggingFind the line of code that eventually caused the program to crash. You can use the following method to quickly locate the problem code.

Method 1:

Select Run> Show> Breakpoints to go To the breakpoint window.

Xcode breakpoint window

First, you must create a breakpoint for-[NSException raise. Select Global Breakpoints, Double-click for Symbol, enter-[NSException raise], and press return.

After the breakpoint-NSException raise is added

Next, add another Global breakpoint objc_exception_throw according to the preceding steps.

When an exception occurs in a running program, the debugger stops running the program and points to the problematic code line.

Method 2:

There are many exceptions, and the program will exit directly if the breakpoint cannot be normally accessed, for example:

At this time, we do not even know where this error occurs. OK, Open Run> Debugger to find the exit position of the program:

Then Add a soft breakpoint Run-> Manage Breakpoints-> Add symbolic breakpoint and enter objc_exception_throw

Run againDebugging:

Is it easy to find the error :)

The first method is available, and the second method can also be used...

Summary:XCode debuggingSetGlobalThe contents of the line where the breakpoint is located and the problem code is located are described. I hope this article will help you!

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.