From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 879 invoked by alias); 7 Feb 2014 16:02:49 -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 861 invoked by uid 89); 7 Feb 2014 16:02:48 -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 16:02:47 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s17G2kAJ012343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 7 Feb 2014 11:02:46 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s17G2iTR008125; Fri, 7 Feb 2014 11:02:45 -0500 Message-ID: <52F503A4.9010102@redhat.com> Date: Fri, 07 Feb 2014 16:02: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 38/38] convert to_get_unwinder and to_get_tailcall_unwinder to methods References: <1391720136-2121-1-git-send-email-tromey@redhat.com> <1391720136-2121-39-git-send-email-tromey@redhat.com> In-Reply-To: <1391720136-2121-39-git-send-email-tromey@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-02/txt/msg00210.txt.bz2 Looks fine. On 02/06/2014 08:55 PM, Tom Tromey wrote: > This converts to_get_unwinder and to_get_tailcall_unwinder to methods > and arranges for them to use the new delegation scheme. > > This just lets us avoid having a differing style (neither new-style > nor INHERIT) of delegation in the tree. > > 2014-02-06 Tom Tromey > > * target.c (target_get_unwinder): Rewrite. > (target_get_tailcall_unwinder): Rewrite. > * record-btrace.c (record_btrace_to_get_unwinder): New function. > (record_btrace_to_get_tailcall_unwinder): New function. > (init_record_btrace_ops): Update. > * target.h (struct target_ops) to_get_tailcall_unwinder>: Now function pointers. Use > TARGET_DEFAULT_RETURN. > --- > gdb/ChangeLog | 11 +++++++++++ > gdb/record-btrace.c | 20 ++++++++++++++++++-- > gdb/target-delegates.c | 32 ++++++++++++++++++++++++++++++++ > gdb/target.c | 16 ++-------------- > gdb/target.h | 12 ++++++++---- > 5 files changed, 71 insertions(+), 20 deletions(-) > > diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c > index c4872eb..ab288ef 100644 > --- a/gdb/record-btrace.c > +++ b/gdb/record-btrace.c > @@ -1302,6 +1302,22 @@ const struct frame_unwind record_btrace_tailcall_frame_unwind = > record_btrace_frame_dealloc_cache > }; > > +/* Implement the to_get_unwinder method. */ > + > +static const struct frame_unwind * > +record_btrace_to_get_unwinder (struct target_ops *self) > +{ > + return &record_btrace_frame_unwind; > +} > + > +/* Implement the to_get_tailcall_unwinder method. */ > + > +static const struct frame_unwind * > +record_btrace_to_get_tailcall_unwinder (struct target_ops *self) > +{ > + return &record_btrace_tailcall_frame_unwind; > +} > + > /* Indicate that TP should be resumed according to FLAG. */ > > static void > @@ -1888,8 +1904,8 @@ init_record_btrace_ops (void) > ops->to_fetch_registers = record_btrace_fetch_registers; > ops->to_store_registers = record_btrace_store_registers; > ops->to_prepare_to_store = record_btrace_prepare_to_store; > - ops->to_get_unwinder = &record_btrace_frame_unwind; > - ops->to_get_tailcall_unwinder = &record_btrace_tailcall_frame_unwind; > + ops->to_get_unwinder = &record_btrace_to_get_unwinder; > + ops->to_get_tailcall_unwinder = &record_btrace_to_get_tailcall_unwinder; > ops->to_resume = record_btrace_resume; > ops->to_wait = record_btrace_wait; > ops->to_find_new_threads = record_btrace_find_new_threads; > diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c > index d9c68cd..03b0d2a 100644 > --- a/gdb/target-delegates.c > +++ b/gdb/target-delegates.c > @@ -1572,6 +1572,32 @@ tdefault_augmented_libraries_svr4_read (struct target_ops *self) > return 0; > } > > +static const struct frame_unwind * > +delegate_get_unwinder (struct target_ops *self) > +{ > + self = self->beneath; > + return self->to_get_unwinder (self); > +} > + > +static const struct frame_unwind * > +tdefault_get_unwinder (struct target_ops *self) > +{ > + return NULL; > +} > + > +static const struct frame_unwind * > +delegate_get_tailcall_unwinder (struct target_ops *self) > +{ > + self = self->beneath; > + return self->to_get_tailcall_unwinder (self); > +} > + > +static const struct frame_unwind * > +tdefault_get_tailcall_unwinder (struct target_ops *self) > +{ > + return NULL; > +} > + > static CORE_ADDR > delegate_decr_pc_after_break (struct target_ops *self, struct gdbarch *arg1) > { > @@ -1844,6 +1870,10 @@ install_delegators (struct target_ops *ops) > ops->to_call_history_range = delegate_call_history_range; > if (ops->to_augmented_libraries_svr4_read == NULL) > ops->to_augmented_libraries_svr4_read = delegate_augmented_libraries_svr4_read; > + if (ops->to_get_unwinder == NULL) > + ops->to_get_unwinder = delegate_get_unwinder; > + if (ops->to_get_tailcall_unwinder == NULL) > + ops->to_get_tailcall_unwinder = delegate_get_tailcall_unwinder; > if (ops->to_decr_pc_after_break == NULL) > ops->to_decr_pc_after_break = delegate_decr_pc_after_break; > } > @@ -1982,5 +2012,7 @@ install_dummy_methods (struct target_ops *ops) > ops->to_call_history_from = tdefault_call_history_from; > ops->to_call_history_range = tdefault_call_history_range; > ops->to_augmented_libraries_svr4_read = tdefault_augmented_libraries_svr4_read; > + ops->to_get_unwinder = tdefault_get_unwinder; > + ops->to_get_tailcall_unwinder = tdefault_get_tailcall_unwinder; > ops->to_decr_pc_after_break = default_target_decr_pc_after_break; > } > diff --git a/gdb/target.c b/gdb/target.c > index 72d5a09..d03c4fb 100644 > --- a/gdb/target.c > +++ b/gdb/target.c > @@ -3761,13 +3761,7 @@ debug_to_prepare_to_store (struct target_ops *self, struct regcache *regcache) > const struct frame_unwind * > target_get_unwinder (void) > { > - struct target_ops *t; > - > - for (t = current_target.beneath; t != NULL; t = t->beneath) > - if (t->to_get_unwinder != NULL) > - return t->to_get_unwinder; > - > - return NULL; > + return current_target.to_get_unwinder (¤t_target); > } > > /* See target.h. */ > @@ -3775,13 +3769,7 @@ target_get_unwinder (void) > const struct frame_unwind * > target_get_tailcall_unwinder (void) > { > - struct target_ops *t; > - > - for (t = current_target.beneath; t != NULL; t = t->beneath) > - if (t->to_get_tailcall_unwinder != NULL) > - return t->to_get_tailcall_unwinder; > - > - return NULL; > + return current_target.to_get_tailcall_unwinder (¤t_target); > } > > /* Default implementation of to_decr_pc_after_break. */ > diff --git a/gdb/target.h b/gdb/target.h > index c988a01..58519b0 100644 > --- a/gdb/target.h > +++ b/gdb/target.h > @@ -1095,10 +1095,14 @@ struct target_ops > int (*to_augmented_libraries_svr4_read) (struct target_ops *) > TARGET_DEFAULT_RETURN (0); > > - /* Those unwinders are tried before any other arch unwinders. Use NULL if > - it is not used. */ > - const struct frame_unwind *to_get_unwinder; > - const struct frame_unwind *to_get_tailcall_unwinder; > + /* Those unwinders are tried before any other arch unwinders. If > + SELF doesn't have unwinders, it should delegate to the > + "beneath" target. */ > + const struct frame_unwind *(*to_get_unwinder) (struct target_ops *self) > + TARGET_DEFAULT_RETURN (NULL); > + > + const struct frame_unwind *(*to_get_tailcall_unwinder) (struct target_ops *self) > + TARGET_DEFAULT_RETURN (NULL); > > /* Return the number of bytes by which the PC needs to be decremented > after executing a breakpoint instruction. > -- Pedro Alves