[nto] Fix nto target stopped by watchpoint.
authorAleksandar Ristovski <aristovski@qnx.com>
Wed, 21 Oct 2015 14:37:33 +0000 (10:37 -0400)
committerAleksandar Ristovski <aristovski@qnx.com>
Wed, 21 Oct 2015 14:37:33 +0000 (10:37 -0400)
Fix 'stopped by watchpoint' detection: add inferior data, use inferior data
for storing last stopped flags needed for detection.

gdb/ChangeLog:

* nto-procfs.c (procfs_wait): Set stopped_flags nad stopped_pc.
(procfs_stopped_by_watchpoint): Use flags stored in inferior data.
* nto-tdep.c (nto_new_inferior_data_reg): New definition.
(nto_new_inferior_data, nto_inferior_data_cleanup, nto_inferior_data):
New functions.
(_initialize_nto_tdep): New forward declaration, new function.
* nto-tdep.h (struct nto_inferior_data): New struct.
(nto_inferior_data): New function declaration.

gdb/ChangeLog
gdb/nto-procfs.c
gdb/nto-tdep.c
gdb/nto-tdep.h

index e54695046c61048fe7f8d928db74fbfcd5d9d3c0..277a0ceadd78b2a04ffe1fccd12d69f059c16f5f 100644 (file)
@@ -1,3 +1,14 @@
+2015-10-21  Aleksandar Ristovski  <aristovski@qnx.com>
+
+       * nto-procfs.c (procfs_wait): Set stopped_flags nad stopped_pc.
+       (procfs_stopped_by_watchpoint): Use flags stored in inferior data.
+       * nto-tdep.c (nto_new_inferior_data_reg): New definition.
+       (nto_new_inferior_data, nto_inferior_data_cleanup, nto_inferior_data):
+       New functions.
+       (_initialize_nto_tdep): New forward declaration, new function.
+       * nto-tdep.h (struct nto_inferior_data): New struct.
+       (nto_inferior_data): New function declaration.
+
 2015-10-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * findvar.c (address_from_register): Check REGNUM validity.
index 82b428c0783954a65356577c08ce9f1a353fb541..6ab78e35b0abf35a990308d5ff6a9e68ac16b1dc 100644 (file)
@@ -784,6 +784,9 @@ procfs_wait (struct target_ops *ops,
       devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0);
     }
 
+  nto_inferior_data (NULL)->stopped_flags = status.flags;
+  nto_inferior_data (NULL)->stopped_pc = status.ip;
+
   if (status.flags & _DEBUG_FLAG_SSTEP)
     {
       ourstatus->kind = TARGET_WAITKIND_STOPPED;
@@ -1626,5 +1629,21 @@ procfs_insert_hw_watchpoint (struct target_ops *self,
 static int
 procfs_stopped_by_watchpoint (struct target_ops *ops)
 {
-  return 0;
+  /* NOTE: nto_stopped_by_watchpoint will be called ONLY while we are
+     stopped due to a SIGTRAP.  This assumes gdb works in 'all-stop' mode;
+     future gdb versions will likely run in 'non-stop' mode in which case
+     we will have to store/examine statuses per thread in question.
+     Until then, this will work fine.  */
+
+  struct inferior *inf = current_inferior ();
+  struct nto_inferior_data *inf_data;
+
+  gdb_assert (inf != NULL);
+
+  inf_data = nto_inferior_data (inf);
+
+  return inf_data->stopped_flags
+        & (_DEBUG_FLAG_TRACE_RD
+           | _DEBUG_FLAG_TRACE_WR
+           | _DEBUG_FLAG_TRACE_MODIFY);
 }
index 62eb88afdb250ac73cd33a7321ed141fae4b233a..e50d3021972051cc967163a03199dcdf006492ef 100644 (file)
@@ -46,6 +46,8 @@ static char default_nto_target[] = "";
 
 struct nto_target_ops current_nto_target;
 
+static const struct inferior_data *nto_inferior_data_reg;
+
 static char *
 nto_target (void)
 {
@@ -477,3 +479,53 @@ nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack, gdb_byte *readbuf,
     }
   return len_read;
 }
+
+/* Allocate new nto_inferior_data object.  */
+
+static struct nto_inferior_data *
+nto_new_inferior_data (void)
+{
+  struct nto_inferior_data *const inf_data
+    = XCNEW (struct nto_inferior_data);
+
+  return inf_data;
+}
+
+/* Free inferior data.  */
+
+static void
+nto_inferior_data_cleanup (struct inferior *const inf, void *const dat)
+{
+  xfree (dat);
+}
+
+/* Return nto_inferior_data for the given INFERIOR.  If not yet created,
+   construct it.  */
+
+struct nto_inferior_data *
+nto_inferior_data (struct inferior *const inferior)
+{
+  struct inferior *const inf = inferior ? inferior : current_inferior ();
+  struct nto_inferior_data *inf_data;
+
+  gdb_assert (inf != NULL);
+
+  inf_data = inferior_data (inf, nto_inferior_data_reg);
+  if (inf_data == NULL)
+    {
+      set_inferior_data (inf, nto_inferior_data_reg,
+                        (inf_data = nto_new_inferior_data ()));
+    }
+
+  return inf_data;
+}
+
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern initialize_file_ftype _initialize_nto_tdep;
+
+void
+_initialize_nto_tdep (void)
+{
+  nto_inferior_data_reg
+    = register_inferior_data_with_cleanup (NULL, nto_inferior_data_cleanup);
+}
index d029f073ddd9aecb835041cfbac155c6a02bcc15..6ed9da0c2ce2476eed8336e5bcccb572db74dcff 100644 (file)
@@ -142,6 +142,16 @@ struct private_thread_info
   char name[1];
 };
 
+/* Per-inferior data, common for both procfs and remote.  */
+struct nto_inferior_data
+{
+  /* Last stopped flags result from wait function */
+  unsigned int stopped_flags;
+
+  /* Last known stopped PC */
+  CORE_ADDR stopped_pc;
+};
+
 /* Generic functions in nto-tdep.c.  */
 
 void nto_init_solib_absolute_prefix (void);
@@ -171,4 +181,7 @@ char *nto_extra_thread_info (struct target_ops *self, struct thread_info *);
 LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR inital_stack,
                                          gdb_byte *readbuf,
                                          LONGEST len, size_t sizeof_auxv_t);
+
+struct nto_inferior_data *nto_inferior_data (struct inferior *inf);
+
 #endif
This page took 0.033261 seconds and 4 git commands to generate.