Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] Add hardware breapoints in procfs.c
@ 2009-05-14 21:24 Pierre Muller
  2009-05-14 21:30 ` Pierre Muller
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Muller @ 2009-05-14 21:24 UTC (permalink / raw)
  To: gdb-patches

I postponed this part of my original patch
for procfs.c

  I don't know if all platforms using
procfs.c code will work with that code,
and I have access only to a i386 OpenSolaris.
 For that target, it works,
but only once the program is started...

 Can someone test other targets?

Pierre

2009-05-14  Pierre Muller  <muller@ics.u-strasbg.fr>

	* procfs.c (procfs_insert_hw_breakpoint,
procfs_remove_hw_breakpoint):
	New functions.
	(procfs_use_watchpoints): Register new hardware breakpoint related
	target functions.

Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.107
diff -u -p -r1.107 procfs.c
--- procfs.c	11 May 2009 11:13:08 -0000	1.107
+++ procfs.c	14 May 2009 20:38:10 -0000
@@ -5348,6 +5348,24 @@ procfs_stopped_by_watchpoint (void)
     }
   return 0;
 }
+/*
+ * Function procfs_stopped_data_address
+ * Returns non-zero if we can find the position
+ * of the triggring watchpoint.
+ */
+
+static int
+procfs_stopped_data_address (struct target_ops *targ, CORE_ADDR *addr)
+{
+  CORE_ADDR waddr;
+
+  if (!procfs_stopped_by_watchpoint ())
+    return 0;
+  waddr = procfs_watchpoint_address ();
+  if (addr)
+    *addr = waddr;
+  return (waddr !== 0);
+}
 
 static int
 procfs_insert_watchpoint (CORE_ADDR addr, int len, int type)
@@ -5387,6 +5405,20 @@ procfs_region_ok_for_hw_watchpoint (CORE
   return 1;
 }
 
+static int
+procfs_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
+{
+  CORE_ADDR addr = bp_tgt->placed_address;
+  return procfs_set_watchpoint (inferior_ptid, addr, 1, hw_execute, 0);
+}
+
+static int
+procfs_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
+{
+  CORE_ADDR addr = bp_tgt->placed_address;
+  return procfs_set_watchpoint (inferior_ptid, addr, 0, 0, 0);
+}
+
 void
 procfs_use_watchpoints (struct target_ops *t)
 {
@@ -5394,6 +5426,9 @@ procfs_use_watchpoints (struct target_op
   t->to_insert_watchpoint = procfs_insert_watchpoint;
   t->to_remove_watchpoint = procfs_remove_watchpoint;
   t->to_region_ok_for_hw_watchpoint = procfs_region_ok_for_hw_watchpoint;
+  t->to_stopped_data_address = procfs_stopped_data_address;
+  t->to_insert_hw_breakpoint = procfs_insert_hw_breakpoint;
+  t->to_remove_hw_breakpoint = procfs_remove_hw_breakpoint;
 }
 
 /*


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [RFC] Add hardware breapoints in procfs.c
  2009-05-14 21:24 [RFC] Add hardware breapoints in procfs.c Pierre Muller
@ 2009-05-14 21:30 ` Pierre Muller
  2009-05-15 15:41   ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Muller @ 2009-05-14 21:30 UTC (permalink / raw)
  To: 'Pierre Muller', gdb-patches

Sorry, I sent the wrong version of the patch.
I started to write another patch that 
tries to find the watchpoint stop address
in procinfo struct.

Correct patch is below.

Pierre

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Pierre Muller
> Envoyé : Thursday, May 14, 2009 11:25 PM
> À : gdb-patches@sourceware.org
> Objet : [RFC] Add hardware breapoints in procfs.c
> 
> I postponed this part of my original patch
> for procfs.c
> 
>   I don't know if all platforms using
> procfs.c code will work with that code,
> and I have access only to a i386 OpenSolaris.
>  For that target, it works,
> but only once the program is started...
> 
>  Can someone test other targets?
> 
> Pierre
> 
2009-05-14  Pierre Muller  <muller@ics.u-strasbg.fr>
 
 	* procfs.c (procfs_insert_hw_breakpoint,
procfs_remove_hw_breakpoint):
 	New functions.
 	(procfs_use_watchpoints): Register new hardware breakpoint related
 	target functions.

Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.107
diff -u -p -r1.107 procfs.c
--- procfs.c    11 May 2009 11:13:08 -0000      1.107
+++ procfs.c    14 May 2009 21:16:54 -0000
@@ -5387,6 +5387,20 @@ procfs_region_ok_for_hw_watchpoint (CORE
   return 1;
 }

