Also move the documentation for these functions to the new header, instead
of at the top of their definition, to align with our current practice.
I tried to honor our guideline that .c files should not rely on indirect
inclusion, hence I only removed #include "ada-lang.h" directives in .c files
that, as far as I could tell, only rely on symbols declared in ada-tasks.h.
---
gdb/ada-lang.h | 19 ----------
gdb/ada-tasks.c | 26 ++++----------
gdb/ada-tasks.h | 72 ++++++++++++++++++++++++++++++++++++++
gdb/breakpoint.c | 1 +
gdb/guile/scm-breakpoint.c | 2 +-
gdb/mi/mi-main.c | 2 +-
gdb/python/py-breakpoint.c | 2 +-
gdb/ravenscar-thread.c | 1 +
8 files changed, 84 insertions(+), 41 deletions(-)
create mode 100644 gdb/ada-tasks.h
@@ -366,25 +366,6 @@ struct ada_exc_info
extern std::vector<ada_exc_info> ada_exceptions_list (const char *regexp);
-/* Tasking-related: ada-tasks.c */
-
-extern int valid_task_id (int);
-
-extern struct ada_task_info *ada_get_task_info_from_ptid (ptid_t ptid);
-
-extern int ada_get_task_number (thread_info *thread);
-
-typedef gdb::function_view<void (struct ada_task_info *task)>
- ada_task_list_iterator_ftype;
-extern void iterate_over_live_ada_tasks
- (ada_task_list_iterator_ftype iterator);
-
-extern const char *ada_get_tcb_types_info (void);
-
-extern void print_ada_task_info (struct ui_out *uiout,
- const char *taskno_str,
- struct inferior *inf);
-
/* Look for a symbol for an overloaded operator for the operation OP.
PARSE_COMPLETION is true if currently parsing for completion.
NARGS and ARGVEC describe the arguments to the call. Returns a
@@ -16,6 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "ada-tasks.h"
#include "observable.h"
#include "gdbcmd.h"
#include "target.h"
@@ -327,8 +328,7 @@ get_ada_tasks_inferior_data (struct inferior *inf)
return data;
}
-/* Return the task number of the task whose thread is THREAD, or zero
- if the task could not be found. */
+/* See ada-tasks.h. */
int
ada_get_task_number (thread_info *thread)
@@ -364,7 +364,7 @@ get_task_number_from_id (CORE_ADDR task_id, struct inferior *inf)
return 0;
}
-/* Return non-zero if TASK_NUM is a valid task number. */
+/* See ada-tasks.h. */
int
valid_task_id (int task_num)
@@ -385,8 +385,7 @@ ada_task_is_alive (const struct ada_task_info *task_info)
return (task_info->state != Terminated);
}
-/* Search through the list of known tasks for the one whose ptid is
- PTID, and return it. Return NULL if the task was not found. */
+/* See ada-tasks.h. */
struct ada_task_info *
ada_get_task_info_from_ptid (ptid_t ptid)
@@ -405,8 +404,7 @@ ada_get_task_info_from_ptid (ptid_t ptid)
return NULL;
}
-/* Call the ITERATOR function once for each Ada task that hasn't been
- terminated yet. */
+/* See ada-tasks.h. */
void
iterate_over_live_ada_tasks (ada_task_list_iterator_ftype iterator)
@@ -490,14 +488,7 @@ read_fat_string_value (char *dest, struct value *val, int max_len)
dest[len] = '\0';
}
-/* Get, from the debugging information, the type description of all types
- related to the Ada Task Control Block that are needed in order to
- read the list of known tasks in the Ada runtime. If all of the info
- needed to do so is found, then save that info in the module's per-
- program-space data, and return NULL. Otherwise, if any information
- cannot be found, leave the per-program-space data untouched, and
- return an error message explaining what was missing (that error
- message does NOT need to be deallocated). */
+/* See ada-tasks.h. */
const char *
ada_get_tcb_types_info (void)
@@ -1056,10 +1047,7 @@ ada_build_task_list ()
return data->task_list.size ();
}
-/* Print a table providing a short description of all Ada tasks
- running inside inferior INF. If ARG_STR is set, it will be
- interpreted as a task number, and the table will be limited to
- that task only. */
+/* See ada-tasks.h. */
void
print_ada_task_info (struct ui_out *uiout,
new file mode 100644
@@ -0,0 +1,72 @@
+/* Helper routines for Ada tasking support in GBD.
+
+ Copyright (C) 2023 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef ADA_TASKS_H
+#define ADA_TASKS_H
+
+#include "gdbsupport/function-view.h"
+#include "ada-lang.h"
+#include "gdbthread.h"
+#include "inferior.h"
+#include "ui-out.h"
+
+/* Return non-zero if TASK_NUM is a valid task number. */
+
+extern int valid_task_id (int task_num);
+
+/* Search through the list of known tasks for the one whose ptid is
+ PTID, and return it. Return NULL if the task was not found. */
+
+extern struct ada_task_info *ada_get_task_info_from_ptid (ptid_t ptid);
+
+/* Return the task number of the task whose thread is THREAD, or zero
+ if the task could not be found. */
+
+extern int ada_get_task_number (thread_info *thread);
+
+typedef gdb::function_view<void (struct ada_task_info *task)>
+ ada_task_list_iterator_ftype;
+
+/* Call the ITERATOR function once for each Ada task that hasn't been
+ terminated yet. */
+
+extern void iterate_over_live_ada_tasks
+ (ada_task_list_iterator_ftype iterator);
+
+/* Get, from the debugging information, the type description of all types
+ related to the Ada Task Control Block that are needed in order to
+ read the list of known tasks in the Ada runtime. If all of the info
+ needed to do so is found, then save that info in the module's per-
+ program-space data, and return NULL. Otherwise, if any information
+ cannot be found, leave the per-program-space data untouched, and
+ return an error message explaining what was missing (that error
+ message does NOT need to be deallocated). */
+
+extern const char *ada_get_tcb_types_info (void);
+
+/* Print a table providing a short description of all Ada tasks
+ running inside inferior INF. If ARG_STR is set, it will be
+ interpreted as a task number, and the table will be limited to
+ that task only. */
+
+extern void print_ada_task_info (struct ui_out *uiout,
+ const char *taskno_str,
+ struct inferior *inf);
+
+#endif /* ADA_TASKS_H */
@@ -52,6 +52,7 @@
#include "observable.h"
#include "memattr.h"
#include "ada-lang.h"
+#include "ada-tasks.h"
#include "top.h"
#include "valprint.h"
#include "jit.h"
@@ -27,7 +27,7 @@
#include "gdbthread.h"
#include "observable.h"
#include "cli/cli-script.h"
-#include "ada-lang.h"
+#include "ada-tasks.h"
#include "arch-utils.h"
#include "language.h"
#include "guile-internal.h"
@@ -46,7 +46,7 @@
#include "osdata.h"
#include "gdbsupport/gdb_splay_tree.h"
#include "tracepoint.h"
-#include "ada-lang.h"
+#include "ada-tasks.h"
#include "linespec.h"
#include "extension.h"
#include "gdbcmd.h"
@@ -27,7 +27,7 @@
#include "gdbthread.h"
#include "observable.h"
#include "cli/cli-script.h"
-#include "ada-lang.h"
+#include "ada-tasks.h"
#include "arch-utils.h"
#include "language.h"
#include "location.h"
@@ -21,6 +21,7 @@
#include "gdbcore.h"
#include "gdbthread.h"
#include "ada-lang.h"
+#include "ada-tasks.h"
#include "target.h"
#include "inferior.h"
#include "command.h"