-/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdbthread.h"
#include "progspace.h"
#include "objfiles.h"
+#include "cli/cli-style.h"
static int ada_build_task_list ();
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);
}
bounds_fieldno = ada_get_field_index (type, "P_BOUNDS", 0);
bounds_type = TYPE_FIELD_TYPE (type, bounds_fieldno);
- if (TYPE_CODE (bounds_type) == TYPE_CODE_PTR)
+ if (bounds_type->code () == TYPE_CODE_PTR)
bounds_type = TYPE_TARGET_TYPE (bounds_type);
- if (TYPE_CODE (bounds_type) != TYPE_CODE_STRUCT)
+ if (bounds_type->code () != TYPE_CODE_STRUCT)
error (_("Unknown task name format. Aborting"));
upper_bound_fieldno = ada_get_field_index (bounds_type, "UB0", 0);
}
/* Read the ATCB data of a given task given its TASK_ID (which is in practice
- the address of its assocated ATCB record), and store the result inside
+ the address of its associated ATCB record), and store the result inside
TASK_INFO. */
static void
msym = lookup_minimal_symbol_by_pc (task_id);
if (msym.minsym)
{
- const char *full_name = MSYMBOL_LINKAGE_NAME (msym.minsym);
+ const char *full_name = msym.minsym->linkage_name ();
const char *task_name = full_name;
const char *p;
task_name = p + 2;
/* Copy the task name. */
- strncpy (task_info->name, task_name, sizeof (task_info->name));
+ strncpy (task_info->name, task_name,
+ sizeof (task_info->name) - 1);
task_info->name[sizeof (task_info->name) - 1] = 0;
}
else
called_task_fieldno));
}
- /* If the ATCB cotnains some information about RV callers, then
+ /* If the ATCB contains some information about RV callers, then
compute the "caller_task". Otherwise, leave it as zero. */
if (pspace_data->atcb_fieldno.call >= 0)
struct type *eltype = NULL;
struct type *idxtype = NULL;
- if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+ if (type->code () == TYPE_CODE_ARRAY)
eltype = check_typedef (TYPE_TARGET_TYPE (type));
if (eltype != NULL
- && TYPE_CODE (eltype) == TYPE_CODE_PTR)
+ && eltype->code () == TYPE_CODE_PTR)
idxtype = check_typedef (TYPE_INDEX_TYPE (type));
if (idxtype != NULL
&& !TYPE_LOW_BOUND_UNDEFINED (idxtype)
/* Validate. */
struct type *type = check_typedef (SYMBOL_TYPE (sym));
- if (TYPE_CODE (type) == TYPE_CODE_PTR)
+ if (type->code () == TYPE_CODE_PTR)
{
data->known_tasks_element = type;
return;
/* 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 (inf, 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. */
/* Finally, print the task name, without quotes around it, as mi like
is not expecting quotes, and in non mi-like no need for quotes
as there is a specific column for the name. */
- uiout->field_string ("name",
- task_info->name[0] != '\0' ? task_info->name
- : _("<no name>"));
+ uiout->field_fmt ("name",
+ (task_info->name[0] != '\0'
+ ? ui_file_style ()
+ : metadata_style.style ()),
+ "%s",
+ (task_info->name[0] != '\0'
+ ? task_info->name
+ : _("<no name>")));
uiout->text ("\n");
}
/* Print the name of the task. */
if (task_info->name[0] != '\0')
- printf_filtered (_("Name: \"%s\"\n"), task_info->name);
+ printf_filtered (_("Name: %s\n"), task_info->name);
else
- printf_filtered (_("<no name>\n"));
+ fprintf_styled (gdb_stdout, metadata_style.style (), _("<no name>\n"));
/* Print the TID and LWP. */
printf_filtered (_("Thread: %#lx\n"), task_info->ptid.tid ());
printf_filtered (_("Parent: %d"), parent_taskno);
if (parent->name[0] != '\0')
- printf_filtered (" (\"%s\")", parent->name);
+ printf_filtered (" (%s)", parent->name);
printf_filtered ("\n");
}
else
ada_task_info *target_task_info = &data->task_list[target_taskno - 1];
if (target_task_info->name[0] != '\0')
- printf_filtered (" (\"%s\")", target_task_info->name);
+ printf_filtered (" (%s)", target_task_info->name);
}
printf_filtered ("\n");
computed if target_get_ada_task_ptid has not been implemented for
our target (yet). Rather than cause an assertion error in that case,
it's nicer for the user to just refuse to perform the task switch. */
- thread_info *tp = find_thread_ptid (task_info->ptid);
+ thread_info *tp = find_thread_ptid (inf, task_info->ptid);
if (tp == NULL)
error (_("Unable to compute thread ID for task %s.\n"
"Cannot switch to this task."),
{
/* All objfiles are being cleared, so we should clear all
our caches for all program spaces. */
- struct program_space *pspace;
-
- for (pspace = program_spaces; pspace != NULL; pspace = pspace->next)
+ for (struct program_space *pspace : program_spaces)
ada_tasks_invalidate_pspace_data (pspace);
}
else
ada_tasks_invalidate_inferior_data (inf);
}
+void _initialize_tasks ();
void
-_initialize_tasks (void)
+_initialize_tasks ()
{
/* Attach various observers. */
gdb::observers::normal_stop.attach (ada_tasks_normal_stop_observer);