Xcode Breakpoint Debugging

Source: Internet
Author: User
Tags print object

Basic Breakpoint

For example, this is the most commonly used breakpoint and is also the easiest to set. Left-click to set it up.

Edit Breakpoint

Breakpoints can be edited.

Breakpoints have several properties that you can set:

    • Condition

    • Ignore

    • Action

    • Options

Condition

The conditional expression can be entered here, and the breakpoint will take effect when the condition is met. For example, enter a = = 50 above. This is a very useful setting, especially when debugging in the loop, with really cool.

Ingore

Here you can set the number of ignored breakpoints.

Action

Action is the most complex and powerful feature here. The action has a type of 6. Such as

    1. AppleScript

    2. Capture GPU Frame

    3. Debugger Command

    4. Log Message

    5. Shell Command

    6. Sound

Log message and debugger Command are commonly used.

Log Message

The things you fill out here can be printed to the console. For example I made the following settings:

%b will print the name of the breakpoint,%h will print the number of calls to the breakpoint, @@ the middle can enter an expression. The above settings in the console output are as follows:

Debugger Command

Here you can enter debug commands, which are PO (print object information), BT (print function stack), expression (expressions) these debug commands. Look at the picture to understand:

The image console output is as follows:

Options

After checking automatically continue after evaluating actions , the program will continue to run after the breakpoint has been generated. This property is quite useful in that you can enter debug information as far as the program is not paused.

Out of the basic breakpoint above, Xcode also provides the following four kinds of breakpoints, you need to click on the lower left corner of the breakpoint panel to add the + sign.

    • Exception Breakpoint

    • OpenGL ES Error Breakpoint

    • Symbolic Breakpoint

    • Test Failure Breakpoint

Exception Breakpoint

Exception Breakpoint is a very useful breakpoint entry. As the name implies, a breakpoint is generated when the program throws an exception. Usually a program crash stops at the point where it crashes, but sometimes it doesn't stop exactly where it's causing the exception. such as array out of bounds! As I've shown, it causes an array of cross-border access.

The program will crash when it runs. But the crash stopped in the main function, even if you look at the stack information can not immediately navigate to the end of the array is the cross-border access. Why does the crash fail to stop in the array where it crosses? This is because an array out-of-bounds access does not necessarily cause the program to crash, and an array out-of-bounds access causes an exception to be thrown, and the thrown exception is not processed to cause the program to crash. As a result, the crash stops inside the corefoundation framework. This time you need to set exception breakpoint to create a breakpoint to locate the error.

OpenGL ES Error Breakpoint

This is mainly OpenGL ES breakpoint debugging, this person is useless.

Symbolic Breakpoint

Symbolic breakpoint, symbolic breakpoint, is really debugging artifact ah. Breakpoints are generated when a program runs to a specific symbol. Adding breakpoints in this way does not need to be added to the source file, nor does it need to know where the breakpoint is set in the first line of the file.

Two more attribute symbol and module than normal breakpoint.

Symbol

The contents of the symbol can be as follows:

1. Method Name: All class methods that have this method name will take effect. For example initWithFrame:.

2. Methods for a particular class: The OC class and the C + + class are applicable, for example, [UIView initwithframe:] or Shap::d Raw ().

3. Function name. For example, ordinary C functions.

By setting the symbol to debug, easy to stop, how to break the breakpoint on how to break.

Test Failure Breakpoint

This type of breakpoint pauses the execution of the program when test assertion fails.


Xcode Breakpoint Debugging

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.