From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2118 invoked by alias); 13 Jan 2014 19:13:21 -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 2080 invoked by uid 89); 13 Jan 2014 19:13:20 -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:13:19 +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 s0DJDGm8031953 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Jan 2014 14:13:17 -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 s0DJCptb016701; Mon, 13 Jan 2014 14:13:15 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 31/32] change delegation for to_read_description Date: Mon, 13 Jan 2014 19:13:00 -0000 Message-Id: <1389640367-5571-32-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/msg00346.txt.bz2 This switches to_read_description to the "new normal" delegation scheme. This one was a bit trickier than the other changes due to the way that target_read_description handled delegation. I examined all the target implementations of to_read_description and changed the ones returning NULL to instead delegate. 2014-01-13 Tom Tromey * arm-linux-nat.c (arm_linux_read_description): Delegate when needed * corelow.c (core_read_description): Delegate when needed. * remote.c (remote_read_description): Delegate when needed. * target-delegates.c: Rebuild. * target.c (target_read_description): Rewrite. * target.h (struct target_ops) : Update comment. Use TARGET_DEFAULT_RETURN. --- gdb/ChangeLog | 11 +++++++++++ gdb/arm-linux-nat.c | 4 ++-- gdb/corelow.c | 12 +++++++++--- gdb/remote.c | 4 ++-- gdb/target-delegates.c | 16 ++++++++++++++++ gdb/target.c | 15 +-------------- gdb/target.h | 7 ++++--- 7 files changed, 45 insertions(+), 24 deletions(-) diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index 7cd7d63..0416ba0 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -636,7 +636,7 @@ arm_linux_read_description (struct target_ops *ops) if (target_auxv_search (ops, AT_HWCAP, &arm_hwcap) != 1) { - return NULL; + return ops->beneath->to_read_description (ops->beneath); } if (arm_hwcap & HWCAP_IWMMXT) @@ -681,7 +681,7 @@ arm_linux_read_description (struct target_ops *ops) return result; } - return NULL; + return ops->beneath->to_read_description (ops->beneath); } /* Information describing the hardware breakpoint capabilities. */ diff --git a/gdb/corelow.c b/gdb/corelow.c index 4b72203..a500aa5 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -870,10 +870,16 @@ static const struct target_desc * core_read_description (struct target_ops *target) { if (core_gdbarch && gdbarch_core_read_description_p (core_gdbarch)) - return gdbarch_core_read_description (core_gdbarch, - target, core_bfd); + { + const struct target_desc *result; + + result = gdbarch_core_read_description (core_gdbarch, + target, core_bfd); + if (result != NULL) + return result; + } - return NULL; + return target->beneath->to_read_description (target->beneath); } static char * diff --git a/gdb/remote.c b/gdb/remote.c index 34b8f6d..3f5f7f9 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -9569,7 +9569,7 @@ remote_read_description (struct target_ops *target) /* Do not try this during initial connection, when we do not know whether there is a running but stopped thread. */ if (!target_has_execution || ptid_equal (inferior_ptid, null_ptid)) - return NULL; + return target->beneath->to_read_description (target->beneath); if (!VEC_empty (remote_g_packet_guess_s, data->guesses)) { @@ -9588,7 +9588,7 @@ remote_read_description (struct target_ops *target) an architecture, but it's too tricky to do safely. */ } - return NULL; + return target->beneath->to_read_description (target->beneath); } /* Remote file transfer support. This is host-initiated I/O, not diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 66c0625..44e5fc2 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -801,6 +801,19 @@ tdefault_flash_done (struct target_ops *self) tcomplain (); } +static const struct target_desc * +delegate_read_description (struct target_ops *self) +{ + self = self->beneath; + return self->to_read_description (self); +} + +static const struct target_desc * +tdefault_read_description (struct target_ops *self) +{ + return 0; +} + static ptid_t delegate_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2) { @@ -1700,6 +1713,8 @@ install_delegators (struct target_ops *ops) ops->to_flash_erase = delegate_flash_erase; if (ops->to_flash_done == NULL) ops->to_flash_done = delegate_flash_done; + if (ops->to_read_description == NULL) + ops->to_read_description = delegate_read_description; if (ops->to_get_ada_task_ptid == NULL) ops->to_get_ada_task_ptid = delegate_get_ada_task_ptid; if (ops->to_auxv_parse == NULL) @@ -1896,6 +1911,7 @@ install_dummy_methods (struct target_ops *ops) ops->to_memory_map = tdefault_memory_map; ops->to_flash_erase = tdefault_flash_erase; ops->to_flash_done = tdefault_flash_done; + ops->to_read_description = tdefault_read_description; ops->to_get_ada_task_ptid = default_get_ada_task_ptid; ops->to_auxv_parse = default_auxv_parse; ops->to_search_memory = default_search_memory; diff --git a/gdb/target.c b/gdb/target.c index df11fc0..76316b5 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -746,7 +746,6 @@ update_current_target (void) (int (*) (CORE_ADDR, gdb_byte *, int, int, struct mem_attrib *, struct target_ops *)) nomemory); - current_target.to_read_description = NULL; #undef de_fault @@ -2559,19 +2558,7 @@ target_mourn_inferior (void) const struct target_desc * target_read_description (struct target_ops *target) { - struct target_ops *t; - - for (t = target; t != NULL; t = t->beneath) - if (t->to_read_description != NULL) - { - const struct target_desc *tdesc; - - tdesc = t->to_read_description (t); - if (tdesc) - return tdesc; - } - - return NULL; + return target->to_read_description (target); } /* This implements a basic search of memory, reading target memory and diff --git a/gdb/target.h b/gdb/target.h index 978941b..b68c336 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -673,9 +673,10 @@ struct target_ops TARGET_DEFAULT_NORETURN (tcomplain ()); /* Describe the architecture-specific features of this target. - Returns the description found, or NULL if no description - was available. */ - const struct target_desc *(*to_read_description) (struct target_ops *ops); + Returns the description found. If no description is found, + this should delegate to the "beneath" target. */ + const struct target_desc *(*to_read_description) (struct target_ops *ops) + TARGET_DEFAULT_RETURN (0); /* Build the PTID of the thread on which a given task is running, based on LWP and THREAD. These values are extracted from the -- 1.8.1.4