binutils-gdb/sim
Andrew Burgess c5ebe0ff70 sim: Don't overwrite stored errno in sim_syscall_multi
The host syscall callback mechanism should take care of updating the
errcode within the CB_SYSCALL struct, and we should not be adjusting
the error code once the syscall has completed.  We especially, should
not be rewriting the syscall errcode based on the value of errno some
time after running the host syscall, as there is no guarantee that
errno has not be overwritten.

To perform a syscall we call cb_syscall (in syscall.c).  To return
from cb_syscall control passes through one of two exit paths these are
labeled FinishSyscall and ErrorFinish and are reached using goto
statements scattered throughout the cb_syscall function.

In FinishSyscall we store the syscall result in 'sc->result', and the
error code is transated to target encoding, and stored in
'sc->errcode'.

In ErrorFinish, we again store the syscall result in 'sc->result', and
fill in 'sc->errcode' by fetching the actual errno from the host with
the 'cb->get_errno' callback.

In both cases 'sc->errcode' will have been filled in with an
appropriate value.

Further, if we look at a specific syscall example, CB_SYS_open, in
this case the first thing we do is fetch the path to open from the
target with 'get_path', if this fails then the errcode is returned,
and we jump to FinishSyscall.  Notice that in this case, no host
syscall may have been performed, for example a failure to read the
path to open out of simulated memory can return EINVAL without
performing any host syscall.  Given that no host syscall has been
performed, reading the host errno makes absolutely no sense.

This commit removes from sim_syscall_multi the rewriting of
sc->errcode based on the value of errno, and instead relies on the
value stored in the cb_syscall.

sim/common/ChangeLog:

	* sim-syscall.c (sim_syscall_multi): Don't update sc->errcode at
	this point, it should have already been set in cb_syscall.
2018-12-18 00:02:01 +00:00
..
aarch64 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
arm Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
avr Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
bfin Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
common sim: Don't overwrite stored errno in sim_syscall_multi 2018-12-18 00:02:01 +00:00
cr16 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
cris sim/cris: Fix references to cgen cpu directory 2018-12-06 12:21:11 +00:00
d10v Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
erc32 [src/erc32] Use ncurses instead of termcap on Cygwin too 2018-10-30 16:41:12 +00:00
frv sim/opcodes: Allow use of out of tree cgen source directory 2018-12-06 12:21:10 +00:00
ft32 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
h8300 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
igen Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
iq2000 sim/opcodes: Allow use of out of tree cgen source directory 2018-12-06 12:21:10 +00:00
lm32 sim/opcodes: Allow use of out of tree cgen source directory 2018-12-06 12:21:10 +00:00
m32c Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
m32r sim/opcodes: Allow use of out of tree cgen source directory 2018-12-06 12:21:10 +00:00
m68hc11 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
mcore Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
microblaze Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
mips Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
mn10300 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
moxie Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
msp430 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
or1k sim/opcodes: Allow use of out of tree cgen source directory 2018-12-06 12:21:10 +00:00
ppc Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
rl78 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
rx Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
sh Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
sh64 sim/opcodes: Allow use of out of tree cgen source directory 2018-12-06 12:21:10 +00:00
testsuite or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns 2018-10-05 11:41:42 +09:00
v850 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
.gitignore sim: drop common/cconfig.h in favor of a single config.h 2016-01-09 03:52:30 -05:00
ChangeLog sim/opcodes: Allow use of out of tree cgen source directory 2018-12-06 12:21:10 +00:00
MAINTAINERS Update my e-mail address, limit maintenance to MIPS I-IV ISAs 2018-07-21 00:14:01 +01:00
Makefile.in Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
README-HACKING sim: punt WITH_DEVICES & tconfig.h support 2015-12-26 20:38:31 -05:00
configure Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
configure.ac Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
configure.tgt sim: or1k: add or1k target to sim 2017-12-12 23:44:14 +09:00