public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Kévin Le Gouguec" <legouguec@adacore.com>
To: gdb-patches@sourceware.org
Cc: simark@simark.ca, "Kévin Le Gouguec" <legouguec@adacore.com>
Subject: [PATCH v2 1/3] gdb: Introduce ada-tasks.h for functions defined in ada-tasks.c
Date: Fri, 27 Jan 2023 17:53:35 +0100	[thread overview]
Message-ID: <20230127165337.1832937-2-legouguec@adacore.com> (raw)
In-Reply-To: <20230127165337.1832937-1-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/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

diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 9fb7ac7f384..e0d44756218 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.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
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index a3a28063daa..bdabc0909cb 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -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,
diff --git a/gdb/ada-tasks.h b/gdb/ada-tasks.h
new file mode 100644
index 00000000000..5a948c27a44
--- /dev/null
+++ b/gdb/ada-tasks.h
@@ -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 */
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 00cc2ab401c..a21f8d5f8ae 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 "valprint.h"
 #include "jit.h"
diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c
index a7e043d847b..6b7b91cd322 100644
--- a/gdb/guile/scm-breakpoint.c
+++ b/gdb/guile/scm-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 "guile-internal.h"
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index e0cade2edc3..73f917f6071 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -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"
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 1b10ccd5415..5189b3af0ad 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 22fbdbe9662..57ac9634233 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.25.1


  reply	other threads:[~2023-01-27 16:54 UTC|newest]

Thread overview: 9+ 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
2023-01-12 18:19 ` Simon Marchi
2023-01-13 12:32   ` Kévin Le Gouguec
2023-01-13 16:29     ` Simon Marchi
2023-01-13 17:16       ` Kévin Le Gouguec
2023-01-27 16:53         ` [PATCH v2 0/3] " Kévin Le Gouguec
2023-01-27 16:53           ` Kévin Le Gouguec [this message]
2023-01-27 16:53           ` [PATCH v2 2/3] gdb/ada-tasks: Make the ada_tasks_pspace_data getter public Kévin Le Gouguec
2023-01-27 16:53           ` [PATCH v2 3/3] gdb: Fix Ada tasking for baremetal targets using 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=20230127165337.1832937-2-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).