From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16019 invoked by alias); 12 Sep 2004 13:04:55 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 16012 invoked from network); 12 Sep 2004 13:04:53 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 12 Sep 2004 13:04:53 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.10) with ESMTP id i8CD4qWe008676 for ; Sun, 12 Sep 2004 09:04:52 -0400 Received: from localhost.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i8CD4qr30669; Sun, 12 Sep 2004 09:04:52 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id EDD5F28D2; Sun, 12 Sep 2004 09:11:21 -0400 (EDT) Message-ID: <41444AF9.5000500@gnu.org> Date: Sun, 12 Sep 2004 13:04:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040831 MIME-Version: 1.0 To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: [patch/rfc] Implement ptrace target vector inheritance References: <413B1E60.9060506@gnu.org> In-Reply-To: <413B1E60.9060506@gnu.org> Content-Type: multipart/mixed; boundary="------------050809000900070201000100" X-SW-Source: 2004-09/txt/msg00187.txt.bz2 This is a multi-part message in MIME format. --------------050809000900070201000100 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1054 > Hello, > > This came from an thread between myself and MarkK (I can't find the url). > > The current native code constructs its target vector using a convoluted combination of #ifdefs and global functions. > > This patch replaces all that with what is effectively a runtime inheritance structure: > > inf-ptrace is-a inf-child is-a target > > I've updated/tested NetBSD/PPC, with a tweak to nbsdppc-nat. that further extends the above with: > > nbsdppc-nat is-a inf-ptrace > > there were no regressions. > > The intent is for all natives to eventually migrate to this. > > Comments? > > Right now I'm more interested in high-level stuff - the idea and the strategy. I'm sure the implementation will evolve as more natives come on board, and as I eliminate a few remaining globals. > > I'll leave this for a week, I've checked in the attached, per suggestions. I've left out the new commands (keeping new functionality separate from refactoring). I've also left a few things like call_ptrace in infptrace.c. committed, Andrew --------------050809000900070201000100 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 2476 2004-09-12 Andrew Cagney * ppcnbsd-nat.c: Include "inf-ptrace.h". (ppcnbsd_fetch_inferior_registers): Rename fetch_inferior_registers. (ppcnbsd_store_inferior_registers): Rename store_inferior_registers. (_initialize_ppcnbsd_nat): Create and add a NetBSD/PPC ptrace target. * config/powerpc/nbsd.mh (NATDEPFILES): Replace and inftarg.o with inf-ptrace.o and inf-child.o. * inf-ptrace.h, inf-ptrace.c, inf-child.h, inf-child.c: New files. * Makefile.in: Update dependencies. Index: ppcnbsd-nat.c =================================================================== RCS file: /cvs/src/src/gdb/ppcnbsd-nat.c,v retrieving revision 1.17 diff -p -u -r1.17 ppcnbsd-nat.c --- ppcnbsd-nat.c 14 Aug 2004 23:37:04 -0000 1.17 +++ ppcnbsd-nat.c 11 Sep 2004 15:08:44 -0000 @@ -35,6 +35,8 @@ #include "ppc-tdep.h" #include "ppcnbsd-tdep.h" +#include "inf-ptrace.h" + /* Returns true if PT_GETREGS fetches this register. */ static int getregs_supplies (int regno) @@ -73,8 +75,8 @@ getfpregs_supplies (int regno) || regno == tdep->ppc_fpscr_regnum); } -void -fetch_inferior_registers (int regno) +static void +ppcnbsd_fetch_inferior_registers (int regno) { if (regno == -1 || getregs_supplies (regno)) { @@ -103,8 +105,8 @@ fetch_inferior_registers (int regno) } } -void -store_inferior_registers (int regno) +static void +ppcnbsd_store_inferior_registers (int regno) { if (regno == -1 || getregs_supplies (regno)) { @@ -177,6 +179,12 @@ void _initialize_ppcnbsd_nat (void); void _initialize_ppcnbsd_nat (void) { + struct target_ops *t; /* Support debugging kernel virtual memory images. */ bsd_kvm_add_target (ppcnbsd_supply_pcb); + /* Add in local overrides. */ + t = inf_ptrace_target (); + t->to_fetch_registers = ppcnbsd_fetch_inferior_registers; + t->to_store_registers = ppcnbsd_store_inferior_registers; + add_target (t); } Index: config/powerpc/nbsd.mh =================================================================== RCS file: /cvs/src/src/gdb/config/powerpc/nbsd.mh,v retrieving revision 1.13 diff -p -u -r1.13 nbsd.mh --- config/powerpc/nbsd.mh 3 Sep 2004 19:08:20 -0000 1.13 +++ config/powerpc/nbsd.mh 11 Sep 2004 15:08:44 -0000 @@ -1,5 +1,5 @@ # Host: PowerPC, running NetBSD -NATDEPFILES= fork-child.o infptrace.o inftarg.o ppcnbsd-nat.o bsd-kvm.o +NATDEPFILES= fork-child.o inf-child.o inf-ptrace.o infptrace.o ppcnbsd-nat.o bsd-kvm.o NAT_FILE= config/nm-nbsd.h LOADLIBES= -lkvm --------------050809000900070201000100--