+static int
+procfs_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
+{
+  CORE_ADDR addr = bp_tgt->placed_address;
+  return procfs_set_watchpoint (inferior_ptid, addr, 1, hw_execute, 0);
+}
+
+static int
+procfs_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
+{
+  CORE_ADDR addr = bp_tgt->placed_address;
+  return procfs_set_watchpoint (inferior_ptid, addr, 0, 0, 0);
+}
+
 void
 procfs_use_watchpoints (struct target_ops *t)
 {
@@ -5394,6 +5408,8 @@ procfs_use_watchpoints (struct target_op
   t->to_insert_watchpoint = procfs_insert_watchpoint;
   t->to_remove_watchpoint = procfs_remove_watchpoint;
   t->to_region_ok_for_hw_watchpoint = procfs_region_ok_for_hw_watchpoint;
+  t->to_insert_hw_breakpoint = procfs_insert_hw_breakpoint;
+  t->to_remove_hw_breakpoint = procfs_remove_hw_breakpoint;
 }

 /*



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] Add hardware breapoints in procfs.c
  2009-05-14 21:30 ` Pierre Muller
@ 2009-05-15 15:41   ` Joel Brobecker
  2009-05-15 15:51     ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2009-05-15 15:41 UTC (permalink / raw)
  To: Pierre Muller; +Cc: gdb-patches


> 2009-05-14  Pierre Muller  <muller@ics.u-strasbg.fr>
>  
>  	* procfs.c (procfs_insert_hw_breakpoint, procfs_remove_hw_breakpoint):
>  	New functions.
>  	(procfs_use_watchpoints): Register new hardware breakpoint related
>  	target functions.

I don't know procfs enough to review the patch accurately. I think
that the part for removing the watchpoint is correct, but I'm wondering
about the part that sets the watchpoint. Does it always stop before
the instruction gets executed? for instance, if you look at 
procfs_insert_watchpoint, it does depend on the target:

  if (!target_have_steppable_watchpoint
      && !gdbarch_have_nonsteppable_watchpoint (current_gdbarch))
    {
      /* When a hardware watchpoint fires off the PC will be left at
         the instruction following the one which caused the
         watchpoint.  It will *NOT* be necessary for GDB to step over
         the watchpoint.  */
      return procfs_set_watchpoint (inferior_ptid, addr, len, type, 1);
    }
  else
    {
      /* When a hardware watchpoint fires off the PC will be left at
         the instruction which caused the watchpoint.  It will be
         necessary for GDB to step over the watchpoint.  */
      return procfs_set_watchpoint (inferior_ptid, addr, len, type, 0);
    }

Does it matter for h/w breakpoints?

-- 
Joel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] Add hardware breapoints in procfs.c
  2009-05-15 15:41   ` Joel Brobecker
@ 2009-05-15 15:51     ` Joel Brobecker
  0 siblings, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2009-05-15 15:51 UTC (permalink / raw)
  To: Pierre Muller; +Cc: gdb-patches

> >  	* procfs.c (procfs_insert_hw_breakpoint, procfs_remove_hw_breakpoint):
> >  	New functions.
> >  	(procfs_use_watchpoints): Register new hardware breakpoint related
> >  	target functions.
> 
> I don't know procfs enough to review the patch accurately. I think
> that the part for removing the watchpoint is correct

Actually, target_insert/remove_hw_breakpoint are supposed to return
non-zero if the operation failed. However, if you look at the implementation
of procfs_set_watchpoint:

    procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag,
                           int after)
    {
    #ifndef UNIXWARE
    #ifndef AIX5
    [...]
    #endif /* AIX5 */
    #endif /* UNIXWARE */
      return 0;
    }

In other words, if h/w watchpoints are not supported, this function
returns zero.  Use that directly to insert h/w breakpoints on a system
where this feature is not implemented would lead the debugger to think
that the breakpoint was inserted when in fact it wasn't.

-- 
Joel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-05-15 15:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-14 21:24 [RFC] Add hardware breapoints in procfs.c Pierre Muller
2009-05-14 21:30 ` Pierre Muller
2009-05-15 15:41   ` Joel Brobecker
2009-05-15 15:51     ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox