[pushed] gdb: Fix build on several hosts/ports

Message ID 20180625165200.16709-1-palves@redhat.com
State New
Headers show
Series
  • [pushed] gdb: Fix build on several hosts/ports
Related show

Commit Message

Pedro Alves June 25, 2018, 4:52 p.m.
Commit 00431a78b28f ("Use thread_info and inferior pointers more
throughout") missed updating some callers, like e.g.,:

 gdb/remote-sim.c: In member function 'virtual void gdbsim_target::mourn_inferior()':
 gdb/remote-sim.c:1198:50: error: cannot convert 'ptid_t' to 'thread_info*' for argument '1' to 'void delete_thread_silent(thread_info*)'
   delete_thread_silent (sim_data->remote_sim_ptid);

 gdb/mygit/src/gdb/procfs.c: In member function ‘virtual void procfs_target::detach(inferior*, int)’:
 gdb/mygit/src/gdb/procfs.c:1931:23: error: invalid conversion from ‘int’ to ‘inferior*’ [-fpermissive]
    detach_inferior (pid);
			 ^
 In file included from gdb/mygit/src/gdb/procfs.c:24:0:
 gdb/mygit/src/gdb/inferior.h:476:13: note:   initializing argument 1 of ‘void detach_inferior(inferior*)’

 etc.

This fixes it.

The delete_thread_silent calls in both go32-nat.c and remote-sim.c are
unnecessary because generic_mourn_inferior calls exit_inferior, which
deletes the inferior's threads.

gdb/ChangeLog:
2018-06-25  Pedro Alves  <palves@redhat.com>

	* windows-nat.c (windows_delete_thread): Use find_thread_ptid and
	pass thread_info pointer to delete_thread.
	(windows_nat_target::detach): Pass inferior pointer to
	detach_inferior.
	* aix-thread.c (sync_threadlists): Pass thread_info pointer to
	delete_thread.
	* bsd-kvm.c (bsd_kvm_target::close): Use discard_all_inferiors.
	* darwin-nat.c (darwin_check_new_threads): Use find_thread_ptid
	and pass a thread_info pointer to delete_thread.
	* fbsd-nat.c (fbsd_nat_target::wait): Use find_thread_ptid and
	pass thread_info pointer to delete_thread.
	* go32-nat.c (go32_nat_target::mourn_inferior): Remove
	delete_thread_silent call.
	* procfs.c (procfs_target::detach): Pass inferior pointer to
	detach_inferior.
	(procfs_target::wait): Pass thread_info pointer to delete_thread.
	* remote-sim.c (gdbsim_target::mourn_inferior): Remove
	delete_thread_silent call.
	* windows-nat.c (windows_delete_thread): Use find_thread_ptid and
	pass thread_info pointer to delete_thread.
	(windows_nat_target::detach): Pass inferior pointer to
	delete_inferior.
---
 gdb/ChangeLog     | 25 +++++++++++++++++++++++++
 gdb/aix-thread.c  |  4 ++--
 gdb/bsd-kvm.c     |  2 +-
 gdb/darwin-nat.c  |  4 +++-
 gdb/fbsd-nat.c    |  5 +++--
 gdb/go32-nat.c    |  1 -
 gdb/procfs.c      |  6 +++---
 gdb/remote-sim.c  |  1 -
 gdb/windows-nat.c |  4 ++--
 9 files changed, 39 insertions(+), 13 deletions(-)

-- 
2.14.4

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9539c87ca18..4a3f7183a51 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,28 @@ 
+2018-06-25  Pedro Alves  <palves@redhat.com>
+
+	* windows-nat.c (windows_delete_thread): Use find_thread_ptid and
+	pass thread_info pointer to delete_thread.
+	(windows_nat_target::detach): Pass inferior pointer to
+	detach_inferior.
+	* aix-thread.c (sync_threadlists): Pass thread_info pointer to
+	delete_thread.
+	* bsd-kvm.c (bsd_kvm_target::close): Use discard_all_inferiors.
+	* darwin-nat.c (darwin_check_new_threads): Use find_thread_ptid
+	and pass a thread_info pointer to delete_thread.
+	* fbsd-nat.c (fbsd_nat_target::wait): Use find_thread_ptid and
+	pass thread_info pointer to delete_thread.
+	* go32-nat.c (go32_nat_target::mourn_inferior): Remove
+	delete_thread_silent call.
+	* procfs.c (procfs_target::detach): Pass inferior pointer to
+	detach_inferior.
+	(procfs_target::wait): Pass thread_info pointer to delete_thread.
+	* remote-sim.c (gdbsim_target::mourn_inferior): Remove
+	delete_thread_silent call.
+	* windows-nat.c (windows_delete_thread): Use find_thread_ptid and
+	pass thread_info pointer to delete_thread.
+	(windows_nat_target::detach): Pass inferior pointer to
+	delete_inferior.
+
 2018-06-22  Alan Hayward  <alan.hayward@arm.com>
 
 	* regcache.c (readable_regcache::read_part): Fix asserts.
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 643d3213f0e..345242aa571 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -800,7 +800,7 @@  sync_threadlists (void)
     {
       if (pi == pcount)
 	{
-	  delete_thread (gbuf[gi]->ptid);
+	  delete_thread (gbuf[gi]);
 	  gi++;
 	}
       else if (gi == gcount)
@@ -836,7 +836,7 @@  sync_threadlists (void)
 	    }
 	  else if (cmp_result > 0)
 	    {
-	      delete_thread (gptid);
+	      delete_thread (gbuf[gi]);
 	      gi++;
 	    }
 	  else
diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
index 336dbf2b976..434c1928b79 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -155,7 +155,7 @@  bsd_kvm_target::close ()
     }
 
   inferior_ptid = null_ptid;
