linux-user: fix print_syscall_err() when syscall returned value is negative
commit42b16184d016d48d167229a1ddb89b3671c77440
authorLaurent Vivier <laurent@vivier.eu>
Wed, 8 Jul 2020 15:24:35 +0000 (8 17:24 +0200)
committerLaurent Vivier <laurent@vivier.eu>
Tue, 14 Jul 2020 07:29:14 +0000 (14 09:29 +0200)
tree84d84732eb3f0ad9ad1fee2ca345aafe694ccdf2
parent6733d57035d1c4a67070b8d737334c28e5c63bc6
linux-user: fix print_syscall_err() when syscall returned value is negative

print_syscall_err() relies on the sign of the returned value to know
if it is an errno value or not.

But in some cases the returned value can have the most signicant bit
set without being an errno.

This patch restores previous behaviour that was also checking if
we can decode the errno to validate it.

This patch fixes this kind of problem (qemu-m68k):

  root@sid:/# QEMU_STRACE= ls
  3 brk(NULL) = -1 errno=21473607683 uname(0x407fff8a) = 0

to become:

  root@sid:/# QEMU_STRACE= ls
  3 brk(NULL) = 0x8001e000
  3 uname(0xffffdf8a) = 0

Fixes: c84be71f6854 ("linux-user: Extend strace support to enable argument printing after syscall execution")
Cc: Filip.Bozuta@syrmia.com
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200708152435.706070-3-laurent@vivier.eu>
linux-user/strace.c