This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH] new MI command for pattern filling of memory regions
Thanks,
my answers are interleaved below.
> -----Original Message-----
> From: Tom Tromey [mailto:tromey@redhat.com]
> Sent: Friday, May 11, 2012 4:14 PM
> To: Giuseppe MONTALTO
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH] new MI command for pattern filling of memory
> regions
>
> The indentation is wrong here and elsewhere in the patch.
> There are missing spaces as well.
> See the GNU Coding Standards for details.
I'll try to better format the code.
>
> I don't think the cast here, or other casts in the patch, are
> necessary.
Consider them gone.
>
> Giuseppe> + /* pattern is made of less bytes than count:
> Giuseppe> + repeat pattern to fill memory. */
> Giuseppe> + data = xmalloc (count/len);
>
> This allocates count/len bytes...
>
> Giuseppe> + steps = count/len;
> Giuseppe> + for (j = 0; j < steps; j++)
> Giuseppe> + {
> Giuseppe> + for (i = 0; i < len; ++i)
> Giuseppe> + {
> Giuseppe> + int x;
> Giuseppe> + sscanf (cdata + i * 2, "%02x", &x);
> Giuseppe> + data[i + j * len] = (gdb_byte)x;
>
> ... but writes 'count' bytes.
you're right; I was supposed to allocate 'count' bytes.
Incidentally, there's a worse error there:
is that I'm counting the cycles basing on the result of an integer
division, hence not taking into account the spare bytes!
I'll fix that too...
Giuseppe