Re: [PATCH] enhancement of mi_cmd_data_write_memory_bytes for filling memory regions (was [PATCH] new MI command for pattern filling of memory regions)

Tom Tromey
2012-09-14T16:30:59Z

>>>>> "Giuseppe" == Giuseppe MONTALTO <giuseppe.montalto@st.com> writes:

Giuseppe> New version of the patch.

I'm sorry about the delay on this.

I know it feels uncomfortable, but it really is good to ping patches --
say every week or so. Otherwise they tend to slide off the radar.

Giuseppe> + int len, r, i, steps, reminder;
Giuseppe> + long int count, j;

I think now size_t is preferred. (This changed since your patch
submission.)

Typo: should be "remainder", not "reminder".

Giuseppe> + count = strtol (argv[2], NULL, 10);

I think strtoul instead.

Giuseppe> + if (len < count)
Giuseppe> + {
Giuseppe> + /* pattern is made of less bytes than count:
Giuseppe> + repeat pattern to fill memory. */

Comments should start with an uppercase letter.

Giuseppe> + else
Giuseppe> + {
Giuseppe> + /* pattern is longer than (or equal to) count:
Giuseppe> + just copy len bytes. */

Likewise.

Giuseppe> + xfree (databuf);

It seems like you could do less work for the usual case where len==count.
That is, avoid the extra malloc and memcpy.

Giuseppe> +set testfile "mi-read-memory"
Giuseppe> +set srcfile ${testfile}.c
Giuseppe> +set binfile ${objdir}/${subdir}/${testfile}

Use standard_testfile now.

Giuseppe> +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
Giuseppe> + untested mi-read-memory.exp

Use build_executable instead and don't call untested.

Giuseppe> +return 0

No need for a return at the end of a .exp file.

Tom