This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Fix GDB build failure on Windows
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 25 Jun 2018 14:27:34 -0400
- Subject: [RFA] Fix GDB build failure on Windows
Hello,
A recent enhancement to use thread_info and inferior pointers more
throughout accidently broke the build in windows-nat.c. This patch
fixes it by completing the transition for the couple of spots that
were missed.
gdb/ChangeLog:
* windows-nat.c (windows_delete_thread): Make parameter ptid
a constant reference. Fix call to delete_thread. Log a
DEBUG_EVENTS message if the thread_info corresponding to
the given ptid_t could not be found.
(windows_nat_target::detach): Fix call to detach_inferior.
Tested on x86-windows and x86_64-windows, using AdaCore's testsuite.
OK to apply?
Thanks,
--
Joel
---
gdb/windows-nat.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 63a7800..620e25c 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -479,7 +479,7 @@ windows_init_thread_list (void)
/* Delete a thread from the list of threads. */
static void
-windows_delete_thread (ptid_t ptid, DWORD exit_code)
+windows_delete_thread (const ptid_t &ptid, DWORD exit_code)
{
windows_thread_info *th;
DWORD id;
@@ -493,7 +493,26 @@ 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);
+
+ thread_info *tp = find_thread_ptid (ptid);
+ if (tp != NULL)
+ delete_thread (tp);
+ else
+ {
+ /* Something unexpected happened: We are trying to delete
+ a thread that the core layer apparently does not know about.
+ This should never happen, and thus we want to be able to
+ report this discrepancy should it actually happen and have
+ unanticipated side-effects; but since we were trying to
+ delete the thread anyway, it's quite possible that this
+ issue has no actual consequence in terms of the overall
+ behavior. So, instead of unnecessarily worrying the user
+ with a warning or internal-error, just log a DEBUG_EVENTS
+ event. */
+ DEBUG_EVENTS (("gdb: windows_delete_thread cannot find thread"
+ " for ptid (pid=%d, tid=%ld)\n",
+ ptid.pid(), ptid.tid()));
+ }
for (th = &thread_head;
th->next != NULL && th->next->id != id;
@@ -2000,7 +2019,7 @@ windows_nat_target::detach (inferior *inf, int from_tty)
x86_cleanup_dregs ();
inferior_ptid = null_ptid;
- detach_inferior (current_event.dwProcessId);
+ detach_inferior (current_inferior ());
maybe_unpush_target ();
}
--
2.1.4