aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-tasks.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-10-21 18:46:06 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-10-21 18:46:06 +0000
commit6cda5a20820e95cf01d510f2478cd4b992cf416b (patch)
tree1f86f3e9188b87abc598192682cc9c4d394c1e9f /gdb/ada-tasks.c
parent5ed9db04f86f3eb360956052f6beea3aefd585aa (diff)
downloadgdb-6cda5a20820e95cf01d510f2478cd4b992cf416b.zip
gdb-6cda5a20820e95cf01d510f2478cd4b992cf416b.tar.gz
gdb-6cda5a20820e95cf01d510f2478cd4b992cf416b.tar.bz2
[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 8ab5ad5..5b82561 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);