+2019-11-22 Tom Tromey <tromey@adacore.com>
+
+ * ada-tasks.c (ada_task_is_alive): Make parameter const.
+ (print_ada_task_info): Don't try to fetch thread id if task is not
+ alive.
+
2019-11-22 Christian Biesinger <cbiesinger@google.com>
* ada-exp.y: Update.
task state. */
static int
-ada_task_is_alive (struct ada_task_info *task_info)
+ada_task_is_alive (const struct ada_task_info *task_info)
{
return (task_info->state != Terminated);
}
/* Print the associated Thread ID. */
if (uiout->is_mi_like_p ())
{
- thread_info *thread = find_thread_ptid (task_info->ptid);
+ thread_info *thread = (ada_task_is_alive (task_info)
+ ? find_thread_ptid (task_info->ptid)
+ : nullptr);
if (thread != NULL)
uiout->field_signed ("thread-id", thread->global_num);
else
- /* This should never happen unless there is a bug somewhere,
- but be resilient when that happens. */
- uiout->field_skip ("thread-id");
+ {
+ /* This can happen if the thread is no longer alive. */
+ uiout->field_skip ("thread-id");
+ }
}
/* Print the ID of the parent task. */
+2019-11-22 Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/tasks.exp: Add -ada-task-info regression test.
+ * gdb.ada/tasks/foo.adb: Add another stopping location.
+
2019-11-20 Luis Machado <luis.machado@linaro.org>
* linux-aarch64-low.c (is_sve_tdesc): Check against target feature
# Now, resume the execution and make sure that GDB does not stop when
# task 4 hits the breakpoint. Continuing thus results in our program
# running to completion.
-gdb_continue_to_end "" continue 1
+set bp_location [gdb_get_line_number "STOP_HERE_2" ${testdir}/foo.adb]
+gdb_breakpoint foo.adb:$bp_location
+gdb_continue_to_breakpoint second ".*foo.adb:$bp_location.*null; -- STOP_HERE_2"
+
+# A regression test for a crash caused by trying to find the thread
+# for a terminated task.
+gdb_test "interpreter-exec mi \"-ada-task-info\"" ".*"
for J in Task_List'Range loop
Task_List (J).Finalize;
end loop;
+
+ null; -- STOP_HERE_2
+
end Foo;