From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25343 invoked by alias); 4 Mar 2011 06:22:19 -0000 Received: (qmail 25327 invoked by uid 22791); 4 Mar 2011 06:22:18 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,TW_WT,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 Mar 2011 06:22:14 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 15CA92BAF1D; Fri, 4 Mar 2011 01:22:12 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id sLPKjgVA0PRk; Fri, 4 Mar 2011 01:22:12 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 047232BAE61; Fri, 4 Mar 2011 01:22:12 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4233) id EF57192A53; Fri, 4 Mar 2011 01:22:11 -0500 (EST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [VxWorks 02/20] Some ada-lang/ada-tasks routines needed by the VxWorks target Date: Fri, 04 Mar 2011 06:22:00 -0000 Message-Id: <1299219720-13398-3-git-send-email-brobecker@adacore.com> In-Reply-To: <1299219720-13398-1-git-send-email-brobecker@adacore.com> References: <1299219720-13398-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00253.txt.bz2 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 know which task is the environment task (this is the initial/main task). The program dies when this task dies... gdb/ChangeLog: * ada-lang.h (ada_language_auto_set, ada_get_environment_task): Add declarations. * ada-lang.c (ada_language_auto_set): New function. * ada-tasks.c (ada_get_environment_task): New function. --- gdb/ada-lang.c | 14 ++++++++++++++ gdb/ada-lang.h | 4 ++++ gdb/ada-tasks.c | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 0 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d0a1014..52961df 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -740,6 +740,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. */ diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 7902124..9a0e8ed 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -215,6 +215,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 *, @@ -377,6 +379,8 @@ 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); diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 216902a..d132ec7 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -212,6 +212,22 @@ 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. */ -- 1.7.0.4