Ruby -> to x86 assembly instructions?

Hey folks,

How can I take, say, the opcodes generated by the following, and translate
them into actual x86 assembly instructions?

RubyVM::InstructionSequence.compile_file("MyTest.rb").disasm

Or more generally, given a ".rb" file how can I see its x86 instructions
(compiled form).

···

--
Arvind Kalyan
http://www.linkedin.com/in/base16
cell: (408) 761-2030

YARV bytecode is interpreted (by a stack machine), not compiled.

That said I'm mentoring a GSoC project which is attempting to translate
YARV bytecodes to LLVM's IR, which can then be directly translated to x86
bytecodes

···

On Tue, Jun 30, 2015 at 5:50 PM, Arvind Kalyan <base16@gmail.com> wrote:

Hey folks,

How can I take, say, the opcodes generated by the following, and translate
them into actual x86 assembly instructions?

RubyVM::InstructionSequence.compile_file("MyTest.rb").disasm

Or more generally, given a ".rb" file how can I see its x86 instructions
(compiled form).

--
Arvind Kalyan
Arvind K. - Amazon | LinkedIn
cell: (408) 761-2030

--
Tony Arcieri

Thanks. I am interested in the h/w instructions purely from
knowledge/introspection/debugging point of view. To clarify, I'm not trying
to execute the compiled ".rb" file.

If you (or anyone else on the thread) have tools that works for you for
this requirement, please share.

Even if there's a command-line flag (that I'm unaware of) to the RubyVM to
spit out the instructions on the fly as it executes, that'd be awesome.

Thanks.

···

On Tue, Jun 30, 2015 at 6:03 PM, Tony Arcieri <bascule@gmail.com> wrote:

YARV bytecode is interpreted (by a stack machine), not compiled.

That said I'm mentoring a GSoC project which is attempting to translate
YARV bytecodes to LLVM's IR, which can then be directly translated to x86
bytecodes

On Tue, Jun 30, 2015 at 5:50 PM, Arvind Kalyan <base16@gmail.com> wrote:

Hey folks,

How can I take, say, the opcodes generated by the following, and
translate them into actual x86 assembly instructions?

RubyVM::InstructionSequence.compile_file("MyTest.rb").disasm

Or more generally, given a ".rb" file how can I see its x86 instructions
(compiled form).

--
Arvind Kalyan
Arvind K. - Amazon | LinkedIn
cell: (408) 761-2030

--
Tony Arcieri

--
Arvind Kalyan
http://www.linkedin.com/in/base16
cell: (408) 761-2030

You might want to look at the (horrible) project "wilson":

···

On Jun 30, 2015, at 18:20, Arvind Kalyan <base16@gmail.com> wrote:

Thanks. I am interested in the h/w instructions purely from knowledge/introspection/debugging point of view. To clarify, I'm not trying to execute the compiled ".rb" file.

If you (or anyone else on the thread) have tools that works for you for this requirement, please share.

Even if there's a command-line flag (that I'm unaware of) to the RubyVM to spit out the instructions on the fly as it executes, that'd be awesome.

Thanks.

On Tue, Jun 30, 2015 at 6:03 PM, Tony Arcieri <bascule@gmail.com> wrote:
YARV bytecode is interpreted (by a stack machine), not compiled.

That said I'm mentoring a GSoC project which is attempting to translate YARV bytecodes to LLVM's IR, which can then be directly translated to x86 bytecodes

On Tue, Jun 30, 2015 at 5:50 PM, Arvind Kalyan <base16@gmail.com> wrote:
Hey folks,

How can I take, say, the opcodes generated by the following, and translate them into actual x86 assembly instructions?

RubyVM::InstructionSequence.compile_file("MyTest.rb").disasm

Or more generally, given a ".rb" file how can I see its x86 instructions (compiled form).

Does that require a certain version of dl? When I run the test script, I
get:

    /Users/eric/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- dl/import (LoadError)
            from /Users/eric/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
            from /Users/eric/.rvm/gems/ruby-2.2.1/gems/wilson-1.1.1/lib/wilson.rb:4:in `<top (required)>'
            from /Users/eric/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
            from /Users/eric/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
            from /Users/eric/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
            from wilson_demo.rb:1:in `<main>'

···

On Wed, Jul 01, 2015, Ryan Davis wrote:

> On Jun 30, 2015, at 18:20, Arvind Kalyan <base16@gmail.com> wrote:
>
> Thanks. I am interested in the h/w instructions purely from knowledge/introspection/debugging point of view. To clarify, I'm not trying to execute the compiled ".rb" file.
>
> If you (or anyone else on the thread) have tools that works for you for this requirement, please share.
>
> Even if there's a command-line flag (that I'm unaware of) to the RubyVM to spit out the instructions on the fly as it executes, that'd be awesome.
>
> Thanks.
>
>
> On Tue, Jun 30, 2015 at 6:03 PM, Tony Arcieri <bascule@gmail.com> wrote:
> YARV bytecode is interpreted (by a stack machine), not compiled.
>
> That said I'm mentoring a GSoC project which is attempting to translate YARV bytecodes to LLVM's IR, which can then be directly translated to x86 bytecodes
>
> On Tue, Jun 30, 2015 at 5:50 PM, Arvind Kalyan <base16@gmail.com> wrote:
> Hey folks,
>
> How can I take, say, the opcodes generated by the following, and translate them into actual x86 assembly instructions?
>
> RubyVM::InstructionSequence.compile_file("MyTest.rb").disasm
>
> Or more generally, given a ".rb" file how can I see its x86 instructions (compiled form).

You might want to look at the (horrible) project "wilson":

GitHub - seattlerb/wilson

--
        Eric Christopherson