arm-elf semihosting stdin problem

Thomas Rauscher trauscher@loytec.com
Thu Dec 23 14:44:00 GMT 2004


Hi,

I think I've found a small problem in rdi-share/hsys.c
when reading from a TTY using CL_Read.

For TTYs fgets() is called instead of fread().
This is usually not a problem, but if it happens that
the target tries to read a single character, no character
is read at all, because fgets() reads at most 'len'
characters minus 1 to be able to store the terminating zero.

I'm not sure whether the current behavior is intended, so
I wanted to ask if this is also a problem for others.

A quick solution would be to malloc one surplus byte and to 
call fgets with len+1. For a clean solution the 
HandleSysMessage() would need some rearrangement because
the buffer is allocated before the handle is checked with
isatty().

Thanks for any answers,
Thomas Rauscher.



More information about the Gdb mailing list