From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31333 invoked by alias); 13 Jan 2014 19:12:58 -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 31257 invoked by uid 89); 13 Jan 2014 19:12:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 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; Mon, 13 Jan 2014 19:12:55 +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 s0DJCraH007056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Jan 2014 14:12:53 -0500 Received: from barimba.redhat.com (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0DJCpt8016701; Mon, 13 Jan 2014 14:12:53 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 02/32] introduce and use find_target_at Date: Mon, 13 Jan 2014 19:12:00 -0000 Message-Id: <1389640367-5571-3-git-send-email-tromey@redhat.com> In-Reply-To: <1389640367-5571-1-git-send-email-tromey@redhat.com> References: <1389640367-5571-1-git-send-email-tromey@redhat.com> X-SW-Source: 2014-01/txt/msg00332.txt.bz2 RECORD_IS_USED and find_record_target look 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. 2014-01-08 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/record.h | 2 +- gdb/target.c | 14 ++++++++++++++ gdb/target.h | 5 +++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/gdb/record.c b/gdb/record.c index ec2a042..0fd8756 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -62,13 +62,7 @@ struct cmd_list_element *info_record_cmdlist = NULL; static 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/record.h b/gdb/record.h index 124c32b..05a17a9 100644 --- a/gdb/record.h +++ b/gdb/record.h @@ -22,7 +22,7 @@ struct cmd_list_element; -#define RECORD_IS_USED (current_target.to_stratum == record_stratum) +#define RECORD_IS_USED (find_target_at (record_stratum) != NULL) extern unsigned int record_debug; diff --git a/gdb/target.c b/gdb/target.c index 092d50c..d2a40ee 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3648,6 +3648,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 e00e38c..b219cff 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1903,6 +1903,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