Fix tracepoint.c:parse_tracepoint_definition leak (and one more)
[deliverable/binutils-gdb.git] / gdb / ada-tasks.c
index 566eae599ef82ff05726d68de6a7902f048dd4e0..e994147a669bf4c6bb15877dbe90ba84303df18d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -611,6 +611,10 @@ read_atcb (CORE_ADDR task_id, struct ada_task_info *task_info)
   const struct ada_tasks_pspace_data *pspace_data
     = get_ada_tasks_pspace_data (current_program_space);
 
+  /* Clear the whole structure to start with, so that everything
+     is always initialized the same.  */
+  memset (task_info, 0, sizeof (struct ada_task_info));
+
   if (!pspace_data->initialized_p)
     {
       const char *err_msg = ada_get_tcb_types_info ();
@@ -704,14 +708,12 @@ read_atcb (CORE_ADDR task_id, struct ada_task_info *task_info)
     task_info->parent =
       value_as_address (value_field (common_value,
                                     pspace_data->atcb_fieldno.parent));
-  else
-    task_info->parent = 0;
-  
 
-  /* If the ATCB contains some information about entry calls, then
-     compute the "called_task" as well.  Otherwise, zero.  */
+  /* If the task is in an entry call waiting for another task,
+     then determine which task it is.  */
 
-  if (pspace_data->atcb_fieldno.atc_nesting_level > 0
+  if (task_info->state == Entry_Caller_Sleep
+      && pspace_data->atcb_fieldno.atc_nesting_level > 0
       && pspace_data->atcb_fieldno.entry_calls > 0)
     {
       /* Let My_ATCB be the Ada task control block of a task calling the
@@ -732,15 +734,10 @@ read_atcb (CORE_ADDR task_id, struct ada_task_info *task_info)
         value_as_address (value_field (entry_calls_value_element,
                                        called_task_fieldno));
     }
-  else
-    {
-      task_info->called_task = 0;
-    }
 
-  /* If the ATCB cotnains some information about RV callers,
-     then compute the "caller_task".  Otherwise, zero.  */
+  /* If the ATCB cotnains some information about RV callers, then
+     compute the "caller_task".  Otherwise, leave it as zero.  */
 
-  task_info->caller_task = 0;
   if (pspace_data->atcb_fieldno.call >= 0)
     {
       /* Get the ID of the caller task from Common_ATCB.Call.all.Self.
@@ -1130,8 +1127,7 @@ print_ada_task_info (struct ui_out *uiout,
                          _("Accepting RV with %-4d"),
                          get_task_number_from_id (task_info->caller_task,
                                                   inf));
-      else if (task_info->state == Entry_Caller_Sleep
-              && task_info->called_task)
+      else if (task_info->called_task)
        uiout->field_fmt ("state",
                          _("Waiting on RV with %-3d"),
                          get_task_number_from_id (task_info->called_task,
@@ -1217,7 +1213,7 @@ info_task (struct ui_out *uiout, const char *taskno_str, struct inferior *inf)
         printf_filtered (_("State: Accepting rendezvous with %d"),
                          target_taskno);
       }
-    else if (task_info->state == Entry_Caller_Sleep && task_info->called_task)
+    else if (task_info->called_task)
       {
         target_taskno = get_task_number_from_id (task_info->called_task, inf);
         printf_filtered (_("State: Waiting on task %d's entry"),
This page took 0.024561 seconds and 4 git commands to generate.