]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: fix for mips-disassembler when branch is at block_size-2 position
authorPetar Jovanovic <mips32r2@gmail.com>
Sun, 20 Jan 2013 18:16:45 +0000 (18:16 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Sun, 20 Jan 2013 18:16:45 +0000 (18:16 +0000)
Check if the last instruction in the block is a branch or jump instruction
should happen only if the disassembler was not already stopped.
Incorrect conditional led to a boundary case in which jumps/branches were not
executed when placed on "max_insns - 2" position in the block.
none/tests/mips32/block_size test will be added to Valgrind to describe the case
and check for regressions in future.

git-svn-id: svn://svn.valgrind.org/vex/trunk@2648

VEX/priv/guest_mips_toIR.c

index f9fb4423a7db1f57346212db401db86551d0ab15..c6a458a70325055ea08fda4b48b93d8a996b7ade 100644 (file)
@@ -3622,12 +3622,13 @@ static DisResult disInstr_MIPS_WRK ( Bool(*resteerOkFn) (/*opaque */void *,
 
    // On MIPS we need to check if the last instruction
    // in block is branch or jump
-   if ((vex_control.guest_max_insns - 1) == (delta+4)/4)
+   if (((vex_control.guest_max_insns - 1) == (delta + 4) / 4)
+       &&  (dres.whatNext != Dis_StopHere))
       if (branch_or_jump(guest_code + delta + 4)) {
          dres.whatNext = Dis_StopHere;
          dres.jk_StopHere = Ijk_Boring;
          putPC(mkU32(guest_PC_curr_instr + 4));
-   }
+      }
    dres.len = 4;
 
    DIP("\n");