From e8b609ac3598c44bba6535cd1306222eb4440bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 20 Nov 2024 14:20:24 -0600 Subject: linux-user: Print tid not pid with strace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This aligns with strace, and is very useful when tracing multi-threaded programs. The result is the same in single-threaded programs. Signed-off-by: J. Neuschäfer Message-Id: 20241024-strace-v1-1-56c4161431cd@gmx.net [rth: Use TaskState.ts_tid via get_task_state()] Signed-off-by: Richard Henderson --- linux-user/strace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index b70eadc19e..f68c5cdc44 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -4401,7 +4401,7 @@ print_syscall(CPUArchState *cpu_env, int num, if (!f) { return; } - fprintf(f, "%d ", getpid()); + fprintf(f, "%d ", get_task_state(env_cpu(cpu_env))->ts_tid); for (i = 0; i < nsyscalls; i++) { if (scnames[i].nr == num) { -- cgit v1.2.3 From d95fd9838b540e69da9b07538ec8ad6ab9eab260 Mon Sep 17 00:00:00 2001 From: Ilya Leoshkevich Date: Wed, 20 Nov 2024 22:26:44 +0100 Subject: linux-user: Fix strace output for s390x mmap() print_mmap() assumes that mmap() receives arguments via memory if mmap2() is present. s390x (as opposed to s390) does not fit this pattern: it does not have mmap2(), but mmap() still receives arguments via memory. Fix by sharing the detection logic between syscall.c and strace.c. Cc: qemu-stable@nongnu.org Fixes: d971040c2d16 ("linux-user: Fix strace output for old_mmap") Suggested-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-ID: <20241120212717.246186-1-iii@linux.ibm.com> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- linux-user/strace.c | 2 +- linux-user/syscall.c | 5 +---- linux-user/syscall_defs.h | 7 +++++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index f68c5cdc44..3b744ccd4a 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -3971,7 +3971,7 @@ print_mmap(CPUArchState *cpu_env, const struct syscallname *name, { return print_mmap_both(cpu_env, name, arg0, arg1, arg2, arg3, arg4, arg5, -#if defined(TARGET_NR_mmap2) +#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP true #else false diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0279f23576..1ce4c79784 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10588,10 +10588,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, return ret; #ifdef TARGET_NR_mmap case TARGET_NR_mmap: -#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \ - (defined(TARGET_ARM) && defined(TARGET_ABI32)) || \ - defined(TARGET_M68K) || defined(TARGET_MICROBLAZE) \ - || defined(TARGET_S390X) +#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP { abi_ulong *v; abi_ulong v1, v2, v3, v4, v5, v6; diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 0e08dfae3e..faad9147c9 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2766,4 +2766,11 @@ struct target_open_how_ver0 { #define RESOLVE_NO_SYMLINKS 0x04 #endif +#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \ + (defined(TARGET_ARM) && defined(TARGET_ABI32)) || \ + defined(TARGET_M68K) || defined(TARGET_MICROBLAZE) || \ + defined(TARGET_S390X) +#define TARGET_ARCH_WANT_SYS_OLD_MMAP +#endif + #endif -- cgit v1.2.3