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]

[RFC] Set to_stopped_data_address field in procfs.c


This patch seems to work correctly for OpenSolaris.

I put proc_watchpoint_address as a global function
because the two before proc_why and proc_what 
also are... even if they don't seem to be used
anywhere else in gdb.

Comments?
Possible testers for other platforms?


Pierre Muller
Pascal language support maintainer for GDB

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

	* procfs.c (proc_watchpoint_address): New function.
	(procfs_stopped_data_address): New function.
	(procfs_use_watchpoints): Register new watchpoint related
	function.

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:42:31 -0000
@@ -1288,6 +1288,30 @@ proc_what (procinfo *pi)
   return pi->prstatus.pr_what;
 #endif
 }
+/*
+ * Function: proc_watchpoint_address
+ *
+ * returns the prstatus.pr_lwp.pr_info.__data.__fault.__addr field.
+ */
+
+CORE_ADDR
+proc_watchpoint_address (procinfo *pi)
+{
+  if (!pi->status_valid)
+    if (!proc_get_status (pi))
+      return 0;	/* FIXME: not a good failure value (but what is?) */
+
+#ifdef NEW_PROC_API
+  return unsigned_pointer_to_address (builtin_type (target_gdbarch)->
+	   builtin_data_ptr,
+	   (gdb_byte *) &pi->prstatus.pr_lwp.pr_info.__data.__fault.__addr);
+#else
+  return unsigned_pointer_to_address (builtin_type (target_gdbarch)->
+	   builtin_data_ptr,
+	   (gdb_byte *) &pi->prstatus.pr_info.__data.__fault.__addr);
+#endif
+}
+
 
 #ifndef PIOCSSPCACT	/* The following is not supported on OSF.  */
 /*
@@ -5348,6 +5372,45 @@ 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;
+  procinfo *pi;
+  int watchpoint_hit = 0;
+
+  pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+
+  if (!pi)	/* If no process, then not stopped by watchpoint!  */
+    return 0;
+
+  if (proc_flags (pi) & (PR_STOPPED | PR_ISTOP))
+    {
+      if (proc_why (pi) == PR_FAULTED)
+	{
+#ifdef FLTWATCH
+	  if (proc_what (pi) == FLTWATCH)
+	    watchpoint_hit = 1;
+#endif
+#ifdef FLTKWATCH
+	  if (proc_what (pi) == FLTKWATCH)
+	    watchpoint_hit = 1;
+#endif
+	}
+    }
+  if (!watchpoint_hit)
+    return 0;
+  waddr = proc_watchpoint_address (pi);
+  if (addr)
+    *addr = waddr;
+  return (waddr != 0);
+}
 
 static int
 procfs_insert_watchpoint (CORE_ADDR addr, int len, int type)
@@ -5394,6 +5457,7 @@ 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;
 }
 
 /*


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