Remove ptid_build
[deliverable/binutils-gdb.git] / gdb / bsd-uthread.c
index 1505cfede70541ab9b777b4401a05fdb45c46013..c2e6ea9536de1ebb322d34ef9154392b7567c87f 100644 (file)
@@ -310,8 +310,7 @@ bsd_uthread_solib_unloaded (struct so_list *so)
 void
 bsd_uthread_target::mourn_inferior ()
 {
-  struct target_ops *beneath = find_target_beneath (this);
-  beneath->mourn_inferior ();
+  beneath ()->mourn_inferior ();
   bsd_uthread_deactivate ();
 }
 
@@ -321,9 +320,8 @@ bsd_uthread_target::fetch_registers (struct regcache *regcache, int regnum)
   struct gdbarch *gdbarch = regcache->arch ();
   struct bsd_uthread_ops *uthread_ops
     = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
-  ptid_t ptid = regcache_get_ptid (regcache);
+  ptid_t ptid = regcache->ptid ();
   CORE_ADDR addr = ptid_get_tid (ptid);
-  struct target_ops *beneath = find_target_beneath (this);
   CORE_ADDR active_addr;
   scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
 
@@ -332,7 +330,7 @@ bsd_uthread_target::fetch_registers (struct regcache *regcache, int regnum)
   inferior_ptid = ptid;
 
   /* Always fetch the appropriate registers from the layer beneath.  */
-  beneath->fetch_registers (regcache, regnum);
+  beneath ()->fetch_registers (regcache, regnum);
 
   /* FIXME: That might have gotten us more than we asked for.  Make
      sure we overwrite all relevant registers with values from the
@@ -354,8 +352,7 @@ bsd_uthread_target::store_registers (struct regcache *regcache, int regnum)
   struct gdbarch *gdbarch = regcache->arch ();
   struct bsd_uthread_ops *uthread_ops
     = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
-  struct target_ops *beneath = find_target_beneath (this);
-  ptid_t ptid = regcache_get_ptid (regcache);
+  ptid_t ptid = regcache->ptid ();
   CORE_ADDR addr = ptid_get_tid (ptid);
   CORE_ADDR active_addr;
   scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
@@ -375,7 +372,7 @@ bsd_uthread_target::store_registers (struct regcache *regcache, int regnum)
     {
       /* Updating the thread that is currently running; pass the
          request to the layer beneath.  */
-      beneath->store_registers (regcache, regnum);
+      beneath ()->store_registers (regcache, regnum);
     }
 }
 
@@ -385,10 +382,9 @@ bsd_uthread_target::wait (ptid_t ptid, struct target_waitstatus *status,
 {
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   CORE_ADDR addr;
-  struct target_ops *beneath = find_target_beneath (this);
 
   /* Pass the request to the layer beneath.  */
-  ptid = beneath->wait (ptid, status, options);
+  ptid = beneath ()->wait (ptid, status, options);
 
   /* If the process is no longer alive, there's no point in figuring
      out the thread ID.  It will fail anyway.  */
@@ -411,7 +407,7 @@ bsd_uthread_target::wait (ptid_t ptid, struct target_waitstatus *status,
        {
          ULONGEST magic = extract_unsigned_integer (buf, 4, byte_order);
          if (magic == BSD_UTHREAD_PTHREAD_MAGIC)
-           ptid = ptid_build (ptid_get_pid (ptid), 0, addr);
+           ptid = ptid_t (ptid_get_pid (ptid), 0, addr);
        }
     }
 
@@ -423,7 +419,8 @@ bsd_uthread_target::wait (ptid_t ptid, struct target_waitstatus *status,
     thread_change_ptid (inferior_ptid, ptid);
 
   /* Don't let the core see a ptid without a corresponding thread.  */
-  if (!in_thread_list (ptid) || is_exited (ptid))
+  thread_info *thread = find_thread_ptid (ptid);
+  if (thread == NULL || thread->state == THREAD_EXITED)
     add_thread (ptid);
 
   return ptid;
@@ -433,15 +430,13 @@ void
 bsd_uthread_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 {
   /* Pass the request to the layer beneath.  */
-  struct target_ops *beneath = find_target_beneath (this);
-  beneath->resume (ptid, step, sig);
+  beneath ()->resume (ptid, step, sig);
 }
 
 bool
 bsd_uthread_target::thread_alive (ptid_t ptid)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
-  struct target_ops *beneath = find_target_beneath (this);
   CORE_ADDR addr = ptid_get_tid (ptid);
 
   if (addr != 0)
@@ -456,7 +451,7 @@ bsd_uthread_target::thread_alive (ptid_t ptid)
        return false;
     }
 
-  return beneath->thread_alive (ptid);
+  return beneath ()->thread_alive (ptid);
 }
 
 void
@@ -471,9 +466,10 @@ bsd_uthread_target::update_thread_list ()
   addr = bsd_uthread_read_memory_address (bsd_uthread_thread_list_addr);
   while (addr != 0)
     {
-      ptid_t ptid = ptid_build (pid, 0, addr);
+      ptid_t ptid = ptid_t (pid, 0, addr);
 
-      if (!in_thread_list (ptid) || is_exited (ptid))
+      thread_info *thread = find_thread_ptid (ptid);
+      if (thread == nullptr || thread->state == THREAD_EXITED)
        {
          /* If INFERIOR_PTID doesn't have a tid member yet, then ptid
             is still the initial thread of the process.  Notify GDB
This page took 0.032642 seconds and 4 git commands to generate.