From patchwork Thu Apr 12 16:59:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 26695 Received: (qmail 94718 invoked by alias); 12 Apr 2018 16:59:40 -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 94704 invoked by uid 89); 12 Apr 2018 16:59:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT autolearn=ham version=3.3.2 spammy=3770, 6, Cancel, 37706 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Apr 2018 16:59:37 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8CB9EB715 for ; Thu, 12 Apr 2018 16:59:35 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E679DEED1 for ; Thu, 12 Apr 2018 16:59:35 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] More procfs.c simplification Date: Thu, 12 Apr 2018 17:59:34 +0100 Message-Id: <20180412165934.27722-1-palves@redhat.com> There are only two architectures using procfs.c (i386/SPARC), and none of their corresponding nat files overrides any target method. Move the add_target calls to procfs.c directly. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Don't call procfs_target/add_target here. * procfs.c (procfs_target): Make static. (_initialize_procfs): Call add_target here. * procfs.h (struct target_ops): Remove forward declaration. (procfs_target): Remove declaration. * sparc-sol2-nat.c (_initialize_sparc_sol2_nat): Delete. --- gdb/i386-sol2-nat.c | 7 ------- gdb/procfs.c | 6 +++++- gdb/procfs.h | 7 ------- gdb/sparc-sol2-nat.c | 9 --------- 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/gdb/i386-sol2-nat.c b/gdb/i386-sol2-nat.c index 359fc3203d..992ecb7ed1 100644 --- a/gdb/i386-sol2-nat.c +++ b/gdb/i386-sol2-nat.c @@ -133,11 +133,6 @@ fill_fpregset (const struct regcache *regcache, void _initialize_amd64_sol2_nat (void) { - struct target_ops *t; - - /* Fill in the generic procfs methods. */ - t = procfs_target (); - #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset; amd64_native_gregset32_num_regs = @@ -146,6 +141,4 @@ _initialize_amd64_sol2_nat (void) amd64_native_gregset64_num_regs = ARRAY_SIZE (amd64_sol2_gregset64_reg_offset); #endif - - add_target (t); } diff --git a/gdb/procfs.c b/gdb/procfs.c index 0143f2621c..51c9ae8f00 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -171,7 +171,9 @@ procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr, } #endif -struct target_ops * +/* Create a procfs target. */ + +static struct target_ops * procfs_target (void) { struct target_ops *t = inf_child_target (); @@ -3770,6 +3772,8 @@ _initialize_procfs (void) _("Cancel a trace of entries into the syscall.")); add_com ("proc-untrace-exit", no_class, proc_untrace_sysexit_cmd, _("Cancel a trace of exits from the syscall.")); + + add_target (procfs_target ()); } /* =================== END, GDB "MODULE" =================== */ diff --git a/gdb/procfs.h b/gdb/procfs.h index beeb876a73..e66c674282 100644 --- a/gdb/procfs.h +++ b/gdb/procfs.h @@ -17,13 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -struct target_ops; - -/* Create a prototype generic procfs target. The client can override - it with local methods. */ - -extern struct target_ops *procfs_target (void); - /* Return a ptid for which we guarantee we will be able to find a 'live' procinfo. */ diff --git a/gdb/sparc-sol2-nat.c b/gdb/sparc-sol2-nat.c index 482050d008..2c0d561f98 100644 --- a/gdb/sparc-sol2-nat.c +++ b/gdb/sparc-sol2-nat.c @@ -97,12 +97,3 @@ fill_fpregset (const struct regcache *regcache, { sparc_collect_fpregset (&sparc_sol2_fpregmap, regcache, regnum, fpregs); } - -void -_initialize_sparc_sol2_nat (void) -{ - struct target_ops *t; - - t = procfs_target (); - add_target (t); -}