2

I'm developing asm plugin for radare2. I implemented disassemble function, so it is returning disassembled instruction using:

r_strbuf_set (&op->buf_asm, line);

Now, when I set asm.arch to my new architecture I am able to see contents of line variable by typing pd. However, before printing the disassembled program, I'm getting bunch of warnings saying:

WARNING: r_reg_get: assertion 'reg && name' failed (line 296)

This happens after my disassemble function finishes, for every instruction processed with my code. What might be the source of such an error? It seems to be unrelated to opcode structure, I'm filling and rather relate to register names. Is implementing anal plugin required, additionally to asm plugin? Usually I see both are available for supported architectures.

v3l0c1r4pt0r
  • 134
  • 8

1 Answers1

0

Implementing dummy anal plugin is enough to prevent this warning from appearing. I added following function and passed it to new plugin:

static int mycpu_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len) {
  r_strbuf_init (&op->esil);
  op->size = 4;
  return op->size;
}

It is later pointed like below:

RAnalPlugin r_anal_plugin_mycpu = {
    .name = "mycpu",
    .desc = "Long name",
    .license = "LGPL3",
    .bits = 32,
    .op = &mycpu_op
}

#ifndef R2_PLUGIN_INCORE
R_API RLibStruct radare_plugin = {
    .type = R_LIB_TYPE_ANAL,
    .data = &r_anal_plugin_mycpu,
    .version = R2_VERSION
};
#endif
v3l0c1r4pt0r
  • 134
  • 8