标题:[实践OK]macbook上的ldd的替代,mac下的strace命令,mac下的strace命令。 出处:向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除 时间:Tue, 26 Nov 2019 10:10:39 +0000 作者:jackxiang 地址:http://jackxiang.com/post/10354/ 内容: 一、Linux下经常会用到ldd查看程序使用了哪些共享链接库,很方便的一个工具,在Mac OS X上没有这个命令,如果想在Mac OS X查看程序使用了哪些链接库可以用otool 来代替。 otool -L `which nginx` /usr/local/bin/nginx: /usr/local/opt/pcre2/lib/libpcre2-8.0.dylib (compatibility version 12.0.0, current version 12.0.0) /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0) /usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3) 来自:http://t.zoukankan.com/amoy9812-p-12322060.html 二、Linux中的strace可以查看程序运行时的系统调用,有时对于调试程序很有帮助,Mac OS X中可用dtruss (需要root)替代 sudo dtruss strace在linux下用来跟踪某个进程的系统调用 在solaris下,对应的是dtrace 在mac下,对应的命令是:dtruss sudo dtruss -p 770 dtrace: system integrity protection is on, some features will not be available SYSCALL(args) = return kevent(0x8, 0x0, 0x0) = 0 0 kevent(0x8, 0x0, 0x0) = 0 0 链接如下: 一)在Mac OS X查看程序使用了哪些链接库可以用otool 来代替: otool -L /usr/bin/vim /usr/bin/vim: /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0) /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1) 来自:https://www.dazhuanlan.com/2019/10/10/5d9ecd060ead4/ 二)   dtruss df -h       # run and examine "df -h"        dtruss -p 1871     # examine PID 1871        dtruss -n tar      # examine all processes called "tar"        dtruss -f test.sh  # run test.sh and follow children 链接:https://blog.csdn.net/sanbingyutuoniao123/article/details/73955092 实践有些问题,如下: dtruss df -h dtrace: system integrity protection is on, some features will not be available dtrace: failed to initialize dtrace: DTrace requires additional privileges Generated by Jackxiang's Bo-blog 2.1.1 Release