This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

RE: [RFC] Add watchpoint hit address function to procfs.c


  Hi Pedro,

  I tried to take all your remarks into account and
decreased further the size of the patch.

  I also checked the testsuite by 
running with RUNTESTFLAGS=gdb*/watch*.exp
with both CVS GDB and with patch applied.
(I used my modified gdb.exp to avoid problems
with the 'DOS-like' newlines..)
 Here is the output:
pierre@fpcOpenSolaris:~/gdbcvs/build64/gdb/testsuite$ diff gdb.sum gdbv4.sum
1c1
< Test Run By pierre on Mon May 10 09:02:27 2010
---
> Test Run By pierre on Mon May 10 09:01:18 2010
80,81c80,81
< FAIL: gdb.base/watchpoint-hw-hit-once.exp: continue
< FAIL: gdb.base/watchpoint-hw-hit-once.exp: continue to break-at-exit (the
prog
ram exited)
---
> PASS: gdb.base/watchpoint-hw-hit-once.exp: continue
> PASS: gdb.base/watchpoint-hw-hit-once.exp: continue to break-at-exit
129,135c129,135
< FAIL: gdb.base/watch-read.exp: read watchpoint triggers on first read
(timeout
)
< FAIL: gdb.base/watch-read.exp: read watchpoint triggers on read after
value ch
anged (timeout)
< FAIL: gdb.base/watch-read.exp: set write watchpoint on global variable
(timeou
t)
< FAIL: gdb.base/watch-read.exp: write watchpoint triggers (timeout)
< FAIL: gdb.base/watch-read.exp: only write watchpoint triggers when value
chang
es (timeout)
< FAIL: gdb.base/watch-read.exp: read watchpoint triggers when value doesn't
cha
nge, trapping reads and writes (timeout)
< FAIL: gdb.base/watch-read.exp: only read watchpoint triggers when value
doesn'
t change (timeout)
---
> PASS: gdb.base/watch-read.exp: read watchpoint triggers on first read
> PASS: gdb.base/watch-read.exp: read watchpoint triggers on read after
value ch
anged
> PASS: gdb.base/watch-read.exp: set write watchpoint on global variable
> PASS: gdb.base/watch-read.exp: write watchpoint triggers
> PASS: gdb.base/watch-read.exp: only write watchpoint triggers when value
chang
es
> FAIL: gdb.base/watch-read.exp: read watchpoint triggers when value doesn't
cha
nge, trapping reads and writes
> FAIL: gdb.base/watch-read.exp: only read watchpoint triggers when value
doesn'
t change
192,193c192,193
< # of expected passes          145
< # of unexpected failures      15
---
> # of expected passes          152
> # of unexpected failures      8
196c196
< /export/home/pierre/bin/gdbcvs version  7.1.50.20100510-cvs -nw -nx
---
> /usr/local/src/gdb/build64/gdb/testsuite/../../gdb/gdb version
7.1.50.2010051
0-cvs -nw -nx

  So there are no regressions.
Remaining failures are:
pierre@fpcOpenSolaris:~/gdbcvs/build64/gdb/testsuite$ grep FAIL gdbv4.sum
FAIL: gdb.base/watch-read.exp: read watchpoint triggers when value doesn't
chang
e, trapping reads and writes
FAIL: gdb.base/watch-read.exp: only read watchpoint triggers when value
doesn't
change
KFAIL: gdb.threads/watchthreads2.exp: gdb can drop watchpoints in
multithreaded
app (PRMS: gdb/10116)
FAIL: gdb.threads/watchthreads.exp: threaded watch loop
FAIL: gdb.threads/watchthreads.exp: first watchpoint on args[0] hit
FAIL: gdb.threads/watchthreads.exp: first watchpoint on args[1] hit
FAIL: gdb.threads/watchthreads.exp: watchpoint on args[0] hit in thread
FAIL: gdb.threads/watchthreads.exp: watchpoint on args[1] hit in thread
FAIL: gdb.threads/watchthreads.exp: combination of threaded watchpoints = 30

  I also checked without adding TIDGET(inferior_ptid), leaving 0 instead,
