From: Nicolas Schodet Date: Tue, 12 Feb 2013 18:38:46 +0000 (+0100) Subject: Fix byte count when doing unaligned memory read, fix issue #127 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=44445dd7b0f557bb9ff2fe22e0da17b03560c673;p=fw%2Fstlink Fix byte count when doing unaligned memory read, fix issue #127 - when start is adjusted, count should also be adjusted, - then, count is rounded to the next multiple of word size. --- diff --git a/gdbserver/gdb-server.c b/gdbserver/gdb-server.c index 1b5fc84..f92fc05 100644 --- a/gdbserver/gdb-server.c +++ b/gdbserver/gdb-server.c @@ -1056,9 +1056,9 @@ start_again: unsigned count = strtoul(s_count, NULL, 16); unsigned adj_start = start % 4; + unsigned count_rnd = (count + adj_start + 4 - 1) / 4 * 4; - stlink_read_mem32(sl, start - adj_start, (count % 4 == 0) ? - count : count + 4 - (count % 4)); + stlink_read_mem32(sl, start - adj_start, count_rnd); reply = calloc(count * 2 + 1, 1); for(unsigned int i = 0; i < count; i++) {