This is the mail archive of the gdb-patches@sourceware.cygnus.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]

RFA: infrun.c, breakpoint.c: Kludge for Solaris x86 hardware watchpoint support


Unfortunately I'd need the following kludge to work around a Solaris x86
kernel problem with hardware watchpoint support.
See the comment in the patches for a description of the problem.

Any objections ?

2000-03-12  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>

	breakpoint.c, breakpoint.h (remove_hw_watchpoints):  New function.
	infrun.c (resume):  Remove hardware watchpoints before stepping
	when CANNOT_STEP_HW_WATCHPOINTS is nonzero.

*** gdb/breakpoint.c.orig	Thu Feb 24 13:41:33 2000
--- gdb/breakpoint.c	Sat Mar  4 11:42:48 2000
***************
*** 1080,1085 ****
--- 1081,1107 ----
  }
  
  int
+ remove_hw_watchpoints ()
+ {
+   register struct breakpoint *b;
+   int val;
+ 
+   ALL_BREAKPOINTS (b)
+   {
+     if (b->inserted
+ 	&& (b->type == bp_hardware_watchpoint
+ 	    || b->type == bp_read_watchpoint
+ 	    || b->type == bp_access_watchpoint))
+       {
+ 	val = remove_breakpoint (b, mark_uninserted);
+ 	if (val != 0)
+ 	  return val;
+       }
+   }
+   return 0;
+ }
+ 
+ int
  reattach_breakpoints (pid)
       int pid;
  {
*** ./gdb/breakpoint.h.orig	Thu Feb  3 05:14:27 2000
--- ./gdb/breakpoint.h	Sat Mar  4 11:42:48 2000
***************
*** 562,567 ****
--- 562,568 ----
  extern int insert_breakpoints PARAMS ((void));
  
  extern int remove_breakpoints PARAMS ((void));
+ extern int remove_hw_watchpoints PARAMS ((void));
  
  /* This function can be used to physically insert eventpoints from the
     specified traced inferior process, without modifying the breakpoint
*** gdb/infrun.c.orig	Thu Feb 24 13:41:46 2000
--- gdb/infrun.c	Mon Mar 13 09:35:54 2000
***************
*** 296,301 ****
--- 296,308 ----
  #define HAVE_CONTINUABLE_WATCHPOINT 1
  #endif
  
+ #ifndef CANNOT_STEP_HW_WATCHPOINTS
+ #define CANNOT_STEP_HW_WATCHPOINTS 0
+ #else
+ #undef  CANNOT_STEP_HW_WATCHPOINTS
+ #define CANNOT_STEP_HW_WATCHPOINTS 1
+ #endif
+ 
  /* Tables of how to react to signals; the user sets them.  */
  
  static unsigned char *signal_stop;
***************
*** 796,801 ****
--- 803,820 ----
    if (step && breakpoints_inserted && breakpoint_here_p (read_pc ()))
      step = 0;
  #endif
+ 
+   /* Some targets (e.g. Solaris x86) have a kernel bug when stepping
+      over an instruction that causes a page fault without triggering
+      a hardware watchpoint. The kernel properly notices that it shouldn't
+      stop, because the hardware watchpoint is not triggered, but it forgets
+      the step request and continues the program normally.
+      Work around the problem by removing hardware watchpoints if a step is
+      requested, GDB will check for a hardware watchpoint trigger after the
+      step anyway.  */
+   if (CANNOT_STEP_HW_WATCHPOINTS && step && breakpoints_inserted)
+     remove_hw_watchpoints ();
+      
  
    /* Normally, by the time we reach `resume', the breakpoints are either
       removed or inserted, as appropriate.  The exception is if we're sitting

-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de

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