IOS breakpoint and print log, iOS breakpoint print log

Source: Internet
Author: User

IOS breakpoint and print log, iOS breakpoint print log

First, the simplest breakpoint is to add a breakpoint to any line number in the Xcode project file.

Clicking it again turns to light blue, indicating that disable is lost.

The disable breakpoint does not work, but it leaves a record in the blue tag in the upper left corner. All the breakpoints you set are recorded here, then you can click here to enable some breakpoints in the light blue position.

To Delete a Breakpoint, you just need to right-click the Breakpoint and choose Delete Breakpoint. You can also left-click the Breakpoint and drag it out to loosen it. A dust bubble will appear; you can also right-click the breakpoint on the tab and delete it.

After a breakpoint is set, the program will be executed again. The program stops compiling to the breakpoint, and such a picture is displayed. here we can see some parameters. self represents the current object, others are the method or the objects allocated in the stack when the current statement is executed.

To view more objects, click all in the lower left corner.

Lldb on the right is a debug tool. You can enter some commands to print some information. The information on the Left can be printed here.

You can enter the po (pring project) to print the object and p (pring) to print some basic types or struct.

If you do not like the command line, you can right-click a line on the left and select Pring Description

In this way, it will be printed in lldb like a command line on the right.

Lldb also has many features. You can enter lldb in the official documentation of Apple to view the features.

There are many commands in the above Debug. Continue indicates that the operation continues; continue to current line indicates that the operation continues to the current row; step over indicates that the operation does not enter the current method. step into indicates that the operation enters the method; step out is the opposite of step. There are also step over instruction and step into instruction. instruction indicates the meaning of the instruction and the instruction of the CPU. If you want the instruction of the single-step CPU, you can click them. They are the instruction-level step; as for step over thread and step into thread, it indicates that the thread is only executed in the current thread, and other threads are stopped. This is mainly used in debug multithreading to prevent interference from other threads.

Next we will introduce some advanced breakpoint usage.

Find a loop, such as a for loop, set a breakpoint in it, right-click and select edit breakpoint to customize the breakpoint. Here there are some parameters, and condition indicates a condition, if this condition is met, the program is disconnected. ignore indicates how many times ignore is terminated. action can be used to add an action, for example, debugger command. You can enter an lldb command, when the program is disconnected, this action is executed. If the last options option is selected, the action is executed continuously after the program meets the conditions.

Sometimes we want to know when something happens, but we cannot determine which line of code it is in. At this time, we need more advanced breakpoints. There is a plus sign in the lower left corner of the breakpoint interface. Click it and select add exception breakpoint. exception indicates an exception.

Then an all exceptions is displayed, and some options are displayed. For the first exception, you can select object-c, c ++, and all. Generally, you can select all; break can be disconnected when an exception is thrown or an exception is handled. The default value is throw. action and options are the same as previously mentioned. It is best to add such a breakpoint to the Project for backup.

Next, let's talk about another breakpoint. In the lower-left corner of the breakpoint interface, select add symbolic breakpoint, which is a symbolic breakpoint.

Some options will also be provided when you set it. You can write a method in symbol, which indicates that the program is disconnected when the program runs the method. The module indicates that it is in the class library or executable program; the following is the same as the previous one.

The breakpoint of the Debug version mentioned above, as well as the breakpoint of the release version, select edit scheme in

Select release here and optimize the breakpoint running program in release. The information may not be very useful and the order may be different from the original one, the Debug version runs faithfully in order, so the release execution speed is faster, but we usually use the Debug version for development. When your program is to be released, use the release version, ensure that you use your release version, because it has better performance than the Debug version, it runs faster, and the running file is smaller.

In some cases, resumable upload is not suitable. For example, some bugs only appear in the release version, while debugging is normal. Multi-task and multi-thread programs. Real-time requirements are high, such as time-dependent; the client and server architecture; there are also processes, when a process depends on the process you want to set a breakpoint. In this case, another method is used to print logs ).

Native Printing includes NSLog, which can be printed both in Debug and release versions. Cocoas2d has a CCLog that can be printed normally in Debug, and a blank statement is executed in release, because printing is troublesome, release must ensure performance.

Timestamp printing tool functions:

Static double gBaseTime = 0.0;

Void logCurTimeStamp (NSString * comment)

{

Double cur_time = [[NSDate date] timeIntervalSince1970];

Double time_past = cur_time-gBaseTime;

GBaseTime = cur_time;

NSLog (@ "[% @] cur time = %. 4f", comment, time_past );

}

The above content is from the Ding group video at http://www.maiziedu.com/course/cocos2d/246-2161 /.

Related Article

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.