【问题标题】:dtruss with DYLD_BIND_AT_LAUNCH and sshfs mounts in OSX 10.9?在 OSX 10.9 中安装 DYLD_BIND_AT_LAUNCH 和 sshfs 的 dtruss?
【发布时间】:2018-03-19 19:01:23
【问题描述】:

我正在尝试在 OSX 10.9 上的 this gist 构建示例:

cd /tmp
git clone https://gist.github.com/ecfd80885b9ddf6734192c056cf48bf4.git fopentest
cd fopentest
bash buildrun.sh

构建成功 - 此外,我可以在终端输出中看到以下内容:

...
+ DYLD_BIND_AT_LAUNCH=YES
+ ./fopentest.exe ./mytestfile.txt
This is a wrapper function for fopen.
=== this is mytestfile.txt ===
Second line here...
Third line here...

这意味着调用DYLD_BIND_AT_LAUNCH=YES ./fopentest.exe ./mytestfile.txt 成功找到了包装库和函数。

现在,作为一个测试,我想通过dtrussOSX “strace” equivalent 运行这个可执行文件——我还按照该链接中的建议完成了sudo chmod u+s /usr/sbin/dtrace。所以我尝试在/tmp 文件夹中:

$ DYLD_BIND_AT_LAUNCH=YES dtruss ./fopentest.exe ./mytestfile.txt 2>&1 | grep wrap
This is a wrapper function for fopen.
stat64("libwrapper.dylib\0", 0x7FFF5A7DF248, 0x7FFF5A7E00E0)         = 0 0
open("libwrapper.dylib\0", 0x0, 0x0)         = 3 0
write_nocancel(0x1, "This is a wrapper function for fopen.\n=== this is mytestfile.txt ===\nSecond line here...\nThird line here...\n\0", 0x6C)      = 108 0

所以,显然dtruss 在这里有效。但是,我在不同的目录中有完全相同的文件,为什么我尝试运行相同的命令,dtruss 失败:

$ DYLD_BIND_AT_LAUNCH=YES dtruss ./fopentest.exe ./mytestfile.txt 2>&1 | grep wrap
dyld: Library not loaded: libwrapper.dylib
stat64("libwrapper.dylib\0", 0x7FFF4FD85228, 0x7FFF4FD860C0)         = 0 0
open("libwrapper.dylib\0", 0x0, 0x0)         = -1 Err#2
stat64("/Users/MYNAME/lib/libwrapper.dylib\0", 0x7FFF4FD85A08, 0x7FFF4FD860C0)       = -1 Err#2
stat64("/usr/local/lib/libwrapper.dylib\0", 0x7FFF4FD85A08, 0x7FFF4FD860C0)      = -1 Err#2
stat64("/usr/lib/libwrapper.dylib\0", 0x7FFF4FD85A18, 0x7FFF4FD860C0)        = -1 Err#2

这可能是什么原因?

【问题讨论】:

    标签: c macos sshfs dtruss


    【解决方案1】:

    嗯,我想我明白是什么原因了:dtruss找不到库的目录,其实是通过sshfs挂载的; mount 显示该路径:

    MYOTHERNAME@myRemotePC:/media/Test1 on /media/Test1 (osxfusefs, nodev, nosuid, synchronous, mounted by MYNAME)
    

    所以,如果我尝试在/media/Test1/fopentest/ 中调用DYLD_BIND_AT_LAUNCH=YES dtruss ./fopentest.exe ./mytestfile.txt,那么我会得到“dyld: Library not loaded: libwrapper.dylib”。

    但是,如果我将该文件夹移动到“正确”文件系统中的其他位置,例如 $HOME:mv /media/Test1/fopentest ~/,我什至不必重建,我可以在 ~/fopentest/ 中调用 DYLD_BIND_AT_LAUNCH=YES dtruss ./fopentest.exe ./mytestfile.txt 和调用成功...

    不知道为什么会发生这种情况-因此肯定会感谢提供更多信息的答案...

    【讨论】:

      猜你喜欢
      • 2014-05-28
      • 2014-08-23
      • 2014-06-19
      • 2013-12-25
      • 2013-11-30
      • 2014-04-12
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      相关资源
      最近更新 更多