Ejemplo n.º 1
0
/* Dumps specified function to file (hex) */
unsigned long
extract_function (char *out_fn, unsigned long start_addr)
{
  FILE *fo;
  unsigned long a = start_addr;
  int x = 0;
  assert (fo = fopen (out_fn, "wt+"));

  do
    {
      unsigned long d = eval_direct32 (a, 0, 0);
      int index = insn_decode (d);
      assert (index >= 0);
      if (x)
	x++;
      if (strcmp (insn_name (index), "l.jr") == 0)
	x = 1;
      a += 4;
      fprintf (fo, "%08lx\n", d);
    }
  while (x < 2);

  fclose (fo);
  return a - 4;
}
Ejemplo n.º 2
0
void Init_instruction(void)
{
#ifdef RUBY_VM
  VALUE rb_cRubyVM;
  VALUE rb_cInstruction;

  if(!rb_const_defined(rb_cObject, rb_intern("RubyVM")))
  {
    rb_define_const(
        rb_cObject,
        "RubyVM",
        rb_const_get(rb_cObject, rb_intern("VM")));
  }

  rb_cRubyVM = rb_define_class("RubyVM", rb_cObject);

  rb_cInstruction = rb_define_class_under(rb_cRubyVM, "Instruction", rb_cObject);
  rb_define_method(rb_cInstruction, "initialize", instruction_initialize, -1);
  rb_define_method(rb_cInstruction, "operands", instruction_operands, 0);
  rb_undef_method(rb_cInstruction, "new");

  define_instruction_subclasses(rb_cInstruction);

  /* Silence compiler warnings about unused static functions */
  insn_name(0);
  insn_op_type(0, 0);
  insn_op_types(0);
#endif
}