Hotspot7 hsdis PrintAssembly Intel Syntax
Asked Answered
H

2

15

It annoys me every time I use -XX:+PrintAssembly with Hotspot and have to read the horrible AT&T syntax.

Is there a way to tell it to use the Intel syntax?

Hereabouts answered 18/2, 2012 at 1:25 Comment(4)
By the way, Which system are you running on?Dex
@Pavan As I understood there was one binary for all OSes so I hoped I could get a crossplatform working way. Mostly openSUSE and Windows though. Sadly as your answer indicates - if I can pass such an option while compiling, I doubt there's any better way to do that. Will try that.Hereabouts
For windows, you should be getting intel syntax by default!?Dex
@Pavan Oh right you are, just tested it there. The "mostly openSUSE" is true enough - I just thought I had the same problem under Windows as well and didn't test it there specifically again. Interesting that they default to different options there.Hereabouts
P
25

All you need is to parse some options onto the dis-asm.h and binutils code

For intel Asm (which I also prefer) just add the following

-XX:PrintAssemblyOptions=intel

If you need to combine options do it with commas like so

-XX:PrintAssemblyOptions=intel,hsdis-help

Anything not recognised as a hsdis option will be fed to the disassembler, these options are the same ones you see listed from

objdump --help

... <SNIP A lot of --help text %<> ...
The following i386/x86-64 specific disassembler options are supported for use
with the -M switch (multiple options should be separated by commas):
  x86-64      Disassemble in 64bit mode
  i386        Disassemble in 32bit mode
  i8086       Disassemble in 16bit mode
  att         Display instruction in AT&T syntax
  intel       Display instruction in Intel syntax
  att-mnemonic
              Display instruction in AT&T mnemonic
  intel-mnemonic
              Display instruction in Intel mnemonic
  addr64      Assume 64bit address size
  addr32      Assume 32bit address size
  addr16      Assume 16bit address size
  data32      Assume 32bit data size
  data16      Assume 16bit data size
  suffix      Always display instruction suffix in AT&T syntax
Report bugs to <http://www.sourceware.org/bugzilla/>.
Pursley answered 28/2, 2012 at 8:2 Comment(1)
Wow that's just great! Though they could really mention that somewhere - even knowing that it should be PrintAssemblyOptions I can't seem to find any documentation about that with google.Hereabouts
D
2

I don't think there's any existent way to do this. But this is what I've found- Here is the source of hsdis. You can change the Makefile by passing -masm=intel to GCC. And if it works, from now onwards, +PrintAssembly should start outputting Intel syntax assembly.

Here is the step by step procedure to get the source, build and finally get the hsdis-arch.so which is the one which does the disassembly work!

I haven't tried this out myself. I wish you get this to work :)

If nothing works, this should make you comfortable with AT&T Syntax :)

Dex answered 21/2, 2012 at 9:26 Comment(6)
Thanks, but where exactly would I add -masm=intel in the makefile? I just did CFLAGS += -masm=intel but that doesn't do the trick.Hereabouts
CFLAGS is the right place, but I am not sure why isn't it working for you. Is the hsdis-arch.so getting generated? Any difference in it after adding this debug option?Dex
The so file is generated just fine, but the output is the same as without it (ie still AT&T) - also no error messages. And yes I do have nasm installed in my path if that's important?Hereabouts
@Hereabouts Oops! We're wrong! The reason why it isn't working is that- By adding -masm=intel to this Makefile we are changing the compilation environment for hsdis files and NOT affecting the disassembly process of your Java files!!Dex
But lets not give up!(Your bounty is too tempting :)) I have one more simple method in mind, but I want some inputs from your side. How are you invoking Hotspot? From the shell? From GUI shortcut? Or from inside a shell script? If you are using GUI shortcut, please run it once from shell and paste the command here!Dex
I'm just running java -XX:+UnlockDiagnosticVMOptions -XX:PrintAssembly from bash - so pretty standard I'd think.Hereabouts

© 2022 - 2024 — McMap. All rights reserved.