riscv-openocd/src/rtos
Bohdan Tymkiv eea508d9af gdb_server: fix GDB_BUFFER_SIZE usage, fix unaligned access during bulk transfers
Currently size of the GDB buffer is 16384 bytes but it is treated as
nul-terminated string in most of the code, so effective size of the
buffer is actually 16383 bytes. OpenOCD responds with `PacketSize=3fff`
to qSupported request. Result of GDB's `m` command is encoded in hex so
each data byte uses two bytes in the buffer. As a result GDB will split
bulk read requests into chunks 0x1fff bytes each. This causes troubles
on targets (or memory regions) which support only aligned, word-sized
access (such as MMIO buffers).

Steps to reproduce (psoc6 target):
gdb> dump binary memory dump.bin 0x040320000 (0x040320000 + 65536)

OpenOCD:
Error: Failed to read memory at 0x40321ffe
Error: Failed to read memory at 0x40321000
Error: Failed to read memory at 0x40323000
Error: Failed to read memory at 0x40325ffe
Error: Failed to read memory at 0x40329ffa
Error: Failed to read memory at 0x40329ffc
Error: Failed to read memory at 0x4032bffc
Error: Failed to read memory at 0x4032dffa

Consolidate GDB_BUFFER_SIZE usage: ensure size of each buffer is
(GDB_BUFFER_SIZE + 1), add explicit comment that additional byte is used
for nul-termination. Report correct size of the buffer to GDB (0x4000)
as recommended in GDB's docummentation: `if the stub stores packets in a
NUL-terminated format, it should allow an extra byte in its buffer for
the NUL`

Checked with clang-asan, clang-analyzer, valgrind - no new errors.

Change-Id: I909e8a2c6b010c5d4a304641808d4a807a4ec18d
Signed-off-by: Bohdan Tymkiv <bhdt@cypress.com>
Reviewed-on: http://openocd.zylin.com/5109
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-06-04 21:37:41 +01:00
..
ChibiOS.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
FreeRTOS.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
Makefile.am rtos/hwthread: add hardware-thread pseudo rtos 2019-03-08 12:54:47 +00:00
ThreadX.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
chromium-ec.c rtos: Add RTOS task awareness for Chromium-EC 2019-01-23 15:27:01 +00:00
eCos.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
embKernel.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
hwthread.c rtos/hwthread: add hardware-thread pseudo rtos 2019-03-08 12:54:47 +00:00
linux.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
linux_header.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
mqx.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
nuttx.c gdb_server: fix GDB_BUFFER_SIZE usage, fix unaligned access during bulk transfers 2019-06-04 21:37:41 +01:00
nuttx_header.h rtos: add support for NuttX 2018-08-01 14:33:50 +01:00
rtos.c gdb_server: fix GDB_BUFFER_SIZE usage, fix unaligned access during bulk transfers 2019-06-04 21:37:41 +01:00
rtos.h rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
rtos_chibios_stackings.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
rtos_chibios_stackings.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
rtos_ecos_stackings.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
rtos_ecos_stackings.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
rtos_embkernel_stackings.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
rtos_embkernel_stackings.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
rtos_mqx_stackings.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
rtos_mqx_stackings.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
rtos_standard_stackings.c rtos: support gdb_get_register_packet 2018-10-16 11:58:03 +01:00
rtos_standard_stackings.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
rtos_ucos_iii_stackings.c esirisc: support eSi-RISC targets 2018-10-16 11:58:24 +01:00
rtos_ucos_iii_stackings.h esirisc: support eSi-RISC targets 2018-10-16 11:58:24 +01:00
uCOS-III.c rtos: check symbol list when updating uCOS-III 2018-10-16 11:59:11 +01:00