From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18924 invoked by alias); 20 Oct 2004 17:34:34 -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 18905 invoked from network); 20 Oct 2004 17:34:33 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 20 Oct 2004 17:34:33 -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 i9KHYS37001619 for ; Wed, 20 Oct 2004 13:34:28 -0400 Received: from localhost.redhat.com (to-dhcp51.toronto.redhat.com [172.16.14.151]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i9KHYRr29783; Wed, 20 Oct 2004 13:34:27 -0400 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 3F5817ACEF; Wed, 20 Oct 2004 13:34:01 -0400 (EDT) Message-ID: <4176A188.1030904@gnu.org> Date: Wed, 20 Oct 2004 17:34:00 -0000 From: Andrew Cagney User-Agent: Mozilla Thunderbird 0.8 (X11/20041012) MIME-Version: 1.0 To: "Theodore A. Roth" Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] initialize err variable in load_section_callback() References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-10/txt/msg00345.txt.bz2 Theodore A. Roth wrote: > Hi, > > I just encountered a problem with using the "load" command with a remote > avr target. The first packet would be sent to the remote target and then > gdb would just give up with this error message: > > (gdb) load > Loading section .text, size 0x1f8 lma 0x0 > Sending packet: $M0,a:0c9446000c9463000c94#d7...Ack > Packet received: OK > Memory access error while loading section .text. > > It looks like load_section_callback() in symfile.c is assuming that a > call to target_write_memory_partial() will set the err variable. > Unfortunately, that is not a valid assumption. > > The attached patch got things working again, but this feels like a hack > to me since target_write_memory_partial() should really be setting err > to a sane value before returning. > > Patch is against today's cvs mainline. Here's the contract: /* Make a single attempt at transfering LEN bytes. On a successful transfer, the number of bytes actually transfered is returned and ERR is set to 0. When a transfer fails, -1 is returned (the number of bytes actually transfered is not defined) and ERR is set to a non-zero error indication. */ So the bug is further down the target stack. Andrew > 2004-10-19 Theodore A. Roth > > * symfile.c (load_section_callback): Initialize err to zero since > target_write_memory_partial() may not set it in all situations. > > Index: symfile.c > =================================================================== > RCS file: /cvs/src/src/gdb/symfile.c,v > retrieving revision 1.143 > diff -u -p -p -r1.143 symfile.c > --- symfile.c 1 Oct 2004 10:23:09 -0000 1.143 > +++ symfile.c 19 Oct 2004 20:07:58 -0000 > @@ -1405,7 +1405,7 @@ load_section_callback (bfd *abfd, asecti > struct cleanup *old_chain; > CORE_ADDR lma = bfd_section_lma (abfd, asec) + args->load_offset; > bfd_size_type block_size; > - int err; > + int err = 0; > const char *sect_name = bfd_get_section_name (abfd, asec); > bfd_size_type sent; >