macOS:幾個用於排錯的命令和工具
1. 系統程式:Console.app - 控制檯
2. 系統程式:Activiy Monitor.app - 活動監視器
3. 執行命令:sudo fs_usage,使用control+c停止,它實時顯示系統呼叫和檔案頁的錯誤等資訊。
4. 執行命令:sudo syscallbypid.d,看看那個程式系統呼叫對多。
5. 執行命令:sysdiagnose。這個相當的強大而全面,它會生成一個系統全方面(可以說是最全)的測試報告,並以zip格式儲存在/var/tmp/目錄中。都包括什麼,看看它的線上幫助資訊吧:
o A spindump of the system
o Several seconds of fs_usage ouput
o Several seconds of top output
o Data about kernel zones
o Status of loaded kernel extensions
o Resident memory usage of user processes
o All system logs, kernel logs, opendirectory log, windowserver log, and log of power management events
o A System Profiler report
o All spin and crash reports
o Disk usage information
o I/O Kit registry information
o Network status
o If a specific process is supplied as an argument: list of malloc-allocated buffers in the process's heap is collected
o If a specific process is supplied as an argument: data about unreferenced malloc buffers in the process's memory is collected
o If a specific process is supplied as an argument: data about the virtual memory regions allocated in the process
o If Mail is the process supplied as an argument: your email address, account configuration, mailbox identifiers, the number of characters in the
subject line of emails, the sent and received times of emails.
不過注意的是,有些資訊是指採集一小段時間的,所以要想詳細獲得具體的長時間段資訊,需要單獨執行。
6. 執行命令: sudo footprint -a。蒐集每個CPU核的記憶體使用資訊。
7. 執行命令: vm_stat。顯示虛擬記憶體的統計資訊
8. 執行命令: spindump。會在/var/tmp/DiagnosticReports/中生成當前系統的特徵,比如核心以及驅動等
9. 執行命令: zprint。顯示核心的情況
10執行命令:newproc.d和。newproc.d會監視新建的程序執行情況; creatbyproc.d使用程序名,它們都使用DTrace,所以在10.11以上版本需要之一SIP。
11執行命令:sar。蒐集系統活動
對於眾多命令,請詳見線上man幫助