Per-inferior target_terminal state, fix PR gdb/13211, more
[deliverable/binutils-gdb.git] / gdb / nto-procfs.c
index a6fe390b02995a43e31ee90e482cd33c3ae40b9b..d72bc1145aa6e225816ad3b5214b0a01ca4fc852 100644 (file)
@@ -1,7 +1,7 @@
 /* Machine independent support for QNX Neutrino /proc (process file system)
    for GDB.  Written by Colin Burgess at QNX Software Systems Limited.
 
-   Copyright (C) 2003-2017 Free Software Foundation, Inc.
+   Copyright (C) 2003-2018 Free Software Foundation, Inc.
 
    Contributed by QNX Software Systems Ltd.
 
@@ -248,38 +248,24 @@ static void
 update_thread_private_data_name (struct thread_info *new_thread,
                                 const char *newname)
 {
-  int newnamelen;
-  struct private_thread_info *pti;
+  nto_thread_info *pti = get_nto_thread_info (new_thread);
 
   gdb_assert (newname != NULL);
   gdb_assert (new_thread != NULL);
-  newnamelen = strlen (newname);
-  if (!new_thread->priv)
-    {
-      new_thread->priv = xmalloc (offsetof (struct private_thread_info,
-                                              name)
-                                    + newnamelen + 1);
-      memcpy (new_thread->priv->name, newname, newnamelen + 1);
-    }
-  else if (strcmp (newname, new_thread->priv->name) != 0)
+
+  if (pti)
     {
-      /* Reallocate if neccessary.  */
-      int oldnamelen = strlen (new_thread->priv->name);
-
-      if (oldnamelen < newnamelen)
-       new_thread->priv = xrealloc (new_thread->priv,
-                                       offsetof (struct private_thread_info,
-                                                 name)
-                                       + newnamelen + 1);
-      memcpy (new_thread->priv->name, newname, newnamelen + 1);
+      pti = new nto_thread_info;
+      new_thread->priv.reset (pti);
     }
+
+  pti->name = newname;
 }
 
 static void 
 update_thread_private_data (struct thread_info *new_thread, 
                            pthread_t tid, int state, int flags)
 {
-  struct private_thread_info *pti;
   procfs_info pidinfo;
   struct _thread_name *tn;
   procfs_threadctl tctl;
@@ -306,7 +292,7 @@ update_thread_private_data (struct thread_info *new_thread,
 
   update_thread_private_data_name (new_thread, tn->name_buf);
 
-  pti = (struct private_thread_info *) new_thread->priv;
+  nto_thread_info *pti = get_nto_thread_info (new_thread);
   pti->tid = tid;
   pti->state = state;
   pti->flags = flags;
@@ -359,7 +345,7 @@ do_closedir_cleanup (void *dir)
 }
 
 static void
-procfs_pidlist (char *args, int from_tty)
+procfs_pidlist (const char *args, int from_tty)
 {
   DIR *dp = NULL;
   struct dirent *dirp = NULL;
@@ -461,7 +447,7 @@ procfs_pidlist (char *args, int from_tty)
 }
 
 static void
-procfs_meminfo (char *args, int from_tty)
+procfs_meminfo (const char *args, int from_tty)
 {
   procfs_mapinfo *mapinfos = NULL;
   static int num_mapinfos = 0;
@@ -746,7 +732,7 @@ nto_handle_sigint (int signo)
   /* If this doesn't work, try more severe steps.  */
   signal (signo, nto_handle_sigint_twice);
 
-  target_interrupt (inferior_ptid);
+  target_interrupt ();
 }
 
 static ptid_t
@@ -957,18 +943,14 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
    on signals, etc.  We'd better not have left any breakpoints
    in the program or it'll die when it hits one.  */
 static void
-procfs_detach (struct target_ops *ops, const char *args, int from_tty)
+procfs_detach (struct target_ops *ops, inferior *inf, int from_tty)
 {
-  int siggnal = 0;
   int pid;
 
   target_announce_detach ();
 
-  if (args)
-    siggnal = atoi (args);
-
   if (siggnal)
-    SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0, siggnal, 0, 0);
+    SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0, 0, 0, 0);
 
   close (ctl_fd);
   ctl_fd = -1;
@@ -1285,7 +1267,7 @@ procfs_create_inferior (struct target_ops *ops, const char *exec_file,
     }
   if (!target_is_pushed (ops))
     push_target (ops);
-  target_terminal_init ();
+  target_terminal::init ();
 
   if (exec_bfd != NULL
       || (symfile_objfile != NULL && symfile_objfile->obfd != NULL))
@@ -1293,7 +1275,7 @@ procfs_create_inferior (struct target_ops *ops, const char *exec_file,
 }
 
 static void
-procfs_interrupt (struct target_ops *self, ptid_t ptid)
+procfs_interrupt (struct target_ops *self)
 {
   devctl (ctl_fd, DCMD_PROC_STOP, NULL, 0, 0);
 }
@@ -1386,7 +1368,7 @@ procfs_store_registers (struct target_ops *ops,
       if (dev_set == -1)
        return;
 
-      len = nto_register_area (get_regcache_arch (regcache),
+      len = nto_register_area (regcache->arch (),
                               regno, regset, &off);
 
       if (len < 1)
This page took 0.026557 seconds and 4 git commands to generate.