From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20916 invoked by alias); 19 Feb 2014 20:29:44 -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 20871 invoked by uid 89); 19 Feb 2014 20:29:44 -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; Wed, 19 Feb 2014 20:29:43 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1JKTfUC006391 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 19 Feb 2014 15:29:41 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1JKTamq025004 for ; Wed, 19 Feb 2014 15:29:40 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 4/7] nto-procfs.c: Don't install a deprecated_xfer_memory method Date: Wed, 19 Feb 2014 20:29:00 -0000 Message-Id: <1392841775-19126-5-git-send-email-palves@redhat.com> In-Reply-To: <1392841775-19126-1-git-send-email-palves@redhat.com> References: <1392841775-19126-1-git-send-email-palves@redhat.com> X-SW-Source: 2014-02/txt/msg00607.txt.bz2 This removes yet another instance of a deprecated_xfer_memory user. I have no way to test this. gdb/ 2014-02-19 Pedro Alves * nto-procfs.c (procfs_xfer_memory): Adjust interface as a to_xfer_partial helper. Rewrite. (procfs_xfer_partial): New function. (init_procfs_ops): Don't install a deprecated_xfer_memory hook. Install a to_xfer_partial hook. --- gdb/nto-procfs.c | 58 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index d0bdc90..bdda7ce 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -59,10 +59,6 @@ static void procfs_open (char *, int); static int procfs_can_run (struct target_ops *self); -static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int, - struct mem_attrib *attrib, - struct target_ops *); - static void init_procfs_ops (void); static ptid_t do_attach (ptid_t ptid); @@ -849,30 +845,44 @@ procfs_fetch_registers (struct target_ops *ops, nto_supply_altregset (regcache, (char *) ®.altreg); } -/* Copy LEN bytes to/from inferior's memory starting at MEMADDR - from/to debugger memory starting at MYADDR. Copy from inferior - if DOWRITE is zero or to inferior if DOWRITE is nonzero. +/* Helper for procfs_xfer_partial that handles memory transfers. + Arguments are like target_xfer_partial. */ - Returns the length copied, which is either the LEN argument or - zero. This xfer function does not do partial moves, since procfs_ops - doesn't allow memory operations to cross below us in the target stack - anyway. */ -static int -procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite, - struct mem_attrib *attrib, struct target_ops *target) +static enum target_xfer_status +procfs_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf, + ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len) { - int nbytes = 0; + int nbytes; + + if (lseek (ctl_fd, (off_t) memaddr, SEEK_SET) != (off_t) memaddr) + return TARGET_XFER_E_IO; + + if (writebuf != NULL) + nbytes = write (ctl_fd, writebuf, len); + else + nbytes = read (ctl_fd, readbuf, len); + if (nbytes <= 0) + return TARGET_XFER_E_IO; + *xfered_len = nbytes; + return TARGET_XFER_OK; +} + +/* Target to_xfer_partial implementation. */ - if (lseek (ctl_fd, (off_t) memaddr, SEEK_SET) == (off_t) memaddr) +static enum target_xfer_status +procfs_xfer_partial (struct target_ops *ops, enum target_object object, + const char *annex, gdb_byte *readbuf, + const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, + ULONGEST *xfered_len) +{ + switch (object) { - if (dowrite) - nbytes = write (ctl_fd, myaddr, len); - else - nbytes = read (ctl_fd, myaddr, len); - if (nbytes < 0) - nbytes = 0; + case TARGET_OBJECT_MEMORY: + return procfs_xfer_memory (readbuf, writebuf, offset, len, xfered_len); + default: + return ops->beneath->to_xfer_partial (ops->beneath, object, annex, + readbuf, writebuf, offset, len); } - return (nbytes); } /* Take a program previously attached to and detaches it. @@ -1397,7 +1407,7 @@ init_procfs_ops (void) procfs_ops.to_fetch_registers = procfs_fetch_registers; procfs_ops.to_store_registers = procfs_store_registers; procfs_ops.to_prepare_to_store = procfs_prepare_to_store; - procfs_ops.deprecated_xfer_memory = procfs_xfer_memory; + procfs_ops.to_xfer_partial = procfs_xfer_partial; procfs_ops.to_files_info = procfs_files_info; procfs_ops.to_insert_breakpoint = procfs_insert_breakpoint; procfs_ops.to_remove_breakpoint = procfs_remove_breakpoint; -- 1.7.11.7