* linux-low.c (my_waitpid): Delete unnecessary prototype.
[deliverable/binutils-gdb.git] / gdb / ada-tasks.c
index 599a17b7fc6f4475a70e0d0e19d1a3a77cc4c861..68cc696d56ee0a3a4e36b1113bdad4831804b0bf 100644 (file)
@@ -160,7 +160,7 @@ static int stale_task_list_p = 1;
 /* 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;
@@ -202,6 +202,15 @@ valid_task_id (int task_num)
           && task_num <= VEC_length (ada_task_info_s, task_list));
 }
 
+/* Return non-zero iff the task STATE corresponds to a non-terminated
+   task state.  */
+
+static int
+ada_task_is_alive (struct ada_task_info *task_info)
+{
+  return (task_info->state != Terminated);
+}
+
 /* Extract the contents of the value as a string whose length is LENGTH,
    and store the result in DEST.  */
 
@@ -262,7 +271,7 @@ read_fat_string_value (char *dest, struct value *val, int max_len)
 
   /* 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';
@@ -539,7 +548,8 @@ read_atcb (CORE_ADDR task_id, struct ada_task_info *task_info)
         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);
@@ -600,7 +610,7 @@ static int
 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);
@@ -623,7 +633,7 @@ read_known_tasks_array (void)
   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);
@@ -662,15 +672,6 @@ ada_build_task_list (int warn_if_null)
   return 1;
 }
 
-/* Return non-zero iff the task STATE corresponds to a non-terminated
-   task state.  */
-
-int
-ada_task_is_alive (struct ada_task_info *task_info)
-{
-  return (task_info->state != Terminated);
-}
-
 /* Print a one-line description of the task whose number is TASKNO.
    The formatting should fit the "info tasks" array.  */
 
@@ -711,9 +712,6 @@ short_task_info (int taskno)
   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]));
 
@@ -754,7 +752,8 @@ info_task (char *taskno_str, int from_tty)
   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')
@@ -868,6 +867,15 @@ task_command_1 (char *taskno_str, int from_tty)
   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);
This page took 0.027795 seconds and 4 git commands to generate.