public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] gdbserver support for qCRC: (compare-sections)
Date: Tue, 23 Mar 2010 18:16:00 -0000	[thread overview]
Message-ID: <4BA9056D.8050206@vmware.com> (raw)
In-Reply-To: <201003231626.13757.pedro@codesourcery.com>

Pedro Alves wrote:
> On Monday 22 March 2010 17:59:25, Michael Snyder wrote:
>> 2010-03-19  Michael Snyder  <msnyder@vmware.com>
>>
>>         * server.c (crc32): New function.
>>         (handle_query): Add handling for 'qCRC:' request.
>>
>> Index: server.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
>> retrieving revision 1.108
>> diff -u -p -r1.108 server.c
>> --- server.c    20 Jan 2010 22:55:38 -0000      1.108
>> +++ server.c    22 Mar 2010 17:57:32 -0000
>> @@ -788,6 +788,47 @@ handle_threads_qxfer (const char *annex,
>>  
>>  }
>>  
>> +/* Table used by the crc32 function to calcuate the checksum.  */
>> +
>> +static unsigned long crc32_table[256] =
>> +{0, 0};
>> +
> 
> I know you've copied this from remote.c, but, can't
> we make this an `unsigned int' table?  longs are 64-bit
> on most 64-bit archs, so this uses up double more memory
> than needed.

Good idea.  Doesn't seem to break anything.  Will do.



> 
>> +/* Compute 32 bit CRC from inferior memory.
>> +
>> +   On success, return 32 bit CRC.
>> +   On failure, return (unsigned long long) -1.  */
>> +
>> +static unsigned long long
>> +crc32 (CORE_ADDR base, int len, unsigned int crc)
> 
> Can't say I'm thrilled by assuming
> sizeof (long long) > sizeof (long), but I guess
> it works on all targets gdbserver cares for presently.

And with your suggested change, the assumption now is that
sizeof(long long) > sizeof(int), which is even more safe.



>> +  if (strncmp ("qCRC:", own_buf, 5) == 0)
>> +    {
>> +      /* CRC check (compare-segment).  */
>> +      char *comma;
>> +      CORE_ADDR base = strtoul (own_buf + 5, &comma, 16);
>> +      int len;
>> +      unsigned long long crc;
>> +
> 
> A `require_running' call is missing here.

Sorry, what's that?  I'm not familiar with it.

> 
> 
>> +      if (*comma++ != ',')
>> +       {
>> +         write_enn (own_buf);
>> +         return;
>> +       }
>> +      len = strtoul (comma, NULL, 16);
>> +      crc = crc32 (base, len, 0xffffffff);
>> +      /* Check for memory failure.  */
>> +      if (crc == (unsigned long long) -1)
>> +       {
>> +         write_enn (own_buf);
>> +         return;
>> +       }
>> +      sprintf (own_buf, "C%lx", (unsigned long) crc);
>> +      return;
>> +    }
>> +
>>    /* Otherwise we didn't know what packet it was.  Say we didn't
>>       understand it.  */
>>    own_buf[0] = 0;
> 
> Otherwise, looks fine to me.

Big thanks for the review!

Michael



  reply	other threads:[~2010-03-23 18:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-19 23:27 Michael Snyder
2010-03-22 17:59 ` Michael Snyder
2010-03-23 16:26   ` Pedro Alves
2010-03-23 18:16     ` Michael Snyder [this message]
2010-03-23 18:32       ` Pedro Alves
2010-03-23 22:44         ` Michael Snyder
2010-03-23 23:15           ` Pedro Alves
2010-03-24  0:16             ` Pedro Alves
2010-03-24  0:34               ` Michael Snyder
2010-03-24  1:15         ` Pedro Alves

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=4BA9056D.8050206@vmware.com \
    --to=msnyder@vmware.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).