“This is the fifth day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

Introduction to the

LLDB is a Debugger built into Xcode. It supports C, C++, object-c and other languages. It supports OSX and iOS.

What are the capabilities of LLDB? A brief summary is:

  1. Runs the program under specified conditions
  2. Stops the program under the specified condition
  3. View events that occur within a program while it is stopped
  4. Modify the program when it is stopped and observe the changes

LLDB has no graphical interface and is operated by commands. Of course, as an iOS developer, the LLDB command often used is Po, which prints the data stored in the current memory by specified variables

Common commands

P, Po

P and Po are still different

(LLDB) p aa (CGFloat) $8 = 20 (LLDB) Po aa 20 (LLDB) p bb (__NSCFString *) $19 = 0x0000608000437660 @" This is a String "(LLDB) Po Bb this is a stringCopy the code

The difference is Po: output value p: output value + value type + reference name + memory address

expression

Expression is used to modify the program when it stops

//expression Printed value (LLDB) expression aa (CGFloat) $10 = 67 //expression Modified value (LLDB) expression aa = 80 (CGFloat) $11 = 80 P aa (CGFloat) $12 = 80 (LLDB)Copy the code

Expression is short for exp

call

Call’s job is to actively invoke a method and print the return value

(LLDB) Call AA (CGFloat) $12 = 70 (LLDB) Call BB (__NSCFString *) $16 = 0x0000608000437660 @" I am a String"Copy the code

bt

Bt function is to view of course the program stack information, stack information is generally very long, if too long and words can use BT 10 to limit the number of printed stack, view the current stack information can effectively know the current program is what method call chain, so as to find the problem.

image lookup

When crashes occur during normal development, Xcode prints out the current stack information on the console, which can sometimes be used to find the problem and correct it. But a lot of times it’s not clear what the problem is, right? How do you check?

image lookup -a 0x00000001009a9f3a

Using this command, you can check which file and line the current crash is in, which makes it easy to locate the specific problem

conclusion

Of course, LLDB has many powerful functions, and I am just an apprentice. If you have better opinions, please send them to the comment section. We can learn and make progress together.