MacBook Pro
I got my work supplied MacBook Pro last week, and I've got two words... AWE-SOME! It's waaaay fast. On my dual 2GHz G5, Firefox bounces the dock icon about 5-8 times before opening. With the new universal Firefox binary, it bounces 1-2x on my MBP! That's friggin' fast! Now, I don't actually use Firefox (mostly because it's historically been too slow to start), but it's still an interesting measure.
Here's a few other interesting little tid-bits I came across on my first run through the new system:
- You can tell if an application is universal by looking at the "Get Info" window in the Finder, or by using the
filecommand from the Terminal. And you can tell if a process is actually running under Rosetta at runtime because/usr/libexec/oah/translatewill be mapped into its address space. Justlsof -p PID | grep translate
You can run an application under Rosetta from the command line by using the command/usr/libexec/oah/translate. For example:/usr/libexec/oah/translate /bin/ls
- On PPC functions arguments are passed in CPU registers starting with $r3. So, the function call
foo(1, 2, 3)would have0x1in$r3,0x2in$r4, etc. On Intel function arguments are passed on the stack, so the function callfoo(1, 2, 3)would have0x1at$ebp+8,0x2at$ebp+12, etc.
In Objective-C, a method call like[foo add:5]actually gets compiled into a C function call likeobjc_msgSend(self, @selector(add:), 5)
And as we just saw, Intel Macs pass function arguments on the stack. So, the standard way to print "self" ingdbon a PPC Mac ispo $r3
(remember,$r3has the first argument on PPC -- "self"), but on Intel it turns intopo *(int *)($ebp+8)
(poisprint-object).
If you need to debug (usinggdb) a PPC binary on an Intel Mac, you can do some basic stuff by setting theOAH_GDBenvironment variable toYES, then starting the application. Then in a new window, start gdb likegdb --oah
then use gdb'sattachcommand to attach to the running process like normal. This will even show you PPC style registers and stuff in gdb. Pretty cool for basic debugging.


7 comments:
Luckeee.
Check your comment spam, mate!
I just obtained a MacBook Pro, and I wanted to make sure I had updated all my startup apps, at least, to universal. I ran 'lsof | grep -i translate' and found one I had missed (SSHKeychain), and I thought that was the end of it.
Later, it occured to me that I was running an old version of OSXvnc that wouldn't be intel-friendly. I checked, and sure enough, I'm running 1.5, and universals started with 1.7.1. So I know it's using rosetta because of the version, but I can't find a way to check for it. I'm just worried I'm missing other apps that work in the same way.
I did 'lsof | grep -i translate' while maintaining an open vnc connection, and I couldn't find it. I also couldn't find it grepping lsof for 'vnc'. I got both the parent and child (from the active connection) PIDs from 'ps auxww | grep -i vnc', but nothing turned up when I 'lsof -p' with each of those PIDs. Is there any other way to check to see what's running under Rosetta? I know OSXvnc has to be running that way, but it's not turning up using your method.
I don't have my mbp w/ me right now, but you may also be able to look at the VM map for the process in question to see if translate is mapped in. Something like vmmap pid | grep -i trans
That didn't work (even with -w), but I found the real problem from before. It's kind of dumb. I just forgot to run lsof as root. Your original method works fine.
Also, vmmutils busts some warnings when running vmmap on rosetta apps vs. native ones, so there is a difference in the result. I actually wrote a script to extract PIDs using that error output before I realized that the real problem was running lsof under my user account.
Thanks for the reply! And thanks a lot for the blog entry! It's very useful.
Post a Comment