summaryrefslogtreecommitdiff
path: root/gdb/ada-tasks.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-10-21 18:46:02 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-10-21 18:46:02 +0000
commitd40664ba46a124548fc96502e5c76231b1fc0301 (patch)
tree87da51160924ce2acfa9790efd706b473b5d6580 /gdb/ada-tasks.c
parent4e3a2e7e7f480a6dc9a1b2abbc2bdafe19d0a1d2 (diff)
downloadgdb-d40664ba46a124548fc96502e5c76231b1fc0301.tar.gz
[Ada] Fix number of lines in -ada-task-info output
When using the new -ada-task-info command with an argument, the output would say that there are N entries in the returned table, (where N is the total number of tasks present in the inferior). But, in fact, the table would only contain at most 1 entry. This patch fixes this by properly computing the number of tasks being displayed before giving it to the uiout. gdb/ChangeLog: * ada-tasks.c (print_ada_task_info): Fix computation of number of tasks displayed in command output. gdb/testsuite/ChangeLog: * gdb.ada/mi_task_info/task_switch.adb: New file. * gdb.ada/mi_task_info.exp: New file.
Diffstat (limited to 'gdb/ada-tasks.c')
-rw-r--r--gdb/ada-tasks.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 8ab5ad5aa63..5b825617ad8 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -984,7 +984,21 @@ print_ada_task_info (struct ui_out *uiout,
target_find_new_threads ();
data = get_ada_tasks_inferior_data (inf);
- nb_tasks = VEC_length (ada_task_info_s, data->task_list);
+
+ /* Compute the number of tasks that are going to be displayed
+ in the output. If an argument was given, there will be
+ at most 1 entry. Otherwise, there will be as many entries
+ as we have tasks. */
+ if (taskno_arg)
+ {
+ if (taskno_arg > 0
+ && taskno_arg <= VEC_length (ada_task_info_s, data->task_list))
+ nb_tasks = 1;
+ else
+ nb_tasks = 0;
+ }
+ else
+ nb_tasks = VEC_length (ada_task_info_s, data->task_list);
nb_columns = ui_out_is_mi_like_p (uiout) ? 8 : 7;
old_chain = make_cleanup_ui_out_table_begin_end (uiout, nb_columns,
@@ -1006,7 +1020,9 @@ print_ada_task_info (struct ui_out *uiout,
ui_out_table_header (uiout, 1, ui_noalign, "name", "Name");
ui_out_table_body (uiout);
- for (taskno = 1; taskno <= nb_tasks; taskno++)
+ for (taskno = 1;
+ taskno <= VEC_length (ada_task_info_s, data->task_list);
+ taskno++)
{
const struct ada_task_info *const task_info =
VEC_index (ada_task_info_s, data->task_list, taskno - 1);