aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-tasks.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2017-11-21 14:00:30 -0800
committerJoel Brobecker <brobecker@adacore.com>2017-11-21 14:32:10 -0800
commit9edcc12f9b714149f84bcf20dbdad91f030e62de (patch)
treeac62a5351db50684dcaeaa663a5f5885a42a40cb /gdb/ada-tasks.c
parent65d40437e2704e635e7144319e956edf3e7fa026 (diff)
downloadgdb-9edcc12f9b714149f84bcf20dbdad91f030e62de.zip
gdb-9edcc12f9b714149f84bcf20dbdad91f030e62de.tar.gz
gdb-9edcc12f9b714149f84bcf20dbdad91f030e62de.tar.bz2
Add multiple-CPU support in ravenscar-thread.c
This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
Diffstat (limited to 'gdb/ada-tasks.c')
-rw-r--r--gdb/ada-tasks.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index e29b563..16cee35 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -353,6 +353,30 @@ ada_task_is_alive (struct ada_task_info *task_info)
return (task_info->state != Terminated);
}
+/* Search through the list of known tasks for the one whose ptid is
+ PTID, and return it. Return NULL if the task was not found. */
+
+struct ada_task_info *
+ada_get_task_info_from_ptid (ptid_t ptid)
+{
+ int i, nb_tasks;
+ struct ada_task_info *task;
+ struct ada_tasks_inferior_data *data;
+
+ ada_build_task_list ();
+ data = get_ada_tasks_inferior_data (current_inferior ());
+ nb_tasks = VEC_length (ada_task_info_s, data->task_list);
+
+ for (i = 0; i < nb_tasks; i++)
+ {
+ task = VEC_index (ada_task_info_s, data->task_list, i);
+ if (ptid_equal (task->ptid, ptid))
+ return task;
+ }
+
+ return NULL;
+}
+
/* Call the ITERATOR function once for each Ada task that hasn't been
terminated yet. */