david942j/crabstone

Duplicate struct definition

chrisseaton opened this issue · 3 comments

Is this code as intended?

class Instruction < FFI::Struct
layout(
:modrm_offset, :uint8,
:disp_offset, :uint8,
:disp_size, :uint8,
:imm_offset, :uint8,
:imm_size, :uint8
)
include Crabstone::Extension::Instruction
end
class Instruction < FFI::Struct
layout(
:prefix, [:uint8, 4],
:opcode, [:uint8, 4],
:rex, :uint8,
:addr_size, :uint8,
:modrm, :uint8,
:sib, :uint8,
:disp, :long,
:sib_index, :uint,
:sib_scale, :int8,
:sib_base, :uint,
:xop_cc, :uint,
:sse_cc, :uint,
:avx_cc, :uint,
:avx_sae, :bool,
:avx_rm, :uint,
:eflags, :ulong,
:op_count, :uint8,
:operands, [Operand, 8],
:encoding, Instruction
)
end

FFI is warning about it. It also doesn't make immediate sense to me.

[DEPRECATION] Struct layout is already defined for class Crabstone::X86::Instruction. Redefinition as in /Users/chrisseaton/.gem/ruby/2.5.8/gems/crabstone-4.0.2/lib/crabstone/arch/4/x86.rb:68:in `<class:Instruction>' will be disallowed in ffi-2.0.

Interesting.. must be a bug.

Thanks for the report!

The new 4.0.3 release of Crabstone contains the fix, thanks again for pointing this out!

Thanks very much for responding so quickly and doing the release straight away. We're using this gem at Shopify for some compiler research.