[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 22/23] bsd-user: add more strace formating
From: |
Stacey Son |
Subject: |
[Qemu-devel] [PATCH 22/23] bsd-user: add more strace formating |
Date: |
Sun, 23 Jun 2013 21:03:54 -0500 |
This change add more strace formating for popular system calls. It also
separates out *BSD and architecture dependent code. In addition, it
changes TARGET_OS in configure (and in the associated makefiles) to
what it should really be: HOST_OS.
Signed-off-by: Stacey Son <address@hidden>
---
Makefile.target | 4 +-
bsd-user/Makefile.objs | 10 +-
bsd-user/freebsd/os-strace.h | 29 ++++++
bsd-user/freebsd/strace.list | 58 ++++++++++--
bsd-user/i386/target_arch_sysarch.h | 11 ++-
bsd-user/mips/target_arch_sysarch.h | 21 ++++-
bsd-user/mips64/target_arch_sysarch.h | 19 ++++
bsd-user/netbsd/os-strace.h | 1 +
bsd-user/openbsd/os-strace.h | 1 +
bsd-user/qemu.h | 10 ++
bsd-user/sparc/target_arch_sysarch.h | 11 ++-
bsd-user/sparc64/target_arch_sysarch.h | 11 ++-
bsd-user/strace.c | 158 ++++++++++++++++++++------------
bsd-user/x86_64/target_arch_sysarch.h | 11 ++-
configure | 18 ++--
15 files changed, 290 insertions(+), 83 deletions(-)
create mode 100644 bsd-user/freebsd/os-strace.h
create mode 100644 bsd-user/netbsd/os-strace.h
create mode 100644 bsd-user/openbsd/os-strace.h
diff --git a/Makefile.target b/Makefile.target
index e67e2bd..ef52ee4 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -103,8 +103,8 @@ endif #CONFIG_LINUX_USER
ifdef CONFIG_BSD_USER
-QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH) \
- -I$(SRC_PATH)/bsd-user/$(TARGET_OS)
+QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) \
+ -I$(SRC_PATH)/bsd-user/$(HOST_ABI_DIR)
obj-y += bsd-user/
obj-y += gdbstub.o thunk.o user-exec.o
diff --git a/bsd-user/Makefile.objs b/bsd-user/Makefile.objs
index 5308e29..06a3026 100644
--- a/bsd-user/Makefile.objs
+++ b/bsd-user/Makefile.objs
@@ -1,5 +1,7 @@
obj-y = main.o bsdload.o elfload.o ioctl.o mmap.o signal.o strace.o syscall.o \
- uaccess.o bsd-mem.o bsd-proc.o $(TARGET_OS)/os-time.o \
- $(TARGET_OS)/os-proc.o bsd-socket.o
$(TARGET_OS)/os-socket.o \
- $(TARGET_OS)/os-stat.o $(TARGET_OS)/os-sys.o \
- $(TARGET_OS)/os-thread.o $(TARGET_OS)/os-extattr.o
bsd-misc.o
+ uaccess.o bsd-mem.o bsd-misc.o bsd-proc.o bsd-socket.o \
+ $(HOST_ABI_DIR)/os-extattr.o $(HOST_ABI_DIR)/os-proc.o \
+ $(HOST_ABI_DIR)/os-socket.o $(HOST_ABI_DIR)/os-stat.o \
+ $(HOST_ABI_DIR)/os-sys.o $(HOST_ABI_DIR)/os-thread.o \
+ $(HOST_ABI_DIR)/os-time.o
+
diff --git a/bsd-user/freebsd/os-strace.h b/bsd-user/freebsd/os-strace.h
new file mode 100644
index 0000000..a222f09
--- /dev/null
+++ b/bsd-user/freebsd/os-strace.h
@@ -0,0 +1,29 @@
+/*
+ * FreeBSD dependent strace print functions
+ *
+ * Copyright (c) 2013 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "target_arch_sysarch.h" /* architecture dependent functions */
+
+
+static inline void do_os_print_sysarch(const struct syscallname *name,
+ abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4,
+ abi_long arg5, abi_long arg6)
+{
+ /* This is arch dependent */
+ do_freebsd_arch_print_sysarch(name, arg1, arg2, arg3, arg4, arg5, arg6);
+}
diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
index 3e793cb..ae2a4a3 100644
--- a/bsd-user/freebsd/strace.list
+++ b/bsd-user/freebsd/strace.list
@@ -16,10 +16,23 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+{ TARGET_FREEBSD_NR___acl_aclcheck_fd, "__acl_get_fd", "%s(%d, %d, %#x)",
NULL, NULL },
+{ TARGET_FREEBSD_NR___acl_aclcheck_file, "__acl_get_file", "%s(\"%s\", %d,
%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR___acl_aclcheck_link, "__acl_get_link", "%s(\"%s\", %d,
%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR___acl_delete_fd, "__acl_delete_fd", "%s(%d, %d)", NULL,
NULL },
+{ TARGET_FREEBSD_NR___acl_delete_file, "__acl_delete_file", "%s(\"%s\", %d)",
NULL, NULL },
+{ TARGET_FREEBSD_NR___acl_delete_link, "__acl_delete_link", "%s(\"%s\", %d)",
NULL, NULL },
+{ TARGET_FREEBSD_NR___acl_get_fd, "__acl_get_fd", "%s(\"%s\", %d, %#x)", NULL,
NULL },
+{ TARGET_FREEBSD_NR___acl_get_file, "__acl_get_file", "%s(\"%s\", %d, %#x)",
NULL, NULL },
+{ TARGET_FREEBSD_NR___acl_get_link, "__acl_get_link", "%s(\"%s\", %d, %#x)",
NULL, NULL },
+{ TARGET_FREEBSD_NR___acl_set_fd, "__acl_get_fd", "%s(\"%s\", %d, %#x)", NULL,
NULL },
+{ TARGET_FREEBSD_NR___acl_set_file, "__acl_get_file", "%s(\"%s\", %d, %#x)",
NULL, NULL },
+{ TARGET_FREEBSD_NR___acl_set_link, "__acl_get_link", "%s(\"%s\", %d, %#x)",
NULL, NULL },
{ TARGET_FREEBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR___semctl, "__semctl", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR___sysctl, "__sysctl", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR___sysctl, "__sysctl", NULL, print_sysctl, NULL },
+{ TARGET_FREEBSD_NR__umtx_op, "_umtx_op", "%s(%#x, %d, %d, %#x, %#x)", NULL,
NULL },
{ TARGET_FREEBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL },
{ TARGET_FREEBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_acct, "acct", NULL, NULL, NULL },
@@ -38,24 +51,41 @@
{ TARGET_FREEBSD_NR_connect, "connect", "%s(%d,%#x,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_dup, "dup", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_dup2, "dup2", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_eaccess, "eaccess", "%s(%s,%#x)", NULL, NULL },
{ TARGET_FREEBSD_NR_execve, "execve", NULL, print_execve, NULL },
{ TARGET_FREEBSD_NR_exit, "exit", "%s(%d)\n", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattrctl, "extattrctl", "%s(\"%s\", %d, \"%s\", %d,
\"%s\"", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_delete_fd, "extattr_delete_fd", "%s(%d, %d,
\"%s\")", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_delete_file, "extattr_delete_file", "%s(\"%s\",
%d, \"%s\")", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_delete_link, "extattr_delete_link", "%s(\"%s\",
%d, \"%s\")", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_get_fd, "extattr_get_fd", "%s(%d, %d, \"%s\", %#x,
%d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_get_file, "extattr_get_file", "%s(\"%s\", %d,
\"%s\", %#x, %d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_get_file, "extattr_get_link", "%s(\"%s\", %d,
\"%s\", %#x, %d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_list_fd, "extattr_list_fd", "%s(%d, %d, %#x, %d)",
NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_list_file, "extattr_list_file", "%s(\"%s\", %#x,
%d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_list_link, "extattr_list_link", "%s(\"%s\", %d,
%#x, %d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_set_fd, "extattr_set_fd", "%s(%d, %d, \"%s\", %#x,
%d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_set_file, "extattr_set_file", "%s(\"%s\", %d,
\"%s\", %#x, %d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_extattr_set_link, "extattr_set_link", "%s(\"%s\", %d,
\"%s\", %#x, %d)", NULL, NULL },
{ TARGET_FREEBSD_NR_fchdir, "fchdir", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fchflags, "fchflags", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fchmod, "fchmod", "%s(%d,%#o)", NULL, NULL },
-{ TARGET_FREEBSD_NR_fchown, "fchown", "%s(\"%s\",%d,%d)", NULL, NULL },
+{ TARGET_FREEBSD_NR_fchown, "fchown", "%s(%d,%d,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_fcntl, "fcntl", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_fexecve, "fexecve", NULL, print_execve, NULL },
{ TARGET_FREEBSD_NR_fhopen, "fhopen", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fhstat, "fhstat", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fhstatfs, "fhstatfs", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_flock, "flock", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_fork, "fork", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_fpathconf, "fpathconf", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_fstat, "fstat", "%s(%d,%p)", NULL, NULL },
-{ TARGET_FREEBSD_NR_fstatfs, "fstatfs", "%s(%d,%p)", NULL, NULL },
+{ TARGET_FREEBSD_NR_fstat, "fstat", "%s(%d,%#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR_fstatat, "fstatat", "%s(%d,\"%s\", %#x)", NULL, NULL },
+{ TARGET_FREEBSD_NR_fstatfs, "fstatfs", "%s(%d,%#x)", NULL, NULL },
{ TARGET_FREEBSD_NR_fsync, "fsync", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_ftruncate, "ftruncate", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_futimes, "futimes", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_getcontext, "getcontext", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getdirentries, "getdirentries", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_freebsd6_mmap, "freebsd6_mmap", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getegid, "getegid", "%s()", NULL, NULL },
@@ -81,7 +111,7 @@
{ TARGET_FREEBSD_NR_getsockopt, "getsockopt", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_gettimeofday, "gettimeofday", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getuid, "getuid", "%s()", NULL, NULL },
-{ TARGET_FREEBSD_NR_ioctl, "ioctl", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_ioctl, "ioctl", NULL, print_ioctl, NULL },
{ TARGET_FREEBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL },
{ TARGET_FREEBSD_NR_kevent, "kevent", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_kill, "kill", NULL, NULL, NULL },
@@ -90,6 +120,7 @@
{ TARGET_FREEBSD_NR_lchown, "lchown", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_link, "link", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_FREEBSD_NR_listen, "listen", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_lpathconf, "lpathconf", "%s(\"%s\", %d)", NULL, NULL },
{ TARGET_FREEBSD_NR_lseek, "lseek", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_lstat, "lstat", "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_FREEBSD_NR_madvise, "madvise", NULL, NULL, NULL },
@@ -114,7 +145,9 @@
{ TARGET_FREEBSD_NR_nanosleep, "nanosleep", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_nfssvc, "nfssvc", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_open, "open", "%s(\"%s\",%#x,%#o)", NULL, NULL },
+{ TARGET_FREEBSD_NR_openat, "openat", "%s(%d, \"%s\",%#x,%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_pathconf, "pathconf", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_pathconf, "pathconf", "%s(\"%s\", %d)", NULL, NULL },
{ TARGET_FREEBSD_NR_pipe, "pipe", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_poll, "poll", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_pread, "pread", NULL, NULL, NULL },
@@ -134,6 +167,7 @@
{ TARGET_FREEBSD_NR_revoke, "revoke", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_rfork, "rfork", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_rmdir, "rmdir", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_rtprio_thread, "rtprio_thread", "%s(%d, %d, %p)", NULL,
NULL },
{ TARGET_FREEBSD_NR_sbrk, "sbrk", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_select, "select", NULL, NULL, NULL },
@@ -141,6 +175,7 @@
{ TARGET_FREEBSD_NR_semop, "semop", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sendmsg, "sendmsg", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sendto, "sendto", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_setcontext, "setcontext", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setegid, "setegid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_seteuid, "seteuid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setgid, "setgid", NULL, NULL, NULL },
@@ -169,15 +204,24 @@
{ TARGET_FREEBSD_NR_sigprocmask, "sigprocmask", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sigreturn, "sigreturn", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sigsuspend, "sigsuspend", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_socket, "socket", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_socket, "socket", "%s(%d,%d,%d)", NULL, NULL },
{ TARGET_FREEBSD_NR_socketpair, "socketpair", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sstk, "sstk", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_stat, "stat", "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_FREEBSD_NR_statfs, "statfs", "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_FREEBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_FREEBSD_NR_sync, "sync", NULL, NULL, NULL },
-{ TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, print_sysarch, NULL },
{ TARGET_FREEBSD_NR_syscall, "syscall", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_create, "thr_create", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_exit, "thr_exit", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_kill, "thr_kill", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_kill2, "thr_kill2", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_new, "thr_new", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_self, "thr_self", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_set_name, "thr_set_name", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_suspend, "thr_suspend", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_wake, "thr_wake", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_truncate, "truncate", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_umask, "umask", "%s(%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_unlink, "unlink", "%s(\"%s\")", NULL, NULL },
diff --git a/bsd-user/i386/target_arch_sysarch.h
b/bsd-user/i386/target_arch_sysarch.h
index 373c838..4fa6698 100644
--- a/bsd-user/i386/target_arch_sysarch.h
+++ b/bsd-user/i386/target_arch_sysarch.h
@@ -22,7 +22,7 @@
#include "syscall.h"
-static abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
+static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
abi_ulong parms)
{
abi_long ret = 0;
@@ -65,5 +65,14 @@ static abi_long do_freebsd_arch_sysarch(CPUX86State *env,
int op,
return ret;
}
+static inline void do_freebsd_arch_print_sysarch(
+ const struct syscallname *name, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+ gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+ TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
#endif /* !__ARCH_SYSARCH_H_ */
diff --git a/bsd-user/mips/target_arch_sysarch.h
b/bsd-user/mips/target_arch_sysarch.h
index 22fa53a..842b29a 100644
--- a/bsd-user/mips/target_arch_sysarch.h
+++ b/bsd-user/mips/target_arch_sysarch.h
@@ -22,7 +22,7 @@
#include "syscall.h"
-static abi_long do_freebsd_arch_sysarch(CPUMIPSState *env, int op,
+static inline abi_long do_freebsd_arch_sysarch(CPUMIPSState *env, int op,
abi_ulong parms)
{
int ret = 0;
@@ -47,4 +47,23 @@ static abi_long do_freebsd_arch_sysarch(CPUMIPSState *env,
int op,
return ret;
}
+static inline void do_freebsd_arch_print_sysarch(
+ const struct syscallname *name, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+ switch (arg1) {
+ case TARGET_MIPS_SET_TLS:
+ gemu_log("%s(SET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+ break;
+
+ case TARGET_MIPS_GET_TLS:
+ gemu_log("%s(GET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+ break;
+
+ default:
+ gemu_log("UNKNOWN OP: %d, " TARGET_ABI_FMT_lx ")", (int)arg1, arg2);
+ }
+}
+
#endif /*!__ARCH_SYSARCH_H_ */
diff --git a/bsd-user/mips64/target_arch_sysarch.h
b/bsd-user/mips64/target_arch_sysarch.h
index 503bc90..6210366 100644
--- a/bsd-user/mips64/target_arch_sysarch.h
+++ b/bsd-user/mips64/target_arch_sysarch.h
@@ -47,4 +47,23 @@ static inline abi_long do_freebsd_arch_sysarch(CPUMIPSState
*env, int op,
return ret;
}
+static inline void do_freebsd_arch_print_sysarch(
+ const struct syscallname *name, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+ switch (arg1) {
+ case TARGET_MIPS_SET_TLS:
+ gemu_log("%s(SET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+ break;
+
+ case TARGET_MIPS_GET_TLS:
+ gemu_log("%s(GET_TLS, 0x" TARGET_ABI_FMT_lx ")", name->name, arg2);
+ break;
+
+ default:
+ gemu_log("UNKNOWN OP: %d, " TARGET_ABI_FMT_lx ")", (int)arg1, arg2);
+ }
+}
+
#endif /*!__ARCH_SYSARCH_H_ */
diff --git a/bsd-user/netbsd/os-strace.h b/bsd-user/netbsd/os-strace.h
new file mode 100644
index 0000000..70cf51d
--- /dev/null
+++ b/bsd-user/netbsd/os-strace.h
@@ -0,0 +1 @@
+/* XXX NetBSD dependent strace print functions */
diff --git a/bsd-user/openbsd/os-strace.h b/bsd-user/openbsd/os-strace.h
new file mode 100644
index 0000000..9161390
--- /dev/null
+++ b/bsd-user/openbsd/os-strace.h
@@ -0,0 +1 @@
+/* XXX OpenBSD dependent strace print functions */
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 2ddf244..3967e22 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -173,6 +173,16 @@ void fork_end(int child);
#include "qemu/log.h"
/* strace.c */
+struct syscallname {
+ int nr;
+ const char *name;
+ const char *format;
+ void (*call)(const struct syscallname *,
+ abi_long, abi_long, abi_long,
+ abi_long, abi_long, abi_long);
+ void (*result)(const struct syscallname *, abi_long);
+};
+
void
print_freebsd_syscall(int num,
abi_long arg1, abi_long arg2, abi_long arg3,
diff --git a/bsd-user/sparc/target_arch_sysarch.h
b/bsd-user/sparc/target_arch_sysarch.h
index e523798..454c084 100644
--- a/bsd-user/sparc/target_arch_sysarch.h
+++ b/bsd-user/sparc/target_arch_sysarch.h
@@ -22,7 +22,8 @@
#include "syscall.h"
-static abi_long do_freebsd_arch_sysarch(void *env, int op, abi_ulong parms)
+static inline abi_long do_freebsd_arch_sysarch(void *env, int op,
+ abi_ulong parms)
{
int ret = 0;
@@ -39,5 +40,13 @@ static abi_long do_freebsd_arch_sysarch(void *env, int op,
abi_ulong parms)
return ret;
}
+static inline void do_freebsd_arch_print_sysarch(
+ const struct syscallname *name, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+ gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+ TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
#endif /*!__ARCH_SYSARCH_H_ */
diff --git a/bsd-user/sparc64/target_arch_sysarch.h
b/bsd-user/sparc64/target_arch_sysarch.h
index c18f699..84e1339 100644
--- a/bsd-user/sparc64/target_arch_sysarch.h
+++ b/bsd-user/sparc64/target_arch_sysarch.h
@@ -22,7 +22,8 @@
#include "syscall.h"
-static abi_long do_freebsd_arch_sysarch(void *env, int op, abi_ulong parms)
+static inline abi_long do_freebsd_arch_sysarch(void *env, int op,
+ abi_ulong parms)
{
int ret = 0;
@@ -39,5 +40,13 @@ static abi_long do_freebsd_arch_sysarch(void *env, int op,
abi_ulong parms)
return ret;
}
+static inline void do_freebsd_arch_print_sysarch(
+ const struct syscallname *name, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+ gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+ TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
#endif /*!__ARCH_SYSARCH_H_ */
diff --git a/bsd-user/strace.c b/bsd-user/strace.c
index 7a28c96..60aabc3 100644
--- a/bsd-user/strace.c
+++ b/bsd-user/strace.c
@@ -15,40 +15,59 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+
#include <stdio.h>
#include <errno.h>
#include <sys/select.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>
+#include <sys/ioccom.h>
+#include <ctype.h>
+
#include "qemu.h"
-int do_strace=0;
+#include "os-strace.h" /* OS dependent strace print functions */
-struct syscallname {
- int nr;
- const char *name;
- const char *format;
- void (*call)(const struct syscallname *,
- abi_long, abi_long, abi_long,
- abi_long, abi_long, abi_long);
- void (*result)(const struct syscallname *, abi_long);
-};
+int do_strace;
/*
* Utility functions
*/
-static void
-print_execve(const struct syscallname *name,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
+static void print_sysctl(const struct syscallname *name, abi_long arg1,
+ abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5,
+ abi_long arg6)
+{
+ uint32_t i;
+ int32_t *namep;
+
+ gemu_log("%s({ ", name->name);
+ namep = lock_user(VERIFY_READ, arg1, sizeof(int32_t) * arg2, 1);
+ if (namep) {
+ int32_t *p = namep;
+
+ for (i = 0; i < (uint32_t)arg2; i++) {
+ gemu_log("%d ", tswap32(*p++));
+ }
+ unlock_user(namep, arg1, 0);
+ }
+ gemu_log("}, %u, 0x" TARGET_ABI_FMT_lx ", 0x" TARGET_ABI_FMT_lx ", 0x"
+ TARGET_ABI_FMT_lx ", 0x" TARGET_ABI_FMT_lx ")",
+ (uint32_t)arg2, arg3, arg4, arg5, arg6);
+}
+
+static void print_execve(const struct syscallname *name, abi_long arg1,
+ abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5,
+ abi_long arg6)
{
abi_ulong arg_ptr_addr;
char *s;
- if (!(s = lock_user_string(arg1)))
+ s = lock_user_string(arg1);
+ if (s == NULL) {
return;
+ }
gemu_log("%s(\"%s\",{", name->name, s);
unlock_user(s, arg1, 0);
@@ -56,29 +75,56 @@ print_execve(const struct syscallname *name,
abi_ulong *arg_ptr, arg_addr;
arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
- if (!arg_ptr)
+ if (!arg_ptr) {
return;
+ }
arg_addr = tswapl(*arg_ptr);
unlock_user(arg_ptr, arg_ptr_addr, 0);
- if (!arg_addr)
+ if (!arg_addr) {
break;
+ }
if ((s = lock_user_string(arg_addr))) {
gemu_log("\"%s\",", s);
unlock_user(s, arg_addr, 0);
}
}
-
gemu_log("NULL})");
}
+static void print_ioctl(const struct syscallname *name,
+ abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4,
+ abi_long arg5, abi_long arg6)
+{
+ /* Decode the ioctl request */
+ gemu_log("%s(%d, 0x%0lx { IO%s%s GRP:0x%x('%c') CMD:%d LEN:%d }, 0x"
+ TARGET_ABI_FMT_lx ", ...)",
+ name->name,
+ (int)arg1,
+ (unsigned long)arg2,
+ arg2 & IOC_OUT ? "R" : "",
+ arg2 & IOC_IN ? "W" : "",
+ (unsigned)IOCGROUP(arg2),
+ isprint(IOCGROUP(arg2)) ? (char)IOCGROUP(arg2) : '?',
+ (int)arg2 & 0xFF,
+ (int)IOCPARM_LEN(arg2),
+ arg3);
+}
+
+static void print_sysarch(const struct syscallname *name, abi_long arg1,
+ abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5,
+ abi_long arg6)
+{
+ /* This is os dependent. */
+ do_os_print_sysarch(name, arg1, arg2, arg3, arg4, arg5, arg6);
+}
+
/*
* Variants for the return value output function
*/
-static void
-print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
+static void print_syscall_ret_addr(const struct syscallname *name, abi_long
ret)
{
-if( ret == -1 ) {
+ if (ret == -1) {
gemu_log(" = -1 errno=%d (%s)\n", errno, strerror(errno));
} else {
gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
@@ -107,10 +153,9 @@ static const struct syscallname openbsd_scnames[] = {
#include "openbsd/strace.list"
};
-static void
-print_syscall(int num, const struct syscallname *scnames, unsigned int
nscnames,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
+static void print_syscall(int num, const struct syscallname *scnames,
+ unsigned int nscnames, abi_long arg1, abi_long arg2, abi_long arg3,
+ abi_long arg4, abi_long arg5, abi_long arg6)
{
unsigned int i;
const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ","
@@ -119,36 +164,37 @@ print_syscall(int num, const struct syscallname *scnames,
unsigned int nscnames,
gemu_log("%d ", getpid() );
- for (i = 0; i < nscnames; i++)
+ for (i = 0; i < nscnames; i++) {
if (scnames[i].nr == num) {
if (scnames[i].call != NULL) {
scnames[i].call(&scnames[i], arg1, arg2, arg3, arg4, arg5,
- arg6);
+ arg6);
} else {
/* XXX: this format system is broken because it uses
host types and host pointers for strings */
- if (scnames[i].format != NULL)
+ if (scnames[i].format != NULL) {
format = scnames[i].format;
- gemu_log(format, scnames[i].name, arg1, arg2, arg3, arg4,
- arg5, arg6);
+ }
+ gemu_log(format, scnames[i].name, arg1, arg2, arg3, arg4, arg5,
+ arg6);
}
return;
}
+ }
gemu_log("Unknown syscall %d\n", num);
}
-static void
-print_syscall_ret(int num, abi_long ret, const struct syscallname *scnames,
- unsigned int nscnames)
+static void print_syscall_ret(int num, abi_long ret,
+ const struct syscallname *scnames, unsigned int nscnames)
{
unsigned int i;
- for (i = 0; i < nscnames; i++)
+ for (i = 0; i < nscnames; i++) {
if (scnames[i].nr == num) {
if (scnames[i].result != NULL) {
scnames[i].result(&scnames[i], ret);
} else {
- if( ret < 0 ) {
+ if (ret < 0) {
gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", -ret,
strerror(-ret));
} else {
@@ -157,52 +203,50 @@ print_syscall_ret(int num, abi_long ret, const struct
syscallname *scnames,
}
break;
}
+ }
}
/*
* The public interface to this module.
*/
-void
-print_freebsd_syscall(int num,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
+void print_freebsd_syscall(int num, abi_long arg1, abi_long arg2, abi_long
arg3,
+ abi_long arg4, abi_long arg5, abi_long arg6)
{
- print_syscall(num, freebsd_scnames, ARRAY_SIZE(freebsd_scnames),
- arg1, arg2, arg3, arg4, arg5, arg6);
+
+ print_syscall(num, freebsd_scnames, ARRAY_SIZE(freebsd_scnames), arg1,
arg2,
+ arg3, arg4, arg5, arg6);
}
-void
-print_freebsd_syscall_ret(int num, abi_long ret)
+void print_freebsd_syscall_ret(int num, abi_long ret)
{
+
print_syscall_ret(num, ret, freebsd_scnames, ARRAY_SIZE(freebsd_scnames));
}
-void
-print_netbsd_syscall(int num,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
+void print_netbsd_syscall(int num, abi_long arg1, abi_long arg2, abi_long arg3,
+ abi_long arg4, abi_long arg5, abi_long arg6)
{
+
print_syscall(num, netbsd_scnames, ARRAY_SIZE(netbsd_scnames),
arg1, arg2, arg3, arg4, arg5, arg6);
}
-void
-print_netbsd_syscall_ret(int num, abi_long ret)
+void print_netbsd_syscall_ret(int num, abi_long ret)
{
+
print_syscall_ret(num, ret, netbsd_scnames, ARRAY_SIZE(netbsd_scnames));
}
-void
-print_openbsd_syscall(int num,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
+void print_openbsd_syscall(int num, abi_long arg1, abi_long arg2, abi_long
arg3,
+ abi_long arg4, abi_long arg5, abi_long arg6)
{
- print_syscall(num, openbsd_scnames, ARRAY_SIZE(openbsd_scnames),
- arg1, arg2, arg3, arg4, arg5, arg6);
+
+ print_syscall(num, openbsd_scnames, ARRAY_SIZE(openbsd_scnames), arg1,
arg2,
+ arg3, arg4, arg5, arg6);
}
-void
-print_openbsd_syscall_ret(int num, abi_long ret)
+void print_openbsd_syscall_ret(int num, abi_long ret)
{
+
print_syscall_ret(num, ret, openbsd_scnames, ARRAY_SIZE(openbsd_scnames));
}
diff --git a/bsd-user/x86_64/target_arch_sysarch.h
b/bsd-user/x86_64/target_arch_sysarch.h
index 52a1d18..6d09d50 100644
--- a/bsd-user/x86_64/target_arch_sysarch.h
+++ b/bsd-user/x86_64/target_arch_sysarch.h
@@ -21,7 +21,7 @@
#include "syscall.h"
-static abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
+static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
abi_ulong parms)
{
abi_long ret = 0;
@@ -64,4 +64,13 @@ static abi_long do_freebsd_arch_sysarch(CPUX86State *env,
int op,
return ret;
}
+static inline void do_freebsd_arch_print_sysarch(
+ const struct syscallname *name, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
+{
+
+ gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
+ TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
+}
+
#endif /*! __ARCH_SYSARCH_H_ */
diff --git a/configure b/configure
index 812ea3f..90167f8 100755
--- a/configure
+++ b/configure
@@ -432,7 +432,9 @@ if test -z "$ARCH"; then
fi
# OS specific
-TARGET_OS=""
+
+# host *BSD for user mode
+HOST_ABI_DIR=""
case $targetos in
CYGWIN*)
@@ -456,10 +458,10 @@ FreeBSD)
make="${MAKE-gmake}"
audio_drv_list="oss"
audio_possible_drivers="oss sdl esd pa"
- # needed for kinfo_getvmmap(3) in libutil.h
+ # -lutil needed for kinfo_getvmmap(3) in libutil.h
# -lprocstat needed for procstat_*(3) in bsd-user/main.c
LIBS="-lprocstat -lutil $LIBS"
- TARGET_OS="freebsd"
+ HOST_ABI_DIR="freebsd"
;;
DragonFly)
bsd="yes"
@@ -473,14 +475,14 @@ NetBSD)
audio_drv_list="oss"
audio_possible_drivers="oss sdl esd"
oss_lib="-lossaudio"
- TARGET_OS="netbsd"
+ HOST_ABI_DIR="netbsd"
;;
OpenBSD)
bsd="yes"
make="${MAKE-gmake}"
audio_drv_list="sdl"
audio_possible_drivers="sdl esd"
- TARGET_OS="openbsd"
+ HOST_ABI_DIR="openbsd"
;;
Darwin)
bsd="yes"
@@ -4283,15 +4285,15 @@ upper() {
target_arch_name="`upper $TARGET_ARCH`"
echo "TARGET_$target_arch_name=y" >> $config_target_mak
-if [ "$TARGET_OS" != "" ]; then
- echo "TARGET_OS=$TARGET_OS" >> $config_target_mak
-fi
echo "TARGET_NAME=$target_name" >> $config_target_mak
echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
if [ "$TARGET_ABI_DIR" = "" ]; then
TARGET_ABI_DIR=$TARGET_ARCH
fi
echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
+if [ "$HOST_ABI_DIR" != "" ]; then
+ echo "HOST_ABI_DIR=$HOST_ABI_DIR" >> $config_target_mak
+fi
case "$target_name" in
i386|x86_64)
if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
--
1.7.8
- [Qemu-devel] [PATCH 11/23] bsd-user: add shims for file related system calls, (continued)
- [Qemu-devel] [PATCH 11/23] bsd-user: add shims for file related system calls, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 10/23] bsd-user: add shims for memory management related syscalls, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 09/23] bsd-user: refresh FreeBSD's system call numbers, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 12/23] bsd-user: add shims for time related system calls., Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 03/23] bsd-user: additional seperation of OS and architecture dependent code, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 04/23] bsd-user: add bsd signal emulation, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 22/23] bsd-user: add more strace formating,
Stacey Son <=
- [Qemu-devel] [PATCH 20/23] bsd-user: add shims for extended attributes system calls, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 18/23] bsd-user: add shim for the ioctl system call, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 16/23] bsd-user: add shims for stat and file handle related syscalls, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 15/23] bsd-user: add shims for socket related system calls, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 14/23] bsd-user: add shims for process related system calls, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 21/23] bsd-user: add miscellaneous system call shims, Stacey Son, 2013/06/24
- [Qemu-devel] [PATCH 17/23] bsd-user: add shims for thread related system calls, Stacey Son, 2013/06/24