This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


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

Fix for DECR_PC_AFTER_BREAK != DECR_PC_AFTER_HW_BREAK


After hitting a hardware breakpoint on a X86 target, GDB resumes
control but is unable to identify what breakpoint was hit.  Thus
breakpoint counters are not updated and associated command scripts
are not executed.

bpstat_stop_status() correctly compares addresses of non-hardware
breakpoints with ($PC - DECR_PC_AFTER_BREAK); but it compares the
address of hardware breakpoints with ($PC - DECR_PC_AFTER_BREAK -
DECR_PC_AFTER_HW_BREAK).  The latter expression is only correct 
when both values are 0.  

After that was fixed, GDB erroneously tried to decrement the PC on
hardware breakpoints even though DECR_PC_AFTER_HW_BREAK == 0.  The
enclosed change makes the distinction between hard and soft breaks
and decrements the PC by the appropriate amount if required.

	--jtc


1998-12-15  J.T. Conklin  <jtc@redbacknetworks.com>

	* breakpoint.c (bpstat_stop_status): Handle systems where
	DECR_PC_AFTER_BREAK != DECR_PC_AFTER_HW_BREAK.

Index: breakpoint.c
===================================================================
RCS file: /usr/rback/release/tools-src/gdb/gdb/breakpoint.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 breakpoint.c
*** breakpoint.c	1998/12/03 00:05:07	1.1.1.1
--- breakpoint.c	1998/12/15 22:40:15
***************
*** 1369,1375 ****
  	  continue;
  
        if (b->type == bp_hardware_breakpoint
! 	  && b->address != (bp_addr - DECR_PC_AFTER_HW_BREAK))
  	continue;
  
        if (b->type != bp_watchpoint
--- 1369,1375 ----
  	  continue;
  
        if (b->type == bp_hardware_breakpoint
! 	  && b->address != (*pc - DECR_PC_AFTER_HW_BREAK))
  	continue;
  
        if (b->type != bp_watchpoint
***************
*** 1470,1477 ****
                    break;
  	      }
          }
!       else if (DECR_PC_AFTER_BREAK != 0 || must_shift_inst_regs)
! 	real_breakpoint = 1;
  
        if (b->frame && b->frame != (get_current_frame ())->frame &&
            (b->type == bp_step_resume && 
--- 1470,1479 ----
                    break;
  	      }
          }
!       else
! 	{
! 	  real_breakpoint = 1;
! 	}
  
        if (b->frame && b->frame != (get_current_frame ())->frame &&
            (b->type == bp_step_resume && 
***************
*** 1527,1542 ****
    bs->next = NULL;		/* Terminate the chain */
    bs = root_bs->next;		/* Re-grab the head of the chain */
  
!   if ((DECR_PC_AFTER_BREAK != 0 || must_shift_inst_regs) && bs)
      {
!       if (real_breakpoint)
  	{
! 	  *pc = bp_addr;
  #if defined (SHIFT_INST_REGS)
! 	  SHIFT_INST_REGS();
  #else /* No SHIFT_INST_REGS.  */
! 	  write_pc (bp_addr);
  #endif /* No SHIFT_INST_REGS.  */
  	}
      }
  
--- 1529,1555 ----
    bs->next = NULL;		/* Terminate the chain */
    bs = root_bs->next;		/* Re-grab the head of the chain */
  
!   if (real_breakpoint && bs)
      {
!       if (bs->breakpoint_at->type == bp_hardware_breakpoint) 
! 	{
! 	  if (DECR_PC_AFTER_HW_BREAK != 0) 
! 	    {
! 	      *pc = *pc - DECR_PC_AFTER_HW_BREAK;
! 	      write_pc (*pc);
! 	    }
! 	}
!       else
  	{
! 	  if (DECR_PC_AFTER_BREAK != 0 || must_shift_inst_regs)
! 	    {
! 	      *pc = bp_addr;
  #if defined (SHIFT_INST_REGS)
! 	      SHIFT_INST_REGS();
  #else /* No SHIFT_INST_REGS.  */
! 	      write_pc (bp_addr);
  #endif /* No SHIFT_INST_REGS.  */
+ 	    }
  	}
      }