public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [vxworks 01/14] Some ada-lang/ada-tasks routines needed by the VxWorks target.
Date: Sun, 25 Apr 2010 15:47:00 -0000	[thread overview]
Message-ID: <1272210447-13895-2-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <1272210447-13895-1-git-send-email-brobecker@adacore.com>

We need to add a few routines in the following units...

  - ada-lang.c:

      After switching to a new partition, if there is an Ada main in there,
      and the language is auto, switch the language to Ada (if not already
      Ada).

  - ada-tasks.c:

      The remote-wtx backend needs to access the list of known Ada
      tasks in order to build the associated list of VxWorks threads
      running as part of an Ada "program".  This is for the multi-tasks
      mode.

2010-04-24  Joel Brobecker  <brobecker@adacore.com>

        * ada-lang.c (ada_language_auto_set, clear_ada_sym_cache):
        New functions.
        * ada-tasks.c (ada_get_environment_task, iterate_over_live_ada_tasks):
        New functions.
        * ada-lang.h (ada_language_auto_set, ada_get_environment_task)
        (ada_task_list_iterator_ftype, iterate_over_live_ada_tasks):
        Add declarations.
---
 gdb/ada-lang.c  |   19 +++++++++++++++++++
 gdb/ada-lang.h  |    8 ++++++++
 gdb/ada-tasks.c |   37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9da0609..5da30f9 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -646,6 +646,20 @@ ada_update_initial_language (enum language lang)
   return lang;
 }
 
+/* If the language mode is auto, and we can find some Ada code
+   in one of the module, then automatically set the language to Ada.  */
+
+void
+ada_language_auto_set (void)
+{
+  if (language_mode == language_mode_auto
+      && ada_update_initial_language (language_unknown) == language_ada)
+    {
+      set_language (language_ada);
+      expected_language = current_language;
+    }
+}
+
 /* If the main procedure is written in Ada, then return its name.
    The result is good until the next call.  Return NULL if the main
    procedure doesn't appear to be in Ada.  */
@@ -3940,6 +3954,11 @@ make_array_descriptor (struct type *type, struct value *arr,
 /* Dummy definitions for an experimental caching module that is not
  * used in the public sources. */
 
+void
+clear_ada_sym_cache (void)
+{
+}
+
 static int
 lookup_cached_symbol (const char *name, domain_enum namespace,
                       struct symbol **sym, struct block **block)
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 3d60f8f..e73e939 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -211,6 +211,8 @@ extern const char *ada_decode (const char*);
 
 extern enum language ada_update_initial_language (enum language);
 
+extern void ada_language_auto_set (void);
+
 extern void clear_ada_sym_cache (void);
 
 extern int ada_lookup_symbol_list (const char *, const struct block *,
@@ -373,8 +375,14 @@ extern char *ada_main_name (void);
 
 extern int valid_task_id (int);
 
+extern struct ada_task_info *ada_get_environment_task (void);
+
 extern int ada_get_task_number (ptid_t);
 
+typedef void (ada_task_list_iterator_ftype) (struct ada_task_info *task);
+extern void iterate_over_live_ada_tasks
+  (ada_task_list_iterator_ftype *iterator);
+
 extern int ada_build_task_list (int warn_if_null);
 
 extern int ada_exception_catchpoint_p (struct breakpoint *b);
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 519cfc6..7f0b1c2 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -212,6 +212,43 @@ ada_task_is_alive (struct ada_task_info *task_info)
   return (task_info->state != Terminated);
 }
 
+/* Return the task info associated to the Environment Task.
+   This function assumes that the inferior does in fact use tasking.  */
+
+struct ada_task_info *
+ada_get_environment_task (void)
+{
+  ada_build_task_list (0);
+  gdb_assert (VEC_length (ada_task_info_s, task_list) > 0);
+
+  /* We use a little bit of insider knowledge to determine which task
+     is the Environment Task:  We know that this task is created first,
+     and thus should always be task #1, which is at index 0 of the
+     TASK_LIST.  */
+  return (VEC_index (ada_task_info_s, task_list, 0));
+}
+
+/* Call the ITERATOR function once for each Ada task that hasn't been
+   terminated yet.  */
+
+void
+iterate_over_live_ada_tasks (ada_task_list_iterator_ftype *iterator)
+{
+  int i, nb_tasks;
+  struct ada_task_info *task;
+
+  ada_build_task_list (0);
+  nb_tasks = VEC_length (ada_task_info_s, task_list);
+
+  for (i = 0; i < nb_tasks; i++)
+    {
+      task = VEC_index (ada_task_info_s, task_list, i);
+      if (!ada_task_is_alive (task))
+        continue;
+      iterator (task);
+    }
+}
+
 /* Extract the contents of the value as a string whose length is LENGTH,
    and store the result in DEST.  */
 
-- 
1.6.3.3

  reply	other threads:[~2010-04-25 15:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-25 15:47 Adding support for " Joel Brobecker
2010-04-25 15:47 ` Joel Brobecker [this message]
2010-04-25 15:48 ` [vxworks 11/14] WTX-TCL support module Joel Brobecker
2010-04-25 15:48 ` [vxworks 13/14] Add tdep files for x86 and powerpc Joel Brobecker
2010-04-25 20:45   ` Mark Kettenis
2010-04-26 16:41     ` Joel Brobecker
2010-04-25 15:48 ` [vxworks 08/14] Partition support Joel Brobecker
2010-04-25 15:48 ` [vxworks 09/14] remote-wtx-hw / register fetch/store support Joel Brobecker
2010-04-25 15:48 ` [vxworks 10/14] Add new "wtx" target Joel Brobecker
2010-04-25 15:48 ` [vxworks 03/14] New module remote-wtx-utils Joel Brobecker
2010-04-26 18:55   ` Tom Tromey
2010-04-27 16:27     ` Joel Brobecker
2010-04-25 15:48 ` [vxworks 14/14] Configury and Makefile updates for VxWorks Joel Brobecker
2010-04-25 15:48 ` [vxworks 02/14] New command_post observer Joel Brobecker
2010-04-26 18:51   ` Tom Tromey
2010-04-27 14:22     ` Joel Brobecker
2010-04-27 17:16       ` Tom Tromey
2010-04-25 15:56 ` [vxworks 12/14] Add support for VxWorks 6 Joel Brobecker
2010-04-25 15:56 ` [vxworks 06/14] VxWorks breakpoint-handling module Joel Brobecker
2010-04-25 15:56 ` [vxworks 05/14] Add options to control Vxworks related settings Joel Brobecker
2010-05-04 15:25   ` Joel Brobecker
2010-04-25 15:56 ` [vxworks 07/14] "multi-tasks-mode" support Joel Brobecker
2010-04-25 16:01 ` [vxworks 04/14] remote-wtxapi: The WTX API abstraction layer Joel Brobecker
2010-05-04 14:58 ` Adding support for VxWorks target Joel Brobecker
2010-05-04 15:43   ` Stan Shebs
2010-05-04 18:30     ` one big unit or several smaller units? (was: "Re: Adding support for VxWorks target") Joel Brobecker
2010-11-25  0:53 ` Adding support for VxWorks target Joel Brobecker

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=1272210447-13895-2-git-send-email-brobecker@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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).