for both find_procinfo_or_die calls.
This had no effect on the testsuite output (same 8 failures).

Pierre





2010-05-10  Pierre Muller  <muller@ics.u-strasbg.fr>

	* procfs.c (proc_watchpoint_address): New function.
	(procfs_stopped_by_watchpoint): Change second parameter of
	find_procinfo_or_die call to TIDGET (INFERIOR_PTID).
	Remove useless check after find_procinfo_or_die call.
	(procfs_stopped_data_address): New function.
	(procfs_use_watchpoints): Register new watchpoint related
	function.


Index: src/gdb/procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.131
diff -u -p -r1.131 procfs.c
--- src/gdb/procfs.c	20 Apr 2010 22:36:35 -0000	1.131
+++ src/gdb/procfs.c	10 May 2010 06:24:55 -0000
@@ -1313,6 +1313,34 @@ proc_what (procinfo *pi)
 #endif
 }
 
+/*
+ * Function: proc_watchpoint_address
+ *
+ *   This function is only called when PI is stopped by a watchpoint.
+ *   Assuming OS supports it, write to *ADDR the data address which
+ * triggered it and return 1.
+ * Return 0 if it is not possible to know the address.
+ */
+
+static int
+proc_watchpoint_address (procinfo *pi, CORE_ADDR *addr)
+{
+  if (!pi->status_valid)
+    if (!proc_get_status (pi))
+      return 0;
+
+#ifdef NEW_PROC_API
+  *addr = (CORE_ADDR) unsigned_pointer_to_address (target_gdbarch,
+	    builtin_type (target_gdbarch)->builtin_data_ptr,
+	    (gdb_byte *) &pi->prstatus.pr_lwp.pr_info.si_addr);
+#else
+  *addr = (CORE_ADDR) unsigned_pointer_to_address (target_gdbarch,
+	    builtin_type (target_gdbarch)->builtin_data_ptr,
+	    (gdb_byte *) &pi->prstatus.pr_info.si_addr);
+#endif
+  return 1;
+}
+
 #ifndef PIOCSSPCACT	/* The following is not supported on OSF.  */
 /*
  * Function: proc_nsysarg
@@ -5539,10 +5567,7 @@ procfs_stopped_by_watchpoint (void)
 {
   procinfo *pi;
 
-  pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
-
-  if (!pi)	/* If no process, then not stopped by watchpoint!  */
-    return 0;
+  pi = find_procinfo_or_die (PIDGET (inferior_ptid), TIDGET
(inferior_ptid));
 
   if (proc_flags (pi) & (PR_STOPPED | PR_ISTOP))
     {
@@ -5560,6 +5585,26 @@ procfs_stopped_by_watchpoint (void)
     }
   return 0;
 }
+/*
+ * Function procfs_stopped_data_address
+ * 
+ * Returns 1 if we the OS knows the position of the triggered
+ * watchpoint.  Sets *ADDR to that address.
+ * Returns 0 if OS cannot report that address.
+ * This function is only called if procfs_stopped_by_watchpoint
+ * returned 1, thus no further checks are done.
+ * The function also assumes that ADDR is not NULL.
+ */
+
+static int
+procfs_stopped_data_address (struct target_ops *targ, CORE_ADDR *addr)
+{
+  procinfo *pi;
+
+  pi = find_procinfo_or_die (PIDGET (inferior_ptid), TIDGET
(inferior_ptid));
+
+  return proc_watchpoint_address (pi, addr);
+}
 
 static int
 procfs_insert_watchpoint (CORE_ADDR addr, int len, int type)
@@ -5607,6 +5652,7 @@ procfs_use_watchpoints (struct target_op
   t->to_remove_watchpoint = procfs_remove_watchpoint;
   t->to_region_ok_for_hw_watchpoint = procfs_region_ok_for_hw_watchpoint;
   t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint;
+  t->to_stopped_data_address = procfs_stopped_data_address;
 }
 
 /*


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