From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25612 invoked by alias); 6 Mar 2010 06:04:59 -0000 Received: (qmail 25448 invoked by uid 22791); 6 Mar 2010 06:04:58 -0000 X-SWARE-Spam-Status: No, hits=-7.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 06 Mar 2010 06:04:49 +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.13.8/8.13.8) with ESMTP id o2664mdc003341 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 6 Mar 2010 01:04:48 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2664l7d016029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Sat, 6 Mar 2010 01:04:48 -0500 Date: Sat, 06 Mar 2010 06:04:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: Re: [RFC] remote-mips.c: Don't error out when a memory read fails Message-ID: <20100305230447.032b36d7@redhat.com> In-Reply-To: <20100306040535.GN2832@adacore.com> References: <20100305154846.29fab2c4@redhat.com> <20100306040535.GN2832@adacore.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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 X-SW-Source: 2010-03/txt/msg00256.txt.bz2 On Sat, 6 Mar 2010 08:05:35 +0400 Joel Brobecker wrote: > > * remote-mips.c (mips_fetch_word): Add new parameter, `valp'. > > Change return value to int. Store value fetched in location > > addressed by `val'. Use function's return value as success > > or failure indicator. Adjust all callers. > > Looks good to me. Thanks for looking it over. > > +static int > > +mips_fetch_word (CORE_ADDR addr, unsigned int *valp) > > { > > unsigned int val; > > I think that this variable is no longer used? Right you are. See below for a revised patch. The only change from the earlier patch is that `val' is removed from mips_fetch_word(). Thanks again, Kevin * remote-mips.c (mips_fetch_word): Add new parameter, `valp'. Change return value to int. Store value fetched in location addressed by `val'. Use function's return value as success or failure indicator. Adjust all callers. Index: remote-mips.c =================================================================== RCS file: /cvs/src/src/gdb/remote-mips.c,v retrieving revision 1.109 diff -u -p -r1.109 remote-mips.c --- remote-mips.c 5 Mar 2010 16:18:54 -0000 1.109 +++ remote-mips.c 6 Mar 2010 05:58:41 -0000 @@ -91,7 +91,7 @@ static int mips_map_regno (struct gdbarc static void mips_prepare_to_store (struct regcache *regcache); -static unsigned int mips_fetch_word (CORE_ADDR addr); +static int mips_fetch_word (CORE_ADDR addr, unsigned int *valp); static int mips_store_word (CORE_ADDR addr, unsigned int value, int *old_contents); @@ -1994,25 +1994,23 @@ mips_store_registers (struct target_ops mips_error ("Can't write register %d: %s", regno, safe_strerror (errno)); } -/* Fetch a word from the target board. */ +/* Fetch a word from the target board. Return word fetched in location + addressed by VALP. Return 0 when successful; return positive error + code when not. */ -static unsigned int -mips_fetch_word (CORE_ADDR addr) +static int +mips_fetch_word (CORE_ADDR addr, unsigned int *valp) { - unsigned int val; int err; - val = mips_request ('d', addr, 0, &err, mips_receive_wait, NULL); + *valp = mips_request ('d', addr, 0, &err, mips_receive_wait, NULL); if (err) { /* Data space failed; try instruction space. */ - val = mips_request ('i', addr, 0, &err, - mips_receive_wait, NULL); - if (err) - mips_error ("Can't read address %s: %s", - paddress (target_gdbarch, addr), safe_strerror (errno)); + *valp = mips_request ('i', addr, 0, &err, + mips_receive_wait, NULL); } - return val; + return err; } /* Store a word to the target board. Returns errno code or zero for @@ -2078,17 +2076,25 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb /* Fill start and end extra bytes of buffer with existing data. */ if (addr != memaddr || len < 4) { + unsigned int val; + + if (mips_fetch_word (addr, &val)) + return 0; + /* Need part of initial word -- fetch it. */ - store_unsigned_integer (&buffer[0], 4, byte_order, - mips_fetch_word (addr)); + store_unsigned_integer (&buffer[0], 4, byte_order, val); } if (count > 1) { + unsigned int val; + /* Need part of last word -- fetch it. FIXME: we do this even if we don't need it. */ - store_unsigned_integer (&buffer[(count - 1) * 4], 4, byte_order, - mips_fetch_word (addr + (count - 1) * 4)); + if (mips_fetch_word (addr + (count - 1) * 4, &val)) + return 0; + + store_unsigned_integer (&buffer[(count - 1) * 4], 4, byte_order, val); } /* Copy data to be written over corresponding part of buffer */ @@ -2123,8 +2129,12 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb /* Read all the longwords */ for (i = 0; i < count; i++, addr += 4) { - store_unsigned_integer (&buffer[i * 4], 4, byte_order, - mips_fetch_word (addr)); + unsigned int val; + + if (mips_fetch_word (addr, &val)) + return 0; + + store_unsigned_integer (&buffer[i * 4], 4, byte_order, val); QUIT; }