Recently, the drop grid input method has encountered several difficult to reproduce problems-the key is that it will not cause a crash。This makes the crash statistics function completely ineffective,The specific performance is that the input method will suddenly get stuck for a few seconds in some cases,Very annoying。Then I thought,macOS comes with activity manager,There is a "sampling" function,You can see the current execution (call) status of the corresponding process,Can I use it to analyze the cause of the error?
After communicating with users,I got a sampling report like this:
1 2 3 4 5 6 7 8 9 10 |
2713 -[IMKSignPostInputController deactivateServer:] (in InputMethodKit) + 326 [0x7fff471f91eb] + 2713 ??? (in LogInputMac2) load address 0x102d32000 + 0x22fb1 [0x102d54fb1] + 2713 ??? (in LogInputMac2) load address 0x102d32000 + 0x22aa3 [0x102d54aa3] + 2713 ??? (in LogInputMac2) load address 0x102d32000 + 0x3b586 [0x102d6d586] + 1774 ??? (in LogInputMac2) load address 0x102d32000 + 0x64a7c [0x102d96a7c] + ! 1774 -[IMKTracingTextInput stringFromRange:actualRange:] (in InputMethodKit) + 197 [0x7fff4714b4e1] + ! 1774 os_activity_apply_f (in libsystem_trace.dylib) + 66 [0x7fff20333811] + ! 1774 __51-[IMKTracingTextInput stringFromRange:actualRange:]_block_invoke (in InputMethodKit) + 94 [0x7fff4714b58a] + ! 1774 __51-[IMKTracingTextInput stringFromRange:actualRange:]_block_invoke_2 (in InputMethodKit) + 70 [0x7fff4714b5f5] + ! 1774 -[IMKLoggingTextInput stringFromRange:actualRange:] (in InputMethodKit) + 192 [0x7fff471d8b76] |
After executing the code of my program,I got to the stuck place soon,Obviously,It should be an API I called that triggered a system bug or something,So as long as I can find out where it is called,What was called,It should be easy to locate the problem,Specific to this example,It is 1774 ??? (in LogInputMac2) What does it represent。
So look at the address behind,I guess it should be similar to the crash log,It also needs dSym to resolve,Only this time there is no ready-made function to use,We need to manually calculate this address (of course, just manually call the lower level tool,Real hands are still unnecessary)
acts
The atos command comes with Xcode,Various tools we use to automatically parse crash logs,Build on top of it,So the first step,We first find the corresponding dSym file (hope you can find it)。
After getting the file,We use the command to parse its uuid,Must be consistent with the results in the sampled data:
1 2 |
Binary Images: 0x102d32000 - 0x102e79fff +com.logcg.inputmethod.LogInputMac2 (2.4.3 Beta - 2340) <21095D7E-0244-3994-9322-6F4A99BCD198> /Library/Input Methods/LogInputMac2.app/Contents/MacOS/LogInputMac2 |
Below the sampled data,Binary image,This shows the version of your program and its uuid。After finding the corresponding dSym,We use the command xcrun dwarfdump --uuid LogInputMac2.app.dSYM/Contents/Resources/DWARF/LogInputMac2 To view the architecture and corresponding uuid contained in dSym,For example, mine is:
1 2 3 |
$xcrun dwarfdump --uuid LogInputMac2.app.dSYM/Contents/Resources/DWARF/LogInputMac2 UUID: 21095D7E-0244-3994-9322-6F4A99BCD198 (x86_64) LogInputMac2.app.dSYM/Contents/Resources/DWARF/LogInputMac2 UUID: 77AC203D-8F6F-3486-B1AE-3F3AB539A8A3 (arm64) LogInputMac2.app.dSYM/Contents/Resources/DWARF/LogInputMac2 |
You see,Corresponding to the sample is the one of x86_64。
Then we enter the interactive mode of atos,First find the start point of the virtual address of your program,For example, in this line 2713 ??? (in LogInputMac2) load address 0x102d32000 + 0x22aa3 [0x102d54aa3] My starting point is 0x102d32000 You will find in other lines,The starting point is the same,Only the address behind is different,After getting this starting point,We execute the order:
1 |
atos -arch x86_64 -o "LogInputMac2.app.dSYM/Contents/Resources/DWARF/LogInputMac2" -l 0x102d32000 |
At this time, the terminal enters the prompt state,Show nothing inside,Then we can enter the actual address for conversion,Or the line 2713,The address in square brackets at the end is the actual address where the program runs,We enter it,atos will display the corresponding code according to your dSym file。
Because it's interactive mode,You can continue to enter other addresses,No need to repeat commands:
1 2 3 4 5 6 7 8 9 10 11 |
$atos -arch x86_64 -o "LogInputMac2.app.dSYM/Contents/Resources/DWARF/LogInputMac2" -l 0x102d32000 0x102d54fb1 @objc LogInputController.activateServer(_:) (in LogInputMac2) + 97 0x102d54aa3 LogInputController.deactivateServer(_:) (in LogInputMac2) (<compiler-generated>:0) 0x102d6d586 TouchBarCandidateController.displaySmartHint() (in LogInputMac2) (TouchBarCandidateController.swift:48) 0x102d96a7c IMKTextInput.stringBeforeInput.getter (in LogInputMac2) (EnhancedTextInput.swift:119) 0x102d96a47 IMKTextInput.stringBeforeInput.getter (in LogInputMac2) (EnhancedTextInput.swift:116) |
References
Original article written by LogStudio:R0uter's Blog » macOS uses the atos command to parse arbitrary crash records and sample data
Reproduced Please keep the source and description link:https://www.logcg.com/archives/3475.html