浏览代码

linux-user/strace.c: Correct errno printing for mmap etc

Correct the printing of errnos for syscalls which are handled
via print_syscall_ret_addr (mmap, mmap2, brk, shmat): errnos
are returned as negative returned values at this level, not
via the host 'errno' variable.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Peter Maydell 13 年之前
父节点
当前提交
2a7e12455c
共有 1 个文件被更改,包括 4 次插入5 次删除
  1. 4 5
      linux-user/strace.c

+ 4 - 5
linux-user/strace.c

@@ -1,5 +1,4 @@
 #include <stdio.h>
 #include <stdio.h>
-#include <errno.h>
 #include <sys/ipc.h>
 #include <sys/ipc.h>
 #include <sys/msg.h>
 #include <sys/msg.h>
 #include <sys/sem.h>
 #include <sys/sem.h>
@@ -286,11 +285,11 @@ print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
 {
 {
     char *errstr = NULL;
     char *errstr = NULL;
 
 
-    if (ret == -1) {
-        errstr = target_strerror(errno);
+    if (ret < 0) {
+        errstr = target_strerror(-ret);
     }
     }
-    if ((ret == -1) && errstr) {
-        gemu_log(" = -1 errno=%d (%s)\n", errno, errstr);
+    if (errstr) {
+        gemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr);
     } else {
     } else {
         gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
         gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
     }
     }