Received: from eggs.gnu.org ([2001:4830:134:3::10]:50701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI0Xz-0008Dv-EM for qemu-devel@nongnu.org; Tue, 28 Jun 2016 17:27:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bI0Xx-0005T4-10 for qemu-devel@nongnu.org; Tue, 28 Jun 2016 17:27:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38748) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI0Xw-0005Sz-PI for qemu-devel@nongnu.org; Tue, 28 Jun 2016 17:27:52 -0400 From: Stefan Hajnoczi Date: Tue, 28 Jun 2016 22:27:30 +0100 Message-Id: <1467149250-31165-9-git-send-email-stefanha@redhat.com> In-Reply-To: <1467149250-31165-1-git-send-email-stefanha@redhat.com> References: <1467149250-31165-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 8/8] trace: [*-user] Add events to trace guest syscalls in syscall emulation mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Stefan Hajnoczi From: Llu=C3=ADs Vilanova Adds two events to trace syscalls in syscall emulation mode (*-user): * guest_user_syscall: Emitted before the syscall is emulated; contains the syscall number and arguments. * guest_user_syscall_ret: Emitted after the syscall is emulated; contains the syscall number and return value. Signed-off-by: Llu=C3=ADs Vilanova Message-id: 146651712411.12388.10024905980452504938.stgit@fimbulvetr.bsc.= es Signed-off-by: Stefan Hajnoczi --- bsd-user/syscall.c | 9 +++++++++ linux-user/syscall.c | 2 ++ trace-events | 16 ++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index a9fe869..66492aa 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -315,12 +315,14 @@ abi_long do_freebsd_syscall(void *cpu_env, int num,= abi_long arg1, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { + CPUState *cpu =3D ENV_GET_CPU(cpu_env); abi_long ret; void *p; =20 #ifdef DEBUG gemu_log("freebsd syscall %d\n", num); #endif + trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg= 6, arg7, arg8); if(do_strace) print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); =20 @@ -400,6 +402,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, a= bi_long arg1, #endif if (do_strace) print_freebsd_syscall_ret(num, ret); + trace_guest_user_syscall_ret(cpu, num, ret); return ret; efault: ret =3D -TARGET_EFAULT; @@ -410,12 +413,14 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, = abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { + CPUState *cpu =3D ENV_GET_CPU(cpu_env); abi_long ret; void *p; =20 #ifdef DEBUG gemu_log("netbsd syscall %d\n", num); #endif + trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg= 6, 0, 0); if(do_strace) print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); =20 @@ -472,6 +477,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, ab= i_long arg1, #endif if (do_strace) print_netbsd_syscall_ret(num, ret); + trace_guest_user_syscall_ret(cpu, num, ret); return ret; efault: ret =3D -TARGET_EFAULT; @@ -482,12 +488,14 @@ abi_long do_openbsd_syscall(void *cpu_env, int num,= abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { + CPUState *cpu =3D ENV_GET_CPU(cpu_env); abi_long ret; void *p; =20 #ifdef DEBUG gemu_log("openbsd syscall %d\n", num); #endif + trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg= 6, 0, 0); if(do_strace) print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); =20 @@ -544,6 +552,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, a= bi_long arg1, #endif if (do_strace) print_openbsd_syscall_ret(num, ret); + trace_guest_user_syscall_ret(cpu, num, ret); return ret; efault: ret =3D -TARGET_EFAULT; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1c17b74..e59f16d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6690,6 +6690,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, #ifdef DEBUG gemu_log("syscall %d", num); #endif + trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg= 6, arg7, arg8); if(do_strace) print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); =20 @@ -11182,6 +11183,7 @@ fail: #endif if(do_strace) print_syscall_ret(num, ret); + trace_guest_user_syscall_ret(cpu, num, ret); return ret; efault: ret =3D -TARGET_EFAULT; diff --git a/trace-events b/trace-events index 9d76de8..4767059 100644 --- a/trace-events +++ b/trace-events @@ -156,3 +156,19 @@ memory_region_tb_write(int cpu_index, uint64_t addr,= uint64_t value, unsigned si # # Targets: TCG(all) disable vcpu tcg guest_mem_before(TCGv vaddr, uint8_t info) "info=3D%d",= "vaddr=3D0x%016"PRIx64" info=3D%d" + +# @num: System call number. +# @arg*: System call argument value. +# +# Start executing a guest system call in syscall emulation mode. +# +# Targets: TCG(all) +disable vcpu guest_user_syscall(uint64_t num, uint64_t arg1, uint64_t ar= g2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t = arg7, uint64_t arg8) "num=3D0x%016"PRIx64" arg1=3D0x%016"PRIx64" arg2=3D0= x%016"PRIx64" arg3=3D0x%016"PRIx64" arg4=3D0x%016"PRIx64" arg5=3D0x%016"P= RIx64" arg6=3D0x%016"PRIx64" arg7=3D0x%016"PRIx64" arg8=3D0x%016"PRIx64 + +# @num: System call number. +# @ret: System call result value. +# +# Finish executing a guest system call in syscall emulation mode. +# +# Targets: TCG(all) +disable vcpu guest_user_syscall_ret(uint64_t num, uint64_t ret) "num=3D0= x%016"PRIx64" ret=3D0x%016"PRIx64 --=20 2.7.4