From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25925 invoked by alias); 28 Jun 2006 07:56:17 -0000 Received: (qmail 25909 invoked by uid 22791); 28 Jun 2006 07:56:12 -0000 X-Spam-Check-By: sourceware.org Received: from zigzag.lvk.cs.msu.su (HELO zigzag.lvk.cs.msu.su) (158.250.17.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 28 Jun 2006 07:56:08 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.50) id 1FvUtz-0000xJ-J9 for gdb-patches@sources.redhat.com; Wed, 28 Jun 2006 11:56:05 +0400 Received: from zigzag.lvk.cs.msu.su ([158.250.17.23]) by zigzag.lvk.cs.msu.su with esmtp (Exim 4.50) id 1FvUtz-0000xF-DJ for gdb-patches@sources.redhat.com; Wed, 28 Jun 2006 11:55:59 +0400 From: Vladimir Prus To: gdb-patches@sources.redhat.com Subject: [PATCH] Cleanup target memory reading Date: Wed, 28 Jun 2006 07:56:00 -0000 User-Agent: KMail/1.7.2 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_PYjoECJ+gIxp+1C" Message-Id: <200606281155.59166.ghost@cs.msu.su> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00385.txt.bz2 --Boundary-00=_PYjoECJ+gIxp+1C Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 672 Hi, at the moment, pretty much every read of target memory goes via target_read_memory, and then via xfer_using_stratum. The only exception is the get_target_memory_unsigned function, which calls target_read function. It's the only use of 'target_read'. The attached patch removes target_read, and makes get_target_memory_unsigned use target_read_memory. OK? - Volodya 2006-06-28 Vladimir Prus * target.h (target_read): Remove (get_target_memory): Remove. * target.c (target_read): Remove (get_target_memory): Remove. (get_target_memory_unsigned): Use target_read_memory. --Boundary-00=_PYjoECJ+gIxp+1C Content-Type: text/x-diff; charset="us-ascii"; name="target_read.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="target_read.diff" Content-length: 3065 === target.c ================================================================== --- target.c (revision 16) +++ target.c (revision 18) @@ -1359,30 +1359,7 @@ return target_xfer_partial (ops, object, annex, NULL, buf, offset, len); } -/* Wrappers to perform the full transfer. */ LONGEST -target_read (struct target_ops *ops, - enum target_object object, - const char *annex, gdb_byte *buf, - ULONGEST offset, LONGEST len) -{ - LONGEST xfered = 0; - while (xfered < len) - { - LONGEST xfer = target_read_partial (ops, object, annex, - (gdb_byte *) buf + xfered, - offset + xfered, len - xfered); - /* Call an observer, notifying them of the xfer progress? */ - if (xfer <= 0) - /* Call memory_error? */ - return -1; - xfered += xfer; - QUIT; - } - return len; -} - -LONGEST target_write (struct target_ops *ops, enum target_object object, const char *annex, const gdb_byte *buf, @@ -1404,25 +1381,13 @@ return len; } -/* Memory transfer methods. */ - -void -get_target_memory (struct target_ops *ops, CORE_ADDR addr, gdb_byte *buf, - LONGEST len) -{ - if (target_read (ops, TARGET_OBJECT_MEMORY, NULL, buf, addr, len) - != len) - memory_error (EIO, addr); -} - ULONGEST -get_target_memory_unsigned (struct target_ops *ops, - CORE_ADDR addr, int len) +get_target_memory_unsigned (CORE_ADDR addr, int len) { gdb_byte buf[sizeof (ULONGEST)]; gdb_assert (len <= sizeof (buf)); - get_target_memory (ops, addr, buf, len); + target_read_memory (addr, buf, len); return extract_unsigned_integer (buf, len); } === target.h ================================================================== --- target.h (revision 16) +++ target.h (revision 18) @@ -247,27 +247,19 @@ ULONGEST offset, LONGEST len); /* Wrappers to perform the full transfer. */ -extern LONGEST target_read (struct target_ops *ops, - enum target_object object, - const char *annex, gdb_byte *buf, - ULONGEST offset, LONGEST len); extern LONGEST target_write (struct target_ops *ops, enum target_object object, const char *annex, const gdb_byte *buf, ULONGEST offset, LONGEST len); -/* Wrappers to target read/write that perform memory transfers. They - throw an error if the memory transfer fails. +/* Read an unsigned value of LEN bytes from ADDR. + Endianess differences between host and target are handled automatically. - NOTE: cagney/2003-10-23: The naming schema is lifted from - "frame.h". The parameter order is lifted from get_frame_memory, - which in turn lifted it from read_memory. */ + Throws an error is unsuccessfull. -extern void get_target_memory (struct target_ops *ops, CORE_ADDR addr, - gdb_byte *buf, LONGEST len); -extern ULONGEST get_target_memory_unsigned (struct target_ops *ops, - CORE_ADDR addr, int len); +*/ +extern ULONGEST get_target_memory_unsigned (CORE_ADDR addr, int len); /* If certain kinds of activity happen, target_wait should perform --Boundary-00=_PYjoECJ+gIxp+1C--