aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-tasks.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-02-15 14:05:38 -0700
committerTom Tromey <tromey@adacore.com>2019-02-19 12:26:37 -0700
commit98814c6c111a0681e691a72834c8dcc5b8d1bb3a (patch)
tree569c709c9438d99160649efbe94acd546877a4d6 /gdb/ada-tasks.c
parent6f2117ba3892110badc65a7126b19cec211acfa2 (diff)
downloadgdb-98814c6c111a0681e691a72834c8dcc5b8d1bb3a.zip
gdb-98814c6c111a0681e691a72834c8dcc5b8d1bb3a.tar.gz
gdb-98814c6c111a0681e691a72834c8dcc5b8d1bb3a.tar.bz2
Minor Ada task cleanups
While working on the Ada task code, I noticed a few things that could be cleaned up: * task_list_valid_p was not set in all cases in ada_build_task_list. This causes many needless re-fetches of the task list. * task_list_valid_p can be bool, and various functions can also return bool. * Nothing checks the return value of read_known_tasks, so it can be changed to return void. * The call to ada_build_task_list in ravenscar_thread_target::update_thread_list is redundant, because this is the first thing done by iterate_over_live_ada_tasks. Tested using the internal AdaCore test suite against a ravenscar target. gdb/ChangeLog 2019-02-19 Tom Tromey <tromey@adacore.com> * ravenscar-thread.c (ravenscar_thread_target::update_thread_list): Don't call ada_build_task_list. * ada-lang.h (ada_build_task_list): Don't declare. * ada-tasks.c (struct ada_tasks_inferior_data) <task_list_valid_p>: Now bool. (read_known_tasks, ada_task_list_changed) (ada_tasks_invalidate_inferior_data): Update. (read_known_tasks_array): Return bool. (read_known_tasks_list): Likewise. (read_known_tasks): Return void. (ada_build_task_list): Now static.
Diffstat (limited to 'gdb/ada-tasks.c')
-rw-r--r--gdb/ada-tasks.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 440e32b..ccabc631 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -26,6 +26,8 @@
#include "progspace.h"
#include "objfiles.h"
+static int ada_build_task_list ();
+
/* The name of the array in the GNAT runtime where the Ada Task Control
Block of each task is stored. */
#define KNOWN_TASKS_NAME "system__tasking__debug__known_tasks"
@@ -230,7 +232,7 @@ struct ada_tasks_inferior_data
/* When nonzero, this flag indicates that the task_list field
below is up to date. When set to zero, the list has either
not been initialized, or has potentially become stale. */
- int task_list_valid_p = 0;
+ bool task_list_valid_p = false;
/* The list of Ada tasks.
@@ -803,9 +805,9 @@ add_ada_task (CORE_ADDR task_id, struct inferior *inf)
}
/* Read the Known_Tasks array from the inferior memory, and store
- it in the current inferior's TASK_LIST. Return non-zero upon success. */
+ it in the current inferior's TASK_LIST. Return true upon success. */
-static int
+static bool
read_known_tasks_array (struct ada_tasks_inferior_data *data)
{
const int target_ptr_byte = TYPE_LENGTH (data->known_tasks_element);
@@ -826,13 +828,13 @@ read_known_tasks_array (struct ada_tasks_inferior_data *data)
add_ada_task (task_id, current_inferior ());
}
- return 1;
+ return true;
}
/* Read the known tasks from the inferior memory, and store it in
- the current inferior's TASK_LIST. Return non-zero upon success. */
+ the current inferior's TASK_LIST. Return true upon success. */
-static int
+static bool
read_known_tasks_list (struct ada_tasks_inferior_data *data)
{
const int target_ptr_byte = TYPE_LENGTH (data->known_tasks_element);
@@ -843,7 +845,7 @@ read_known_tasks_list (struct ada_tasks_inferior_data *data)
/* Sanity check. */
if (pspace_data->atcb_fieldno.activation_link < 0)
- return 0;
+ return false;
/* Build a new list by reading the ATCBs. Read head of the list. */
read_memory (data->known_tasks_addr, known_tasks, target_ptr_byte);
@@ -864,7 +866,7 @@ read_known_tasks_list (struct ada_tasks_inferior_data *data)
pspace_data->atcb_fieldno.activation_link));
}
- return 1;
+ return true;
}
/* Set all fields of the current inferior ada-tasks data pointed by DATA.
@@ -962,11 +964,10 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
}
/* Read the known tasks from the current inferior's memory, and store it
- in the current inferior's data TASK_LIST.
- Return non-zero upon success. */
+ in the current inferior's data TASK_LIST. */
-static int
-read_known_tasks (void)
+static void
+read_known_tasks ()
{
struct ada_tasks_inferior_data *data =
get_ada_tasks_inferior_data (current_inferior ());
@@ -983,29 +984,27 @@ read_known_tasks (void)
ada_tasks_inferior_data_sniffer (data);
gdb_assert (data->known_tasks_kind != ADA_TASKS_UNKNOWN);
+ /* Step 3: Set task_list_valid_p, to avoid re-reading the Known_Tasks
+ array unless needed. */
switch (data->known_tasks_kind)
{
- case ADA_TASKS_NOT_FOUND: /* Tasking not in use in inferior. */
- return 0;
- case ADA_TASKS_ARRAY:
- return read_known_tasks_array (data);
- case ADA_TASKS_LIST:
- return read_known_tasks_list (data);
+ case ADA_TASKS_NOT_FOUND: /* Tasking not in use in inferior. */
+ break;
+ case ADA_TASKS_ARRAY:
+ data->task_list_valid_p = read_known_tasks_array (data);
+ break;
+ case ADA_TASKS_LIST:
+ data->task_list_valid_p = read_known_tasks_list (data);
+ break;
}
-
- /* Step 3: Set task_list_valid_p, to avoid re-reading the Known_Tasks
- array unless needed. Then report a success. */
- data->task_list_valid_p = 1;
-
- return 1;
}
/* 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). */
-int
-ada_build_task_list (void)
+static int
+ada_build_task_list ()
{
struct ada_tasks_inferior_data *data;
@@ -1361,7 +1360,7 @@ ada_task_list_changed (struct inferior *inf)
{
struct ada_tasks_inferior_data *data = get_ada_tasks_inferior_data (inf);
- data->task_list_valid_p = 0;
+ data->task_list_valid_p = false;
}
/* Invalidate the per-program-space data. */
@@ -1380,7 +1379,7 @@ ada_tasks_invalidate_inferior_data (struct inferior *inf)
struct ada_tasks_inferior_data *data = get_ada_tasks_inferior_data (inf);
data->known_tasks_kind = ADA_TASKS_UNKNOWN;
- data->task_list_valid_p = 0;
+ data->task_list_valid_p = false;
}
/* The 'normal_stop' observer notification callback. */