views:

366

answers:

3

I know of otool -tv, but I would much rather use the Intel syntax rather than AT&Ts, mainly to easily follow along in a book and not have to look over thousands of %'s and $'s.

I'd also appreciate any tips to where I might find gdb's config file.

EDIT: I forgot: I'm running a 64bit processor, but was wondering if it would be possible to also disassemble into 32 bit assembly? Not only that, but does OSX's gdb's list command work differently than the standard GNU version?

Thanks so much!

(Also, if you have any idea where I might find a little disassembler from C -> MIPS, that'd be very fun to play with. But not necessary!)

A: 

You can use A2I to translate from AT&T to Intel syntax: http://membres.lycos.fr/placr/a2i.html

Victor Hurdugaci
That's not quite what I'm looking for – the syntaxes are both easy enough to read. It's more a matter of making my life easier; using A2I adds steps I'd rather not take, for little reward. Thank you though!
Isaac Hodes
A: 

With Objdump you can disassemble with -d -M intel, and apparently -m can be used to specify the architecture.

Bastien Léonard
I understand that - unfortunately objdump doesn't work on/doesn't come with OSX.
Isaac Hodes
+1  A: 

To answer your second question, if the code has been compiled into a fat binary with both 64-bit and 32-bit, you can use otool -arch i386 -tv to disassemble the 32-bit slice of the binary; otool -arch x86_64 -tv will give you the 64-bit portion (on SnowLeopard, this is also the default behavior if no -arch flag is passed).

Also note that while otool doesn't support the Intel syntax, gdb (set disassembly-flavor intel) and XCode (Preferences -> Debugging -> Disassembly Style) do.

Stephen Canon
Thanks! I'll go with this, though I'm still curious about MIPS :) Too bad about `otool` not supporting Intel's syntax.
Isaac Hodes
If it's an obstacle for you, you should file a bug requesting that the feature be added (you'll need to set up an ADC account if you don't already have one): developer.apple.com/BugReporter
Stephen Canon