From patchwork Wed May 21 15:20:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1055 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 9E246360073 for ; Wed, 21 May 2014 08:20:48 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 5B9AE41C6A422; Wed, 21 May 2014 08:20:48 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 219A641C44A08 for ; Wed, 21 May 2014 08:20:48 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=TnvelyPBX8t8UdibjVue1fiTVMeyJ4gRhqCgrWehXRTsj+8YoC4n2 owORMjNPBcdC9GPin05VHb4HdBLluAqx6nWVIczcIDXDwdatQYJJGkLqFOABsM+x jt+Dqgp+07Xr3rAwTeHGH1wK3nNj+ETAmZrfVC5lMlJ9q/7drfggOE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=l/Mx9cYGdBMCjYyZT5gLB1T2ro8=; b=Od3z1kYVGuBCgqkVd2ccicVi3Ej0 VcKudvMs5Z00SMUgPtT57cG9Tbvy8XltPouxIPY3YITiQGAoQvcdBdQkZh8hVXUR Fh5AlfBdSNcqJu+yfqB/mtpRzA/yWyqhZNw5FSg5SPsMVP/hKxNljNffIEl81y0/ eHgCcBQljTnUZ2E= Received: (qmail 17489 invoked by alias); 21 May 2014 15:20:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 17475 invoked by uid 89); 21 May 2014 15:20:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS, UNWANTED_LANGUAGE_BODY 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; Wed, 21 May 2014 15:20:44 +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 s4LFKh9t006676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 21 May 2014 11:20:43 -0400 Received: from barimba.redhat.com (ovpn-113-182.phx2.redhat.com [10.3.113.182]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s4LFKgpC016555; Wed, 21 May 2014 11:20:42 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] convert to_thread_address_space to use TARGET_DEFAULT_FUNC Date: Wed, 21 May 2014 09:20:40 -0600 Message-Id: <1400685640-27786-1-git-send-email-tromey@redhat.com> X-DH-Original-To: gdb@patchwork.siddhesh.in This converts to_thread_address_space to use TARGET_DEFAULT_FUNC. This method was one of a handful not using the normal target delegation approach. The only rationale here is consistency in the target vector. Built and regtested on x86-64 Fedora 20. 2014-05-21 Tom Tromey * target-delegates.c: Rebuild. * target.c (default_thread_address_space): New function. (target_thread_address_space): Simplify. * target.h (struct target_ops) : Add TARGET_DEFAULT_FUNC. --- gdb/ChangeLog | 8 ++++++++ gdb/target-delegates.c | 10 ++++++++++ gdb/target.c | 46 ++++++++++++++++++++++++---------------------- gdb/target.h | 3 ++- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 0e95cf0..e6fbb44 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -945,6 +945,13 @@ delegate_thread_architecture (struct target_ops *self, ptid_t arg1) return self->to_thread_architecture (self, arg1); } +static struct address_space * +delegate_thread_address_space (struct target_ops *self, ptid_t arg1) +{ + self = self->beneath; + return self->to_thread_address_space (self, arg1); +} + static void delegate_trace_init (struct target_ops *self) { @@ -1782,6 +1789,8 @@ install_delegators (struct target_ops *ops) ops->to_can_run_breakpoint_commands = delegate_can_run_breakpoint_commands; if (ops->to_thread_architecture == NULL) ops->to_thread_architecture = delegate_thread_architecture; + if (ops->to_thread_address_space == NULL) + ops->to_thread_address_space = delegate_thread_address_space; if (ops->to_trace_init == NULL) ops->to_trace_init = delegate_trace_init; if (ops->to_download_tracepoint == NULL) @@ -1974,6 +1983,7 @@ install_dummy_methods (struct target_ops *ops) ops->to_supports_evaluation_of_breakpoint_conditions = tdefault_supports_evaluation_of_breakpoint_conditions; ops->to_can_run_breakpoint_commands = tdefault_can_run_breakpoint_commands; ops->to_thread_architecture = default_thread_architecture; + ops->to_thread_address_space = default_thread_address_space; ops->to_trace_init = tdefault_trace_init; ops->to_download_tracepoint = tdefault_download_tracepoint; ops->to_can_download_tracepoint = tdefault_can_download_tracepoint; diff --git a/gdb/target.c b/gdb/target.c index 71292d3..067091c 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -77,6 +77,9 @@ static int default_verify_memory (struct target_ops *self, const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size); +static struct address_space *default_thread_address_space + (struct target_ops *self, ptid_t ptid); + static void tcomplain (void) ATTRIBUTE_NORETURN; static int return_zero (struct target_ops *); @@ -2589,30 +2592,10 @@ target_get_osdata (const char *type) return target_read_stralloc (t, TARGET_OBJECT_OSDATA, type); } -/* Determine the current address space of thread PTID. */ - -struct address_space * -target_thread_address_space (ptid_t ptid) +static struct address_space * +default_thread_address_space (struct target_ops *self, ptid_t ptid) { - struct address_space *aspace; struct inferior *inf; - struct target_ops *t; - - for (t = current_target.beneath; t != NULL; t = t->beneath) - { - if (t->to_thread_address_space != NULL) - { - aspace = t->to_thread_address_space (t, ptid); - gdb_assert (aspace); - - if (targetdebug) - fprintf_unfiltered (gdb_stdlog, - "target_thread_address_space (%s) = %d\n", - target_pid_to_str (ptid), - address_space_num (aspace)); - return aspace; - } - } /* Fall-back to the "main" address space of the inferior. */ inf = find_inferior_pid (ptid_get_pid (ptid)); @@ -2626,6 +2609,25 @@ target_thread_address_space (ptid_t ptid) return inf->aspace; } +/* Determine the current address space of thread PTID. */ + +struct address_space * +target_thread_address_space (ptid_t ptid) +{ + struct address_space *aspace; + + aspace = current_target.to_thread_address_space (¤t_target, ptid); + gdb_assert (aspace != NULL); + + if (targetdebug) + fprintf_unfiltered (gdb_stdlog, + "target_thread_address_space (%s) = %d\n", + target_pid_to_str (ptid), + address_space_num (aspace)); + + return aspace; +} + /* Target file operations. */ diff --git a/gdb/target.h b/gdb/target.h index 9371529..f8e5e3a 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -772,7 +772,8 @@ struct target_ops The default implementation always returns the inferior's address space. */ struct address_space *(*to_thread_address_space) (struct target_ops *, - ptid_t); + ptid_t) + TARGET_DEFAULT_FUNC (default_thread_address_space); /* Target file operations. */