Po command: the abbreviation of print object. The text description of the displayed object shows the string information obtained from the description message of the object ).
For example:
, I use the po command to display the content of an NSDictionary. Note: On the left side, we can see some information about dict: 3 key/value pairs, showing the data volume contained in the dict, and the expanded information shows the isa hierarchy, that is, the relationship between class and metaclass ). Right-click dict on the left and select "Print Description of" dict ". The dict details can be output on the console:
View plaincopyprint?
Print command: It is similar to formatting output, which can output different object information:
For example:
[Cpp]View plaincopyprint?
Note: 4 is the value of NSUTF8StringEncoding.
Info command: We can view the information of the memory address.
For example"Memory Address of info symbol"You can obtain the information about the symbol where the memory address is located:
[Cpp]View plaincopyprint?
For example"Info line * Memory Address"You can obtain the code line information of the memory address:
[Cpp]View plaincopyprint?
Show command: Displays information about GDB. For example, show version displays the GDB version.
[Cpp]View plaincopyprint?
Help Command: if you forget the syntax of a command, you can use the help command name to obtain help information. For example, help info shows the usage of the info command.
[Cpp]View plaincopyprint?
Set a breakpoint when a system throws an exception
Sometimes our program doesn't know where it is to run and crash is hard to reproduce. A conservative approach is to set a breakpoint before the system throws an exception. Specifically, it is to set a breakpoint at the objc_exception_throw. Step 1: Press CMD + 6 in XCode to go To the Breakpoint Management window. Click + in the lower right corner to add a new Symbolic Breakpoint. In the Symbol column, enter objc_exception_throw, click done. In this way, in Debug mode, if the program is about to throw an exception, the exception will be interrupted. For example, in the previous code, I asked [firstObjctcrashTest]; To throw an exception. After the breakpoint is set at objc_exception_throw, the program will be interrupted at this code, so that we can know where the code is going wrong.