Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@gnu.org>
To: "Theodore A. Roth" <troth@openavr.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] initialize err variable in load_section_callback()
Date: Wed, 20 Oct 2004 17:34:00 -0000	[thread overview]
Message-ID: <4176A188.1030904@gnu.org> (raw)
In-Reply-To: <Pine.LNX.4.53.0410191307030.17223@knuth.amplepower.com>

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  <troth@openavr.org>
> 
> 	* 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;
>  


  reply	other threads:[~2004-10-20 17:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-19 20:22 Theodore A. Roth
2004-10-20 17:34 ` Andrew Cagney [this message]
2004-10-20 18:07   ` Theodore A. Roth
2004-10-26  0:04     ` Andrew Cagney
2004-10-26 18:19       ` Theodore A. Roth
2004-12-28  9:10         ` Theodore A. Roth
2005-03-04 17:51           ` Daniel Jacobowitz
2004-12-02 14:45 Paul Schlie
2005-01-04  7:31 Paul Schlie
2005-01-14 23:29 ` Paul Schlie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4176A188.1030904@gnu.org \
    --to=cagney@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=troth@openavr.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox