aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAleksandar Ristovski <aristovski@qnx.com>2015-10-16 11:08:38 -0400
committerAleksandar Ristovski <aristovski@qnx.com>2015-10-16 11:11:07 -0400
commit96e7a1eb6d09fda9e22e112e35e7d0085a8f4fd0 (patch)
tree448e47714ec2242170bb57604d9a25dc01832844 /gdb
parent6457197210144f50a696097c0d308d81d46d5510 (diff)
downloadgdb-96e7a1eb6d09fda9e22e112e35e7d0085a8f4fd0.zip
gdb-96e7a1eb6d09fda9e22e112e35e7d0085a8f4fd0.tar.gz
gdb-96e7a1eb6d09fda9e22e112e35e7d0085a8f4fd0.tar.bz2
gdbserver: Reset current_thread when the thread is removed.
Reset current_thread and make sure 'remove_process' is used after all associated threads have been removed first. gdb/gdbserver/ChangeLog: * inferiors.c (thread_pid_matches_callback): New function. (find_thread_process): New function. (remove_thread): Reset current_thread. (remove_process): Assert threads have been removed first.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/gdbserver/inferiors.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index 21f45fa..72a3ef1 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -141,6 +141,27 @@ find_thread_ptid (ptid_t ptid)
return (struct thread_info *) find_inferior_id (&all_threads, ptid);
}
+/* Predicate function for matching thread entry's pid to the given
+ pid value passed by address in ARGS. */
+
+static int
+thread_pid_matches_callback (struct inferior_list_entry *entry, void *args)
+{
+ return (ptid_get_pid (entry->id) == *(pid_t *)args);
+}
+
+/* Find a thread associated with the given PROCESS, or NULL if no
+ such thread exists. */
+
+static struct thread_info *
+find_thread_process (const struct process_info *const process)
+{
+ pid_t pid = ptid_get_pid (ptid_of (process));
+
+ return (struct thread_info *)
+ find_inferior (&all_threads, thread_pid_matches_callback, &pid);
+}
+
ptid_t
gdb_id_to_thread_id (ptid_t gdb_id)
{
@@ -166,6 +187,8 @@ remove_thread (struct thread_info *thread)
discard_queued_stop_replies (ptid_of (thread));
remove_inferior (&all_threads, (struct inferior_list_entry *) thread);
free_one_thread (&thread->entry);
+ if (current_thread == thread)
+ current_thread = NULL;
}
/* Return a pointer to the first inferior in LIST, or NULL if there isn't one.
@@ -291,6 +314,7 @@ remove_process (struct process_info *process)
{
clear_symbol_cache (&process->symbol_cache);
free_all_breakpoints (process);
+ gdb_assert (find_thread_process (process) == NULL);
remove_inferior (&all_processes, &process->entry);
free (process);
}