-  delete_thread_silent (bsd_kvm_ptid);
+  discard_all_inferiors ();
 }
 
 static LONGEST
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index ed1ed328989..7dccce73926 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -350,7 +350,9 @@  darwin_check_new_threads (struct inferior *inf)
       if (old_ix < old_nbr && (new_ix == new_nbr || new_id > old_id))
 	{
 	  /* A thread was removed.  */
-	  delete_thread (ptid_build (inf->pid, 0, old_id));
+	  struct thread_info *thr
+	    = find_thread_ptid (ptid_build (inf->pid, 0, old_id));
+	  delete_thread (thr);
 	  kret = mach_port_deallocate (gdb_task, old_id);
 	  MACH_CHECK_ERROR (kret);
 	  old_ix++;
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 069e1e44bee..f9c622cf138 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -1274,7 +1274,8 @@  fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 		 threads might be skipped during post_attach that
 		 have not yet reported their PL_FLAG_EXITED event.
 		 Ignore EXITED events for an unknown LWP.  */
-	      if (in_thread_list (wptid))
+	      thread_info *thr = find_thread_ptid (wptid);
+	      if (thr != nullptr)
 		{
 		  if (debug_fbsd_lwp)
 		    fprintf_unfiltered (gdb_stdlog,
@@ -1283,7 +1284,7 @@  fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 		  if (print_thread_events)
 		    printf_unfiltered (_("[%s exited]\n"), target_pid_to_str
 				       (wptid));
-		  delete_thread (wptid);
+		  delete_thread (thr);
 		}
 	      if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1)
 		perror_with_name (("ptrace"));
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index f00e424d464..687fd295fb7 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -788,7 +788,6 @@  go32_nat_target::mourn_inferior ()
 
   ptid = inferior_ptid;
   inferior_ptid = null_ptid;
-  delete_thread_silent (ptid);
   prog_has_started = 0;
 
   generic_mourn_inferior ();
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 8b09eca6ed9..ab959b78542 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -1928,7 +1928,7 @@  procfs_target::detach (inferior *inf, int from_tty)
   do_detach ();
 
   inferior_ptid = null_ptid;
-  detach_inferior (pid);
+  detach_inferior (inf);
   maybe_unpush_target ();
 }
 
@@ -2295,7 +2295,7 @@  wait_again:
 		    if (print_thread_events)
 		      printf_unfiltered (_("[%s exited]\n"),
 					 target_pid_to_str (retval));
-		    delete_thread (retval);
+		    delete_thread (find_thread_ptid (retval));
 		    status->kind = TARGET_WAITKIND_SPURIOUS;
 		    return retval;
 		  }
@@ -2414,7 +2414,7 @@  wait_again:
 		    if (print_thread_events)
 		      printf_unfiltered (_("[%s exited]\n"),
 					 target_pid_to_str (retval));
-		    delete_thread (retval);
+		    delete_thread (find_thread_ptid (retval));
 		    status->kind = TARGET_WAITKIND_SPURIOUS;
 		    return retval;
 		  }
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 9c89ab9db72..29bfe1dc7e1 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -1195,7 +1195,6 @@  gdbsim_target::mourn_inferior ()
 
   remove_breakpoints ();
   generic_mourn_inferior ();
-  delete_thread_silent (sim_data->remote_sim_ptid);
 }
 
 /* Pass the command argument through to the simulator verbatim.  The
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 63a780014ab..98d94a33f25 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -493,7 +493,7 @@  windows_delete_thread (ptid_t ptid, DWORD exit_code)
   else if (print_thread_events && id != main_thread_id)
     printf_unfiltered (_("[%s exited with code %u]\n"),
 		       target_pid_to_str (ptid), (unsigned) exit_code);
-  delete_thread (ptid);
+  delete_thread (find_thread_ptid (ptid));
 
   for (th = &thread_head;
        th->next != NULL && th->next->id != id;
@@ -2000,7 +2000,7 @@  windows_nat_target::detach (inferior *inf, int from_tty)
 
   x86_cleanup_dregs ();
   inferior_ptid = null_ptid;
-  detach_inferior (current_event.dwProcessId);
+  detach_inferior (inf);
 
   maybe_unpush_target ();
 }