gdbserver x86 on win32: call init_target_desc
[deliverable/binutils-gdb.git] / gdb / aix-thread.c
index 693d6f6fae7c7852c74f63b2f72a7491a83deebb..f9ec8641657389b2ae2004e5c7aa722ba965c17c 100644 (file)
@@ -1,6 +1,6 @@
 /* Low level interface for debugging AIX 4.3+ pthreads.
 
-   Copyright (C) 1999-2016 Free Software Foundation, Inc.
+   Copyright (C) 1999-2017 Free Software Foundation, Inc.
    Written by Nick Duffek <nsd@redhat.com>.
 
    This file is part of GDB.
@@ -155,7 +155,7 @@ static pthdb_session_t pd_session;
 /* Return a printable representation of pthdebug function return
    STATUS.  */
 
-static char *
+static const char *
 pd_status2str (int status)
 {
   switch (status)
@@ -985,12 +985,11 @@ aix_thread_resume (struct target_ops *ops,
 
   if (!PD_TID (ptid))
     {
-      struct cleanup *cleanup = save_inferior_ptid ();
+      scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
       struct target_ops *beneath = find_target_beneath (ops);
       
       inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
       beneath->to_resume (beneath, ptid, step, sig);
-      do_cleanups (cleanup);
     }
   else
     {
@@ -1022,14 +1021,16 @@ static ptid_t
 aix_thread_wait (struct target_ops *ops,
                 ptid_t ptid, struct target_waitstatus *status, int options)
 {
-  struct cleanup *cleanup = save_inferior_ptid ();
   struct target_ops *beneath = find_target_beneath (ops);
 
-  pid_to_prc (&ptid);
+  {
+    scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
 
-  inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
-  ptid = beneath->to_wait (beneath, ptid, status, options);
-  do_cleanups (cleanup);
+    pid_to_prc (&ptid);
+
+    inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+    ptid = beneath->to_wait (beneath, ptid, status, options);
+  }
 
   if (ptid_get_pid (ptid) == -1)
     return pid_to_ptid (-1);
@@ -1297,8 +1298,8 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
     }
 }
 
-/* Fetch register REGNO if != -1 or all registers otherwise in the
-   thread/process specified by inferior_ptid.  */
+/* Fetch register REGNO if != -1 or all registers otherwise from the
+   thread/process connected to REGCACHE.  */
 
 static void
 aix_thread_fetch_registers (struct target_ops *ops,
@@ -1308,11 +1309,11 @@ aix_thread_fetch_registers (struct target_ops *ops,
   pthdb_tid_t tid;
   struct target_ops *beneath = find_target_beneath (ops);
 
-  if (!PD_TID (inferior_ptid))
+  if (!PD_TID (regcache_get_ptid (regcache)))
     beneath->to_fetch_registers (beneath, regcache, regno);
   else
     {
-      thread = find_thread_ptid (inferior_ptid);
+      thread = find_thread_ptid (regcache_get_ptid (regcache));
       tid = thread->priv->tid;
 
       if (tid == PTHDB_INVALID_TID)
@@ -1652,7 +1653,7 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
 }
 
 /* Store gdb's current view of the register set into the
-   thread/process specified by inferior_ptid.  */
+   thread/process connected to REGCACHE.  */
 
 static void
 aix_thread_store_registers (struct target_ops *ops,
@@ -1662,11 +1663,11 @@ aix_thread_store_registers (struct target_ops *ops,
   pthdb_tid_t tid;
   struct target_ops *beneath = find_target_beneath (ops);
 
-  if (!PD_TID (inferior_ptid))
+  if (!PD_TID (regcache_get_ptid (regcache)))
     beneath->to_store_registers (beneath, regcache, regno);
   else
     {
-      thread = find_thread_ptid (inferior_ptid);
+      thread = find_thread_ptid (regcache_get_ptid (regcache));
       tid = thread->priv->tid;
 
       if (tid == PTHDB_INVALID_TID)
@@ -1684,16 +1685,12 @@ aix_thread_xfer_partial (struct target_ops *ops, enum target_object object,
                         const gdb_byte *writebuf,
                         ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
 {
-  struct cleanup *old_chain = save_inferior_ptid ();
-  enum target_xfer_status xfer;
+  scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
   struct target_ops *beneath = find_target_beneath (ops);
 
   inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
-  xfer = beneath->to_xfer_partial (beneath, object, annex, readbuf,
+  return beneath->to_xfer_partial (beneath, object, annex, readbuf,
                                   writebuf, offset, len, xfered_len);
-
-  do_cleanups (old_chain);
-  return xfer;
 }
 
 /* Clean up after the inferior exits.  */
@@ -1725,7 +1722,7 @@ aix_thread_thread_alive (struct target_ops *ops, ptid_t ptid)
 /* Return a printable representation of composite PID for use in
    "info threads" output.  */
 
-static char *
+static const char *
 aix_thread_pid_to_str (struct target_ops *ops, ptid_t ptid)
 {
   static char *ret = NULL;
@@ -1745,11 +1742,10 @@ aix_thread_pid_to_str (struct target_ops *ops, ptid_t ptid)
 /* Return a printable representation of extra information about
    THREAD, for use in "info threads" output.  */
 
-static char *
+static const char *
 aix_thread_extra_thread_info (struct target_ops *self,
                              struct thread_info *thread)
 {
-  struct ui_file *buf;
   int status;
   pthdb_pthread_t pdtid;
   pthdb_tid_t tid;
@@ -1762,43 +1758,42 @@ aix_thread_extra_thread_info (struct target_ops *self,
   if (!PD_TID (thread->ptid))
     return NULL;
 
-  buf = mem_fileopen ();
+  string_file buf;
 
   pdtid = thread->priv->pdtid;
   tid = thread->priv->tid;
 
   if (tid != PTHDB_INVALID_TID)
     /* i18n: Like "thread-identifier %d, [state] running, suspended" */
-    fprintf_unfiltered (buf, _("tid %d"), (int)tid);
+    buf.printf (_("tid %d"), (int)tid);
 
   status = pthdb_pthread_state (pd_session, pdtid, &state);
   if (status != PTHDB_SUCCESS)
     state = PST_NOTSUP;
-  fprintf_unfiltered (buf, ", %s", state2str (state));
+  buf.printf (", %s", state2str (state));
 
   status = pthdb_pthread_suspendstate (pd_session, pdtid, 
                                       &suspendstate);
   if (status == PTHDB_SUCCESS && suspendstate == PSS_SUSPENDED)
     /* i18n: Like "Thread-Id %d, [state] running, suspended" */
-    fprintf_unfiltered (buf, _(", suspended"));
+    buf.printf (_(", suspended"));
 
   status = pthdb_pthread_detachstate (pd_session, pdtid, 
                                      &detachstate);
   if (status == PTHDB_SUCCESS && detachstate == PDS_DETACHED)
     /* i18n: Like "Thread-Id %d, [state] running, detached" */
-    fprintf_unfiltered (buf, _(", detached"));
+    buf.printf (_(", detached"));
 
   pthdb_pthread_cancelpend (pd_session, pdtid, &cancelpend);
   if (status == PTHDB_SUCCESS && cancelpend)
     /* i18n: Like "Thread-Id %d, [state] running, cancel pending" */
-    fprintf_unfiltered (buf, _(", cancel pending"));
+    buf.printf (_(", cancel pending"));
 
-  ui_file_write (buf, "", 1);
+  buf.write ("", 1);
 
   xfree (ret);                 /* Free old buffer.  */
 
-  ret = ui_file_xstrdup (buf, NULL);
-  ui_file_delete (buf);
+  ret = xstrdup (buf.c_str ());
 
   return ret;
 }
@@ -1836,8 +1831,6 @@ init_aix_thread_ops (void)
 /* Module startup initialization function, automagically called by
    init.c.  */
 
-void _initialize_aix_thread (void);
-
 void
 _initialize_aix_thread (void)
 {
This page took 0.028353 seconds and 4 git commands to generate.