diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2019-10-17 18:02:38 +0200 |
---|---|---|
committer | Tomas Vanek <vanekt@fbl.cz> | 2019-12-19 20:40:55 +0000 |
commit | f476c9eec42d551bc9015089abc47b09058f06b5 (patch) | |
tree | 056c3de8713f1a3e4146d7b2d93657735812a169 /tcl | |
parent | 104a5cbef8965d47b9111f7e010f96ebb5fdf06c (diff) | |
download | riscv-openocd-f476c9eec42d551bc9015089abc47b09058f06b5.zip riscv-openocd-f476c9eec42d551bc9015089abc47b09058f06b5.tar.gz riscv-openocd-f476c9eec42d551bc9015089abc47b09058f06b5.tar.bz2 |
gdb_server: fix string length with semihosting_fileio
The GDB file-I/O remote protocol extension, used for implementing
the semihosting file I/O, requires the length of strings to
include the trailing zero character, as explicitly stated inside a
comment in GDB source code [1]:
/* 1. Parameter: Ptr to pathname / length incl. trailing zero. */
ARM specification for semihosting [2] requires the string length
to not include the trailing zero character, e.g. in SYS_OPEN
specifications:
"field 3: An integer that gives the length of the string
pointed to by field 1. The length does not include the
terminating null character that must be present."
The mismatch above requires OpenOCD to add "one" to the string
length before passing it to GDB. Such conversion is missing
either in the generic semihosting provider of the data, the
function semihosting_common(), and in the consumer of the data,
the gdb_server function gdb_fileio_reply().
The conversion is already implemented in the target specific
function nds32_get_gdb_fileio_info(), but it's not the preferred
place for such GDB specific requirement.
This issue affects the semihosting calls "open", "unlink",
"rename" and "system".
Remove the "+1" conversion from nds32_get_gdb_fileio_info().
Add the "+1" conversion in gdb_fileio_reply().
[1] http://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;f=gdb/remote-fileio.c;h=11c141e42c4d#l381
[2] "Semihosting for AArch32 and AArch64, Release 2.0"
https://static.docs.arm.com/100863/0200/semihosting.pdf
Change-Id: I35461bcb30f734fe2d51f7f0d418e3d04b4af506
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5322
Tested-by: jenkins
Reviewed-by: Steven Stallion <sstallion@gmail.com>
Reviewed-by: Muhammad Omair Javaid <omair.javaid@linaro.org>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Diffstat (limited to 'tcl')
0 files changed, 0 insertions, 0 deletions