Skip to content

Questionable behavior of the normally unused instruction OP_DEBUG #5686

@dearblue

Description

@dearblue

I just followed the code by eye, so if I'm wrong or that's the intended behavior, please ignore it.

  1. two consecutive FETCH_XXX() from iseq may

    While OP_DEBUG is defined as operand type BBB in include/mruby/ops.h, it is defined as operand type Z in src/vm.c followed by FETCH_BBB().
    I assume that OP_DEBUG always intends to FETCH_BBB(), but if the operand is extended with instruction OP_EXT3, for example, FETCH_SSB() is performed followed by FETCH_BBB().

    If this is not the intention, it is better to change OP_DEBUG in src/vm.c to BBB or OP_DEBUG in include/mruby/ops.h to Z.

  2. inconsistency when the configuration macro MRB_USE_DEBUG_HOOK is defined

    In normal instructions, mrb->debug_op_hook() is called before decoding the operand.
    For OP_DEBUG, mrb->debug_op_hook() is called again after FETCH_BBB(). In addition, NULL check of mrb->debug_op_hook is not performed at this time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions