From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21263 invoked by alias); 7 Feb 2014 15:43:29 -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 21248 invoked by uid 89); 7 Feb 2014 15:43:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 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; Fri, 07 Feb 2014 15:43:28 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s17FhRV2023396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 7 Feb 2014 10:43:27 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s17FhQuc015182; Fri, 7 Feb 2014 10:43:26 -0500 Message-ID: <52F4FF1D.1010302@redhat.com> Date: Fri, 07 Feb 2014 15:43:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Tom Tromey CC: gdb-patches@sourceware.org Subject: Re: [RFC v2 02/38] introduce and use find_target_at References: <1391720136-2121-1-git-send-email-tromey@redhat.com> <1391720136-2121-3-git-send-email-tromey@redhat.com> In-Reply-To: <1391720136-2121-3-git-send-email-tromey@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-02/txt/msg00206.txt.bz2 On 02/06/2014 08:55 PM, Tom Tromey wrote: > 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. This log entry is now stale. The to_stratum issue was fixed meanwhile. (also, this own series makes use of this later on, no need to mention a subsequent series). > > 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 > -- Pedro Alves