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: use breakpoint type, not address, to recognize watchpoints



I've applied this patch.  I'm pretty sure it's right, but if other
folks could check it over for correctness, that would be great.

2001-05-05  Jim Blandy  <jimb@redhat.com>

	* breakpoint.c (check_duplicates): Use the breakpoint's type, not
	its address, to decide whether it's a watchpoint or not.  Zero
	is a valid code address.
	(update_breakpoints_after_exec): Admonishing comments.
	* breakpoint.h (struct breakpoint): Doc fixes.

Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.33
diff -c -r1.33 breakpoint.c
*** gdb/breakpoint.c	2001/05/06 00:52:07	1.33
--- gdb/breakpoint.c	2001/05/06 01:27:07
***************
*** 1144,1150 ****
  
         ??rehrauer: Let's hope that merely clearing out this catchpoint's
         target address field, if any, is sufficient to have it be reset
!        automagically.  Certainly on HP-UX that's true. */
      if ((b->type == bp_catch_exec) ||
  	(b->type == bp_catch_vfork) ||
  	(b->type == bp_catch_fork))
--- 1144,1160 ----
  
         ??rehrauer: Let's hope that merely clearing out this catchpoint's
         target address field, if any, is sufficient to have it be reset
!        automagically.  Certainly on HP-UX that's true.
! 
!        Jim Blandy <jimb@redhat.com>: Actually, zero is a perfectly
!        valid code address on some platforms (like the mn10200 and
!        mn10300 simulators).  We shouldn't assign any special
!        interpretation to a breakpoint with a zero address.  And in
!        fact, GDB doesn't --- I can't see what that comment above is
!        talking about.  As far as I can tell, setting the address of a
!        bp_catch_exec/bp_catch_vfork/bp_catch_fork breakpoint to zero
!        is meaningless, since those are implemented with HP-UX kernel
!        hackery, not by storing breakpoint instructions somewhere.  */
      if ((b->type == bp_catch_exec) ||
  	(b->type == bp_catch_vfork) ||
  	(b->type == bp_catch_fork))
***************
*** 1195,1201 ****
  
      /* If this breakpoint has survived the above battery of checks, then
         it must have a symbolic address.  Be sure that it gets reevaluated
!        to a target address, rather than reusing the old evaluation.  */
      b->address = (CORE_ADDR) NULL;
    }
  }
--- 1205,1217 ----
  
      /* If this breakpoint has survived the above battery of checks, then
         it must have a symbolic address.  Be sure that it gets reevaluated
!        to a target address, rather than reusing the old evaluation.
! 
!        Jim Blandy <jimb@redhat.com>: As explained above in the comment
!        for bp_catch_exec and friends, I'm pretty sure this is entirely
!        unnecessary.  A call to breakpoint_re_set_one always recomputes
!        the breakpoint's address from scratch, or deletes it if it can't.
!        So I think this assignment could be deleted without effect.  */
      b->address = (CORE_ADDR) NULL;
    }
  }
***************
*** 3734,3740 ****
    CORE_ADDR address = bpt->address;
    asection *section = bpt->section;
  
!   if (address == 0)		/* Watchpoints are uninteresting */
      return;
  
    ALL_BREAKPOINTS (b)
--- 3750,3760 ----
    CORE_ADDR address = bpt->address;
    asection *section = bpt->section;
  
!   /* Watchpoints are uninteresting.  */
!   if (bpt->type == bp_watchpoint
!       || bpt->type == bp_hardware_watchpoint
!       || bpt->type == bp_read_watchpoint
!       || bpt->type == bp_access_watchpoint)
      return;
  
    ALL_BREAKPOINTS (b)
Index: gdb/breakpoint.h
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.h,v
retrieving revision 1.7
diff -c -r1.7 breakpoint.h
*** gdb/breakpoint.h	2001/05/04 04:15:24	1.7
--- gdb/breakpoint.h	2001/05/06 01:27:08
***************
*** 193,208 ****
      /* Number assigned to distinguish breakpoints.  */
      int number;
  
!     /* Address to break at, or NULL if not a breakpoint.  */
      CORE_ADDR address;
  
!     /* Line number of this address.  Only matters if address is
!        non-NULL.  */
  
      int line_number;
  
!     /* Source file name of this address.  Only matters if address is
!        non-NULL.  */
  
      char *source_file;
  
--- 193,209 ----
      /* Number assigned to distinguish breakpoints.  */
      int number;
  
!     /* Address to break at.
!        Note that zero is a perfectly valid code address on some
!        platforms (for example, the mn10200 and mn10300 simulators).
!        NULL is not a special value for this field.  */
      CORE_ADDR address;
  
!     /* Line number of this address.  */
  
      int line_number;
  
!     /* Source file name of this address.  */
  
      char *source_file;
  
***************
*** 217,227 ****
         control of the target insert_breakpoint and remove_breakpoint routines.
         No other code should assume anything about the value(s) here.  */
      char shadow_contents[BREAKPOINT_MAX];
!     /* Nonzero if this breakpoint is now inserted.  Only matters if address
!        is non-NULL.  */
      char inserted;
      /* Nonzero if this is not the first breakpoint in the list
!        for the given address.  Only matters if address is non-NULL.  */
      char duplicate;
      /* Chain of command lines to execute when this breakpoint is hit.  */
      struct command_line *commands;
--- 218,227 ----
         control of the target insert_breakpoint and remove_breakpoint routines.
         No other code should assume anything about the value(s) here.  */
      char shadow_contents[BREAKPOINT_MAX];
!     /* Nonzero if this breakpoint is now inserted.  */
      char inserted;
      /* Nonzero if this is not the first breakpoint in the list
!        for the given address.  */
      char duplicate;
      /* Chain of command lines to execute when this breakpoint is hit.  */
      struct command_line *commands;
***************
*** 231,238 ****
      /* Conditional.  Break only if this expression's value is nonzero.  */
      struct expression *cond;
  
!     /* String we used to set the breakpoint (malloc'd).  Only matters if
!        address is non-NULL.  */
      char *addr_string;
      /* Language we used to set the breakpoint.  */
      enum language language;
--- 231,237 ----
      /* Conditional.  Break only if this expression's value is nonzero.  */
      struct expression *cond;
  
!     /* String we used to set the breakpoint (malloc'd).  */
      char *addr_string;
      /* Language we used to set the breakpoint.  */
      enum language language;


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