简体   繁体   中英

dtruss with DYLD_BIND_AT_LAUNCH and sshfs mounts in OSX 10.9?

I'm trying to build the example at this gist on OSX 10.9:

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

The build succeeds - and furthermore, I can see the following in the terminal output:

...
+ 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...

That would mean that the call DYLD_BIND_AT_LAUNCH=YES ./fopentest.exe ./mytestfile.txt successfully found the wrapper library and function.

Now, just as a test, I'd like to run this executable through dtruss , OSX “strace” equivalent - I've also done sudo chmod u+s /usr/sbin/dtrace as recommmended in that link. So I try in the /tmp folder:

$ 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

So, clearly dtruss here works. However, I have the exact same files in a different directory, and why I try to run the same commands, dtruss fails:

$ 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

What could possibly be the reason for this?

Hm, I think I understand what the reason is: the directory where dtruss fails to find the library, is actually mounted via sshfs ; mount shows this for that path:

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

So, if I try to call DYLD_BIND_AT_LAUNCH=YES dtruss ./fopentest.exe ./mytestfile.txt in /media/Test1/fopentest/ , then I get the " dyld: Library not loaded: libwrapper.dylib ".

However, if I move that folder elsewhere in the "proper" filesystem, say in $HOME : mv /media/Test1/fopentest ~/ , I don't even have to rebuild, I can just call the DYLD_BIND_AT_LAUNCH=YES dtruss ./fopentest.exe ./mytestfile.txt in ~/fopentest/ and the call succeeds...

Not sure why this happens - so a more informative answer will definitely be appreciated...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM