From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15440 invoked by alias); 23 Sep 2010 18:43:20 -0000 Received: (qmail 15339 invoked by uid 22791); 23 Sep 2010 18:43:19 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,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; Thu, 23 Sep 2010 18:43:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 00BF42BAC55; Thu, 23 Sep 2010 14:43:11 -0400 (EDT) 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 zOFs-TJmsBNV; Thu, 23 Sep 2010 14:43:11 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id BEAD22BAB99; Thu, 23 Sep 2010 14:43:11 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 902E8F591F; Thu, 23 Sep 2010 11:43:08 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [PATCH 1/2] [Ada] Add ada-tasks.c:iterate_over_live_ada_tasks Date: Thu, 23 Sep 2010 19:44:00 -0000 Message-Id: <1285267380-8329-2-git-send-email-brobecker@adacore.com> In-Reply-To: <1285267380-8329-1-git-send-email-brobecker@adacore.com> References: <1285267380-8329-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: 2010-09/txt/msg00412.txt.bz2 This new function is needed by the ravenscar-thread layer. gdb/ChangeLog: * ada-tasks.c (iterate_over_live_ada_tasks): New function. * ada-lang.h (iterate_over_live_ada_tasks): Declare. --- gdb/ada-lang.h | 4 ++++ gdb/ada-tasks.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index d1e8ca5..935c2e1 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -378,6 +378,10 @@ extern int valid_task_id (int); 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 8e42252..3cbcc4f 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -212,6 +212,27 @@ ada_task_is_alive (struct ada_task_info *task_info) return (task_info->state != Terminated); } +/* 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.7.1