1From e8f06676c6c88e12cd5f4f81a839b7111c683596 Mon Sep 17 00:00:00 2001 2From: Richard Henderson <richard.henderson@linaro.org> 3Date: Wed, 28 Feb 2024 10:25:16 -1000 4Subject: [PATCH 3/5] linux-user: Add strace for shmat 5 6Upstream-Status: Submitted [https://www.mail-archive.com/qemu-devel@nongnu.org/msg1026793.html] 7 8Signed-off-by: Richard Henderson <richard.henderson@linaro.org> 9Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> 10--- 11 linux-user/strace.c | 23 +++++++++++++++++++++++ 12 linux-user/strace.list | 2 +- 13 2 files changed, 24 insertions(+), 1 deletion(-) 14 15diff --git a/linux-user/strace.c b/linux-user/strace.c 16index cf26e5526..47d6ec326 100644 17--- a/linux-user/strace.c 18+++ b/linux-user/strace.c 19@@ -670,6 +670,25 @@ print_semctl(CPUArchState *cpu_env, const struct syscallname *name, 20 } 21 #endif 22 23+static void 24+print_shmat(CPUArchState *cpu_env, const struct syscallname *name, 25+ abi_long arg0, abi_long arg1, abi_long arg2, 26+ abi_long arg3, abi_long arg4, abi_long arg5) 27+{ 28+ static const struct flags shmat_flags[] = { 29+ FLAG_GENERIC(SHM_RND), 30+ FLAG_GENERIC(SHM_REMAP), 31+ FLAG_GENERIC(SHM_RDONLY), 32+ FLAG_GENERIC(SHM_EXEC), 33+ }; 34+ 35+ print_syscall_prologue(name); 36+ print_raw_param(TARGET_ABI_FMT_ld, arg0, 0); 37+ print_pointer(arg1, 0); 38+ print_flags(shmat_flags, arg2, 1); 39+ print_syscall_epilogue(name); 40+} 41+ 42 #ifdef TARGET_NR_ipc 43 static void 44 print_ipc(CPUArchState *cpu_env, const struct syscallname *name, 45@@ -683,6 +702,10 @@ print_ipc(CPUArchState *cpu_env, const struct syscallname *name, 46 print_ipc_cmd(arg3); 47 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); 48 break; 49+ case IPCOP_shmat: 50+ print_shmat(cpu_env, &(const struct syscallname){ .name = "shmat" }, 51+ arg1, arg4, arg2, 0, 0, 0); 52+ break; 53 default: 54 qemu_log(("%s(" 55 TARGET_ABI_FMT_ld "," 56diff --git a/linux-user/strace.list b/linux-user/strace.list 57index 6655d4f26..dfd4237d1 100644 58--- a/linux-user/strace.list 59+++ b/linux-user/strace.list 60@@ -1398,7 +1398,7 @@ 61 { TARGET_NR_sgetmask, "sgetmask" , NULL, NULL, NULL }, 62 #endif 63 #ifdef TARGET_NR_shmat 64-{ TARGET_NR_shmat, "shmat" , NULL, NULL, print_syscall_ret_addr }, 65+{ TARGET_NR_shmat, "shmat" , NULL, print_shmat, print_syscall_ret_addr }, 66 #endif 67 #ifdef TARGET_NR_shmctl 68 { TARGET_NR_shmctl, "shmctl" , NULL, NULL, NULL }, 69-- 702.34.1 71 72