Bug 9053 - remote_xfer_partial(): packet size probe fails when LENGTH and OFFSET are zero [target: avr]
Summary: remote_xfer_partial(): packet size probe fails when LENGTH and OFFSET are zer...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: remote (show other bugs)
Version: 6.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 17060 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-05-24 19:48 UTC by Joerg Wunsch
Modified: 2014-08-09 01:01 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
remote.c.diff (309 bytes, application/octet-stream)
, Joerg Wunsch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joerg Wunsch 2005-05-24 19:48:01 UTC
[Converted from Gnats 1948]

In remote_xfer_partial(), the following piece of code suggests
the size of a remote packet can be probed:

  /* Note: a zero OFFSET and LEN can be used to query the minimum
     buffer size.  */
  if (offset == 0 && len == 0)
    return (rs->remote_packet_size);

Yet, a few lines above, the request had already been
discarded unless a buffer pointer was provided, commented
as:

  /* Only handle reads.  */
  if (writebuf != NULL || readbuf == NULL)
    return -1;

That should be changed to not discard the request in the
case of a packet probe.  The suggested patch fixes this.

The problem became apparent as the "info io_registers"
command for the AVR target does no longer work (as it uses
the packet probe to decide how much space to allocate for
the IO register packet).

Release:
6.3

Environment:
FreeBSD & configured for target AVR

How-To-Repeat:
Use avr-gdb, connect to a target, and issue an
"info io_registers" command.  Debugging information in the
remote process indicate no request is sent there by GDB.

(NB: the AVR target only supports remote debugging.)
Comment 1 eweddington 2007-08-10 23:12:06 UTC
From: Eric Weddington <eweddington@cso.atmel.com>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: remote/1948: remote_xfer_partial(): packet size probe fails when
 LENGTH and OFFSET are zero [target: avr]
Date: Fri, 10 Aug 2007 17:12:06 -0600

 This bug looks like it's fixed in 6.6 (remote_xfer_partial()):
 
   /* Note: a zero OFFSET and LEN can be used to query the minimum
      buffer size.  */
   if (offset == 0 && len == 0)
     return (get_remote_packet_size ());
 
 But it needs to be tested for the AVR.
 
 Eric Weddington
Comment 2 Pedro Alves 2008-12-24 19:14:23 UTC
Marking as WAITING.

I see that the check in question was changed here:

http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/remote.c.diff?r1=1.228&r2=1.229&cvsroot=src&f=h
Comment 3 Sourceware Commits 2014-08-09 00:56:44 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  dcd2e6ef22c3453b9322ad4b46fb7cc05810b7ee (commit)
      from  20c6f1e176f4139ed1e76d4256e70149e38c0820 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dcd2e6ef22c3453b9322ad4b46fb7cc05810b7ee

commit dcd2e6ef22c3453b9322ad4b46fb7cc05810b7ee
Author: Yao Qi <yao@codesourcery.com>
Date:   Fri Aug 8 13:45:23 2014 +0800

    Fix PR remote/9053: remove dead code on query packet size
    
    The code becomes dead as GDB evolves.  In 2003, Andrew Cagney post patch
    https://sourceware.org/ml/gdb-patches/2003-10/msg00511.html to add target
    read/write partial methods.  They support query buffer size when both
    OFFSET and LEN is zero, and it was used in avr-tdep.c and kod.c.  Then,
    Daniel added target_read_object_alloc and avr-tdep.c switches to use that
    in patch https://sourceware.org/ml/gdb-patches/2006-07/msg00009.html
    From then on, GDB on longer queries the buffer size, so the code
    returning packet size in remote_xfer_partial became dead.
    
    PR 17060 is duplicated of PR 9053, so I mention the latter in the
    ChangeLog entry.  Rebuild GDB with this patch.  OK to apply?
    I'll mark PR 17060 as duplicated once the patch is applied.
    
    gdb:
    
    2014-08-09  Yao Qi  <yao@codesourcery.com>
    
    	PR remote/9053
    	* remote.c (remote_xfer_partial): Remove dead code.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog |    5 +++++
 gdb/remote.c  |    4 ----
 2 files changed, 5 insertions(+), 4 deletions(-)
Comment 4 Yao Qi 2014-08-09 00:58:24 UTC
*** Bug 17060 has been marked as a duplicate of this bug. ***
Comment 5 Yao Qi 2014-08-09 01:01:50 UTC
GDB on longer supports querying packet size (when LENGTH and OFFSET are zero), and the corresponding code becomes dead.  Remove the dead code and close this PR.