/* Return the task number of the task whose ptid is PTID, or zero
if the task could not be found. */
-static int
+int
ada_get_task_number (ptid_t ptid)
{
int i;
/* Extract LEN characters from the fat string. */
array_val = value_ind (value_field (val, array_fieldno));
- read_memory (VALUE_ADDRESS (array_val), dest, len);
+ read_memory (value_address (array_val), dest, len);
/* Add the NUL character to close the string. */
dest[len] = '\0';
ada_coerce_to_simple_array_ptr (value_field (tcb_value,
fieldno.entry_calls));
entry_calls_value_element =
- value_subscript (entry_calls_value, atc_nesting_level_value);
+ value_subscript (entry_calls_value,
+ value_as_long (atc_nesting_level_value));
called_task_fieldno =
ada_get_field_index (value_type (entry_calls_value_element),
"called_task", 0);
read_known_tasks_array (void)
{
const int target_ptr_byte =
- gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT;
+ gdbarch_ptr_bit (target_gdbarch) / TARGET_CHAR_BIT;
const CORE_ADDR known_tasks_addr = get_known_tasks_addr ();
const int known_tasks_size = target_ptr_byte * MAX_NUMBER_OF_KNOWN_TASKS;
gdb_byte *known_tasks = alloca (known_tasks_size);
for (i = 0; i < MAX_NUMBER_OF_KNOWN_TASKS; i++)
{
struct type *data_ptr_type =
- builtin_type (current_gdbarch)->builtin_data_ptr;
+ builtin_type (target_gdbarch)->builtin_data_ptr;
CORE_ADDR task_id =
extract_typed_address (known_tasks + i * target_ptr_byte,
data_ptr_type);
else if (task_info->state == Entry_Caller_Sleep && task_info->called_task)
printf_filtered (_(" Waiting on RV with %-3d"),
get_task_number_from_id (task_info->called_task));
- else if (task_info->state == Runnable && active_task_p)
- /* Replace "Runnable" by "Running" since this is the active task. */
- printf_filtered (" %-22s", _("Running"));
else
printf_filtered (" %-22s", _(task_states[task_info->state]));
task_info = VEC_index (ada_task_info_s, task_list, taskno - 1);
/* Print the Ada task ID. */
- printf_filtered (_("Ada Task: %s\n"), paddr_nz (task_info->task_id));
+ printf_filtered (_("Ada Task: %s\n"),
+ paddress (target_gdbarch, task_info->task_id));
/* Print the name of the task. */
if (task_info->name[0] != '\0')
if (!ada_task_is_alive (task_info))
error (_("Cannot switch to task %d: Task is no longer running"), taskno);
+ /* On some platforms, the thread list is not updated until the user
+ performs a thread-related operation (by using the "info threads"
+ command, for instance). So this thread list may not be up to date
+ when the user attempts this task switch. Since we cannot switch
+ to the thread associated to our task if GDB does not know about
+ that thread, we need to make sure that any new threads gets added
+ to the thread list. */
+ target_find_new_threads ();
+
switch_to_thread (task_info->ptid);
ada_find_printable_frame (get_selected_frame (NULL));
printf_filtered (_("[Switching to task %d]\n"), taskno);