1. Common breakpoint
Click on the line number to add the most commonly used breakpoint, omitted.
2. Conditional breakpoint
Most of the time, the problem code is called frequently until there is a problem under specific conditions. In this case, conditional breakpoints can be used.
Right click any breakpoint and select Edit breakpoint to edit the condition.
3. Symbolic breakpoint
Sometimes we have no source code, only header file, not convenient to add ordinary breakpoints, you can use symbolic breakpoints. In the breakpoint interface, click + and select ad symbolic breakpoint to add a symbolic breakpoint.
4. Abnormal breakpoint
The breakpoint when objc exception is thrown is of limited use because there are very few scenarios in which objc can catch exception.
Common commands of lldb
- Print a value / object
- Call a method and output the return value
- Executing an expression is often used to change data and construct a specific scene at runtime
- Print current stack information
Learn more about IOS — debugging tool lldb
It is used to analyze the problem of wild pointer.
The problem of wild pointer leads to a lot of strange crash stacks. The basic reason is that after the object is released, the corresponding memory is not sure when and how much it will be covered, resulting in normal or crash access later.
Zombie object is the way to eliminate this uncertainty. When the object is released, a zombie class will be generated, and the ISA in the corresponding memory will be replaced, pointing to the zombie class. In this way, the object can be captured 100% when it is accessed through a wild pointer.
This function can be opened in “Edit scheme…” – > “run” – > “diagnostics” – > “zombie objects”. It should only be used in debugging, which has a great impact on performance.
Address sanitizer is a lower level method. Zombie objects are only valid for wild pointers of objc objects, while address sanitizer can check for any memory access errors. Typical scenarios, such as C array out of bounds.
Time profile is used to detect CPU usage time and optimize performance.
If there is a performance problem with an operation, you can start time profile record before the operation and stop after the operation. The time profile records the CPU time spent by all methods during the period and arranges them from high to low. So we can easily find the bottleneck of energy consumption and optimize it.
The allocations tool is used to analyze memory problems.
After the application is started, you can see all the sources of memory growth before and after a specific operation.
It is very convenient to locate the memory problems that can be reproduced.