This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 19/19] read/write_pieced_value: Merge into one function
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 12 Jun 2017 14:57:13 +0100
- Subject: Re: [PATCH v2 19/19] read/write_pieced_value: Merge into one function
- Authentication-results: sourceware.org; auth=none
- References: <1494352015-10465-1-git-send-email-arnez@linux.vnet.ibm.com> <1494352015-10465-20-git-send-email-arnez@linux.vnet.ibm.com>
Andreas Arnez <arnez@linux.vnet.ibm.com> writes:
> + if (from == NULL)
> + {
> + /* Read mode. */
> + read_value_memory (v, offset,
> + p->v.mem.in_stack_memory,
> + p->v.mem.addr + bits_to_skip / 8,
> + buffer.data (), this_size);
> + copy_bitwise (v_contents, offset,
> + buffer.data (), bits_to_skip % 8,
> + this_size_bits, bits_big_endian);
> + break;
> + }
> +
> + /* Write mode. */
I feel it is more clear to add "else" here, like
if (from == NULL)
{
/* Read mode. */
}
else
{
/* Write mode. */
}
then, we don't need the "break" above.
> + if (bits_to_skip % 8 != 0 || this_size_bits % 8 != 0)
> + {
> + if (this_size <= 8)
> + {
> + /* Perform a single read for small sizes. */
> + read_memory (start_addr, buffer.data (), this_size);
> + }
> + else
> + {
> + /* Only the first and last bytes can possibly have any
> + bits reused. */
> + read_memory (start_addr, buffer.data (), 1);
> + read_memory (start_addr + this_size - 1,
> + &buffer[this_size - 1], 1);
> + }
> + }
> +
> + copy_bitwise (buffer.data (), bits_to_skip % 8,
> + from_contents, offset,
> + this_size_bits, bits_big_endian);
> + write_memory_with_notification (start_addr, buffer.data (),
> + this_size);
> + }
> break;
Otherwise, the patch is good to me.
--
Yao (齐尧)