From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12861 invoked by alias); 6 Feb 2014 20:55:46 -0000 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 Received: (qmail 12764 invoked by uid 89); 6 Feb 2014 20:55:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Feb 2014 20:55:44 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s16KtgJ2019567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Feb 2014 15:55:42 -0500 Received: from barimba.redhat.com (ovpn-113-148.phx2.redhat.com [10.3.113.148]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s16KtfZN013306; Thu, 6 Feb 2014 15:55:42 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC v2 02/38] introduce and use find_target_at Date: Thu, 06 Feb 2014 20:55:00 -0000 Message-Id: <1391720136-2121-3-git-send-email-tromey@redhat.com> In-Reply-To: <1391720136-2121-1-git-send-email-tromey@redhat.com> References: <1391720136-2121-1-git-send-email-tromey@redhat.com> X-SW-Source: 2014-02/txt/msg00137.txt.bz2 RECORD_IS_USED looks at current_target.to_stratum to determine whether a record target is in use. This is bad because arch_stratum is greater than record_stratum. To fix this, this patch adds find_target_at to determine whether a target appears at a given stratum. This may seem like overkill somehow, but I have a subsequent patch series that uses it more heavily. This new function lets us clean up find_record_target a bit as well. 2014-02-06 Tom Tromey * record.c (find_record_target): Use find_target_at. * record.h (RECORD_IS_REPLAY): Use find_target_at. * target.c (find_target_at): New function. * target.h (find_target_at): Declare. --- gdb/ChangeLog | 7 +++++++ gdb/record.c | 8 +------- gdb/target.c | 14 ++++++++++++++ gdb/target.h | 5 +++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/gdb/record.c b/gdb/record.c index 4c67192..41e167f 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -62,13 +62,7 @@ struct cmd_list_element *info_record_cmdlist = NULL; struct target_ops * find_record_target (void) { - struct target_ops *t; - - for (t = current_target.beneath; t != NULL; t = t->beneath) - if (t->to_stratum == record_stratum) - return t; - - return NULL; + return find_target_at (record_stratum); } /* Check that recording is active. Throw an error, if it isn't. */ diff --git a/gdb/target.c b/gdb/target.c index 6723562..c9f004a 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3685,6 +3685,20 @@ find_target_beneath (struct target_ops *t) return t->beneath; } +/* See target.h. */ + +struct target_ops * +find_target_at (enum strata stratum) +{ + struct target_ops *t; + + for (t = current_target.beneath; t != NULL; t = t->beneath) + if (t->to_stratum == stratum) + return t; + + return NULL; +} + /* The inferior process has died. Long live the inferior! */ diff --git a/gdb/target.h b/gdb/target.h index e3479e2..07d0afd 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1955,6 +1955,11 @@ extern void find_default_create_inferior (struct target_ops *, extern struct target_ops *find_target_beneath (struct target_ops *); +/* Find the target at STRATUM. If no target is at that stratum, + return NULL. */ + +struct target_ops *find_target_at (enum strata stratum); + /* Read OS data object of type TYPE from the target, and return it in XML format. The result is NUL-terminated and returned as a string, allocated using xmalloc. If an error occurs or the transfer is -- 1.8.1.4