Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Kévin Le Gouguec" <legouguec@adacore.com>
To: gdb-patches@sourceware.org
Cc: "Kévin Le Gouguec" <legouguec@adacore.com>,
	"Simon Marchi" <simark@simark.ca>
Subject: [PATCH v4 1/2] gdb: Introduce ada-tasks.h for functions defined in ada-tasks.c
Date: Fri, 13 Nov 2026 17:40:38 +0100	[thread overview]
Message-ID: <747b666d5ed99d79a84f54b04d087fc56de70d41.1794585020.git.legouguec@adacore.com> (raw)
In-Reply-To: <cover.1794585020.git.legouguec@adacore.com>

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/Makefile.in            |  1 +
 gdb/ada-lang.h             | 19 -----------
 gdb/ada-tasks.c            | 26 ++++-----------
 gdb/ada-tasks.h            | 68 ++++++++++++++++++++++++++++++++++++++
 gdb/break-cond-parse.c     |  2 +-
 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 +
 10 files changed, 82 insertions(+), 42 deletions(-)
 create mode 100644 gdb/ada-tasks.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 41dbb814787..d7964e67cab 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1285,6 +1285,7 @@ HFILES_NO_SRCDIR = \
 	ada-exp-parser.h \
 	ada-exp.h \
 	ada-lang.h \
+	ada-tasks.h \
 	addrmap.h \
 	alpha-bsd-tdep.h \
 	alpha-tdep.h \
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index cf89a90f2f5..96043b96b92 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -362,25 +362,6 @@ struct ada_exc_info
 
 extern std::vector<ada_exc_info> ada_exceptions_list (const char *regexp);
 
-/* Tasking-related: ada-tasks.c */
-
-extern bool 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);
-
-using ada_task_list_iterator_ftype
-  = gdb::function_view<void (struct ada_task_info *task)>;
-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
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 7dfa819a937..503563de42a 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -20,6 +20,7 @@
 #include "cli/cli-cmds.h"
 #include "target.h"
 #include "ada-lang.h"
+#include "ada-tasks.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "gdbthread.h"
@@ -317,8 +318,7 @@ get_ada_tasks_inferior_data (struct inferior *inf)
   return &ada_tasks_inferior_data_handle.try_emplace (inf);
 }
 
-/* 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)
@@ -354,7 +354,7 @@ get_task_number_from_id (CORE_ADDR task_id, struct inferior *inf)
   return 0;
 }
 
-/* Return true if TASK_NUM is a valid task number.  */
+/* See ada-tasks.h.  */
 
 bool
 valid_task_id (int task_num)
@@ -375,8 +375,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)
@@ -395,8 +394,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)
@@ -480,14 +478,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)
@@ -1036,10 +1027,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,
diff --git a/gdb/ada-tasks.h b/gdb/ada-tasks.h
new file mode 100644
index 00000000000..66870ac323f
--- /dev/null
+++ b/gdb/ada-tasks.h
@@ -0,0 +1,68 @@
+/* Helper routines for Ada tasking support in GBD.
+
+   Copyright (C) 2026 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 GDB_ADA_TASKS_H
+#define GDB_ADA_TASKS_H
+
+/* Return true if TASK_NUM is a valid task number.  */
+
+extern bool 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);
+
+struct thread_info;
+
+/* 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);
+
+using ada_task_list_iterator_ftype
+  = gdb::function_view<void (struct ada_task_info *task)>;
+
+/* 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 ();
+
+/* 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 /* GDB_ADA_TASKS_H */
diff --git a/gdb/break-cond-parse.c b/gdb/break-cond-parse.c
index f552c171c05..fa532f21669 100644
--- a/gdb/break-cond-parse.c
+++ b/gdb/break-cond-parse.c
@@ -21,7 +21,7 @@
 #include "scoped-mock-context.h"
 #include "break-cond-parse.h"
 #include "tid-parse.h"
-#include "ada-lang.h"
+#include "ada-tasks.h"
 
 /* When parsing tokens from a string, which direction are we parsing?
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index a23f5998b20..6e993f332b4 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -52,6 +52,7 @@
 #include "observable.h"
 #include "memattr.h"
 #include "ada-lang.h"
+#include "ada-tasks.h"
 #include "top.h"
 #include "ui.h"
 #include "valprint.h"
diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c
index 5df2c00f5d3..911e13448a2 100644
--- a/gdb/guile/scm-breakpoint.c
+++ b/gdb/guile/scm-breakpoint.c
@@ -26,7 +26,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"
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 42f5dcc3ded..f4bca4048d5 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -44,7 +44,7 @@
 #include "valprint.h"
 #include "osdata.h"
 #include "tracepoint.h"
-#include "ada-lang.h"
+#include "ada-tasks.h"
 #include "linespec.h"
 #include "extension.h"
 #include "cli/cli-cmds.h"
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index ee7276f1792..2a539513502 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -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"
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index b5e0979a7f1..bb3d7f9e847 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -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"
-- 
2.43.0


  reply	other threads:[~2026-11-13 16:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 17:10 [PATCH] Fix Ada tasking for baremetal targets using Ravenscar threads Kévin Le Gouguec via Gdb-patches
2023-01-12 18:19 ` Simon Marchi via Gdb-patches
2023-01-13 12:32   ` Kévin Le Gouguec via Gdb-patches
2023-01-13 16:29     ` Simon Marchi via Gdb-patches
2023-01-13 17:16       ` Kévin Le Gouguec via Gdb-patches
2023-01-27 16:53         ` [PATCH v2 0/3] " Kévin Le Gouguec via Gdb-patches
2023-01-27 16:53           ` [PATCH v2 1/3] gdb: Introduce ada-tasks.h for functions defined in ada-tasks.c Kévin Le Gouguec via Gdb-patches
2023-01-27 16:53           ` [PATCH v2 2/3] gdb/ada-tasks: Make the ada_tasks_pspace_data getter public Kévin Le Gouguec via Gdb-patches
2023-01-27 16:53           ` [PATCH v2 3/3] gdb: Fix Ada tasking for baremetal targets using Ravenscar threads Kévin Le Gouguec via Gdb-patches
2026-11-06 16:51           ` [PATCH v3 0/2] " Kévin Le Gouguec
2026-11-06 16:51             ` [PATCH v3 1/2] gdb: Introduce ada-tasks.h for functions defined in ada-tasks.c Kévin Le Gouguec
2026-11-06 19:43               ` Simon Marchi
2026-11-09  9:14                 ` Kévin Le Gouguec
2026-11-09 15:02                   ` Simon Marchi
2026-11-09 17:07                     ` Kévin Le Gouguec
2026-11-06 16:51             ` [PATCH v3 2/2] gdb: Fix CPU ID offset for Ravenscar Threads Kévin Le Gouguec
2026-11-13 16:40             ` [PATCH v4 0/2] Fix Ada tasking for baremetal targets using Ravenscar threads Kévin Le Gouguec
2026-11-13 16:40               ` Kévin Le Gouguec [this message]
2026-11-13 16:40               ` [PATCH v4 2/2] gdb: Fix CPU ID offset for Ravenscar Threads Kévin Le Gouguec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=747b666d5ed99d79a84f54b04d087fc56de70d41.1794585020.git.legouguec@adacore.com \
    --to=legouguec@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox