From 44445dd7b0f557bb9ff2fe22e0da17b03560c673 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 12 Feb 2013 19:38:46 +0100 Subject: [PATCH] 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. --- gdbserver/gdb-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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++) { -- 2.30.2