This paper introduces three methods:

  1. Symbol breakpoints and processes
  2. Hold down thecontrol+step into
  3. Assembly and flow

Take the alloc method as an example.

1. Break point

Type alloc in the symbol breakpoint

SSPerson alloc in the ViewController, put a breakpoint. Before we reach this point, we need to close the new symbol breakpoint above, because there are many calls to alloc, and if it is on, it will not be able to accurately locate SSPerson’s alloc method

The status of the breakpoint on and off

When the breakpoint reaches alloc, the symbol breakpoint is opened and execution continues

The following figure shows a stack call where the alloc symbol is broken. It can be seen that the source code of alloc is located in libobjc.a. dylib (you need to go to Apple’s corresponding open source website to download the objc source code for further exploration).

2. Hold down thecontrol+step into

In the same way, the program executes at the breakpoint SSPerson alloc

Hold down the Control key and select step into ⬇️

After entering, the display is as follows:

After the next objc_alloc symbol break point, you can see the source library for objc_alloc (you need to go to Apple’s corresponding open source website to download the objc source code for further exploration).

3. Assembly and process

In the same way, the program executes at the breakpoint SSPerson alloc

Xcode toolbar select Debug –> Debug Workflow –> Always Show Disassembly. This option indicates that Disassembly will Always be displayed, i.e. by assembly and flow

Hold down Control and click Step into ⬇️ to execute callq as shown in the following figure, corresponding to objc_alloc

Hold down Control, hit Step into ⬇️, and you see the break point in the objc_alloc section

(You need to go to Apple’s corresponding open source website to download the objc source code for further exploration.)

PS: Apple provided source download address

1, opensource.apple.com Apple all opensource source summary address. Consult the corresponding source code, according to the corresponding version in MAC 10.15, for example: macOS – 10.15 – > 10.15 – > select search objc 2, opensource.apple.com/tarballs/ Apple more direct source download address. Search directly for the source name you want to download, such as objc: search directly for objc –> objC4 / –> select the appropriate version of objC