This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] cris-tdep.c: fix single-step bugs


I've committed the patch below to both trunk and the 5.1 branch.  It
fixes two problems with single-stepping, one of which was a major one. 
They were exposed thanks to Corrinna's change to display.exp which added
floating point addition to the code path where gdb was watching a
variable.


2001-10-26  Orjan Friberg  <orjanf@axis.com>

        * cris-tdep.c (constraint): Loop through the whole
cris_spec_regs
        struct, not just the NUM_SPECREGS first entries.
        (bdap_prefix): Read PC before autoincrement.


Index: cris-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/cris-tdep.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 cris-tdep.c
*** cris-tdep.c 2001/09/24 08:04:10     1.4
--- cris-tdep.c 2001/10/26 14:43:59
*************** constraint (unsigned int insn, const sig
*** 1613,1638 ****
  
        case 'P':
          tmp = (insn >> 0xC) & 0xF;
!         for (i = 0; i < NUM_SPECREGS; i++)
!           /* Since we match four bits, we will give a value of
!              4 - 1 = 3 in a match.  If there is a corresponding
!              exact match of a special register in another pattern, it
!              will get a value of 4, which will be higher.  This should
!              be correct in that an exact pattern would match better
that
!              a general pattern.
!              Note that there is a reason for not returning zero; the
!              pattern for "clear" is partly  matched in the bit-pattern
!              (the two lower bits must be zero), while the bit-pattern
!              for a move from a special register is matched in the
!              register constraint.
!              This also means we will will have a race condition if
!              there is a partly match in three bits in the bit
pattern.  */
!           if (tmp == cris_spec_regs[i].number)
!             {
!               retval += 3;
!               break;
!             }
!         if (i == NUM_SPECREGS)
            return -1;
          break;
        }
--- 1613,1642 ----
  
        case 'P':
          tmp = (insn >> 0xC) & 0xF;
! 
!         for (i = 0; cris_spec_regs[i].name != NULL; i++)
!           {
!             /* Since we match four bits, we will give a value of
!                4 - 1 = 3 in a match.  If there is a corresponding
!                exact match of a special register in another pattern,
it
!                will get a value of 4, which will be higher.  This
should
!                be correct in that an exact pattern would match better
that
!                a general pattern.
!                Note that there is a reason for not returning zero; the
!                pattern for "clear" is partly  matched in the
bit-pattern
!                (the two lower bits must be zero), while the
bit-pattern
!                for a move from a special register is matched in the
!                register constraint.
!                This also means we will will have a race condition if
!                there is a partly match in three bits in the bit
pattern.  */
!             if (tmp == cris_spec_regs[i].number)
!               {
!                 retval += 3;
!                 break;
!               }
!           }
!         
!         if (cris_spec_regs[i].name == NULL)
            return -1;
          break;
        }
*************** bdap_prefix (unsigned short inst, inst_e
*** 1872,1888 ****
        return; 
      }
  
!   if (cris_get_mode (inst) == AUTOINC_MODE)
!     {
!       process_autoincrement (cris_get_size (inst), inst, inst_env); 
!     }
!     
    inst_env->prefix_value = inst_env->reg[cris_get_operand2 (inst)];
  
    /* The offset is an indirection of the contents of the operand1
register.  */
    inst_env->prefix_value += 
!     read_memory_integer (inst_env->reg[cris_get_operand1 (inst)],
cris_get_size (inst));
!   
    /* A prefix doesn't change the xflag_found.  But the rest of the
flags
       need updating.  */
    inst_env->slot_needed = 0;
--- 1876,1897 ----
        return; 
      }
  
!   /* The calculation of prefix_value used to be after
process_autoincrement,
!      but that fails for an instruction such as jsr [$r0+12] which is
encoded
!      as 5f0d 0c00 30b9 when compiled with -fpic.  Since PC is operand1
it
!      mustn't be incremented until we have read it and what it points
at.  */
    inst_env->prefix_value = inst_env->reg[cris_get_operand2 (inst)];
  
    /* The offset is an indirection of the contents of the operand1
register.  */
    inst_env->prefix_value += 
!     read_memory_integer (inst_env->reg[cris_get_operand1 (inst)], 
!                          cris_get_size (inst));
! 
!   if (cris_get_mode (inst) == AUTOINC_MODE)
!     {
!       process_autoincrement (cris_get_size (inst), inst, inst_env); 
!     }
!    
    /* A prefix doesn't change the xflag_found.  But the rest of the
flags
       need updating.  */
    inst_env->slot_needed = 0;

-- 
Orjan Friberg              E-mail: orjan.friberg@axis.com
Axis Communications AB     Phone:  +46 46 272 17 68


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]