Originally, this function had a parameter called `warn_if_null'
which would trigger a message to be printed on stdout if the
program was found to not use Ada tasking. It used one of the printf_
functions for that, which is wrong when considering the context of
GDB/MI interpreters.
So, this patch changes this function to stop printing the message,
and leaves that part to the callers instead. It also changes the
semantics slightly to return the number of tasks found, rather than
a yes/no answer. Not strictly needed, but simple enough to do, and
potentially useful later.
gdb/ChangeLog:
* ada-lang.h (ada_build_task_list): Remove parameter
`warn_if_null'.
* ada-tasks.c (ada_build_task_list): Remove parameter
`warn_if_null'. Adjust implementation and documentation.
(valid_task_id, ada_get_environment_task)
iterate_over_live_ada_tasks): Adjust call to ada_build_task_list.
(info_tasks_command): Adjust implementation.
(task_command): Likewise.
* ravenscar-thread.c (ravenscar_find_new_threads): Fix call
to ada_build_task_list.
2011-09-16 Joel Brobecker <brobecker@adacore.com>
2011-09-16 Joel Brobecker <brobecker@adacore.com>
+ * ada-lang.h (ada_build_task_list): Remove parameter
+ `warn_if_null'.
+ * ada-tasks.c (ada_build_task_list): Remove parameter
+ `warn_if_null'. Adjust implementation and documentation.
+ (valid_task_id, ada_get_environment_task)
+ iterate_over_live_ada_tasks): Adjust call to ada_build_task_list.
+ (info_tasks_command): Adjust implementation.
+ (task_command): Likewise.
+ * ravenscar-thread.c (ravenscar_find_new_threads): Fix call
+ to ada_build_task_list.
+
+2011-09-16 Joel Brobecker <brobecker@adacore.com>
+
* ada-tasks.c (ada_tasks_check_symbol_table, task_list): Delete.
(enum ada_known_tasks_kind, struct ada_tasks_inferior_data): New.
(ada_tasks_inferior_data_handle): New static global.
* ada-tasks.c (ada_tasks_check_symbol_table, task_list): Delete.
(enum ada_known_tasks_kind, struct ada_tasks_inferior_data): New.
(ada_tasks_inferior_data_handle): New static global.
extern void iterate_over_live_ada_tasks
(ada_task_list_iterator_ftype *iterator);
extern void iterate_over_live_ada_tasks
(ada_task_list_iterator_ftype *iterator);
-extern int ada_build_task_list (int warn_if_null);
+extern int ada_build_task_list (void);
{
struct ada_tasks_inferior_data *data;
{
struct ada_tasks_inferior_data *data;
- ada_build_task_list (0);
+ ada_build_task_list ();
data = get_ada_tasks_inferior_data (current_inferior ());
return (task_num > 0
&& task_num <= VEC_length (ada_task_info_s, data->task_list));
data = get_ada_tasks_inferior_data (current_inferior ());
return (task_num > 0
&& task_num <= VEC_length (ada_task_info_s, data->task_list));
struct ada_task_info *task;
struct ada_tasks_inferior_data *data;
struct ada_task_info *task;
struct ada_tasks_inferior_data *data;
- ada_build_task_list (0);
+ ada_build_task_list ();
data = get_ada_tasks_inferior_data (current_inferior ());
nb_tasks = VEC_length (ada_task_info_s, data->task_list);
data = get_ada_tasks_inferior_data (current_inferior ());
nb_tasks = VEC_length (ada_task_info_s, data->task_list);
-/* Builds the task_list by reading the Known_Tasks array from
- the inferior. Prints an appropriate message and returns non-zero
- if it failed to build this list. */
+/* Build the task_list by reading the Known_Tasks array from
+ the inferior, and return the number of tasks in that list
+ (zero means that the program is not using tasking at all). */
-ada_build_task_list (int warn_if_null)
+ada_build_task_list (void)
{
struct ada_tasks_inferior_data *data;
{
struct ada_tasks_inferior_data *data;
if (!data->task_list_valid_p)
read_known_tasks ();
if (!data->task_list_valid_p)
read_known_tasks ();
- if (data->task_list == NULL)
- {
- if (warn_if_null)
- printf_filtered (_("Your application does not use any Ada tasks.\n"));
- return 0;
- }
-
- return 1;
+ return VEC_length (ada_task_info_s, data->task_list);
}
/* Print a one-line description of the task running in inferior INF
}
/* Print a one-line description of the task running in inferior INF
static void
info_tasks_command (char *arg, int from_tty)
{
static void
info_tasks_command (char *arg, int from_tty)
{
- const int task_list_built = ada_build_task_list (1);
+ struct ui_out *uiout = current_uiout;
- if (!task_list_built)
- return;
+ if (ada_build_task_list () == 0)
+ {
+ ui_out_message (uiout, 0,
+ _("Your application does not use any Ada tasks.\n"));
+ return;
+ }
if (arg == NULL || *arg == '\0')
info_tasks (from_tty, current_inferior ());
if (arg == NULL || *arg == '\0')
info_tasks (from_tty, current_inferior ());
static void
task_command (char *taskno_str, int from_tty)
{
static void
task_command (char *taskno_str, int from_tty)
{
- const int task_list_built = ada_build_task_list (1);
+ struct ui_out *uiout = current_uiout;
- if (!task_list_built)
- return;
+ if (ada_build_task_list () == 0)
+ {
+ ui_out_message (uiout, 0,
+ _("Your application does not use any Ada tasks.\n"));
+ return;
+ }
if (taskno_str == NULL || taskno_str[0] == '\0')
display_current_task_id ();
if (taskno_str == NULL || taskno_str[0] == '\0')
display_current_task_id ();
static void
ravenscar_find_new_threads (struct target_ops *ops)
{
static void
ravenscar_find_new_threads (struct target_ops *ops)
{
- ada_build_task_list (0);
+ ada_build_task_list ();
/* Do not clear the thread list before adding the Ada task, to keep
the thread that the process stratum has included into it
/* Do not clear the thread list before adding the Ada task, to keep
the thread that the process stratum has included into it