qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] linux-user: Trace sendto/recvfrom
@ 2024-08-07 12:37 Philippe Mathieu-Daudé
  2024-08-07 12:37 ` [PATCH v2 1/4] linux-user: Display sockaddr buffer as pointer Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-07 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Zach van Rijn, Philippe Mathieu-Daudé

Since v1:
- Add/use print_buf_len (rth)

Strace format added while debugging
https://gitlab.com/qemu-project/qemu/-/issues/2485

Philippe Mathieu-Daudé (4):
  linux-user: Display sockaddr buffer as pointer
  linux-user: Factor print_buf_len() out
  linux-user: Add strace for sendto()
  linux-user: Add strace for recvfrom()

 linux-user/strace.c    | 51 +++++++++++++++++++++++++++++++++++++-----
 linux-user/strace.list |  4 ++--
 2 files changed, 47 insertions(+), 8 deletions(-)

-- 
2.45.2



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/4] linux-user: Display sockaddr buffer as pointer
  2024-08-07 12:37 [PATCH v2 0/4] linux-user: Trace sendto/recvfrom Philippe Mathieu-Daudé
@ 2024-08-07 12:37 ` Philippe Mathieu-Daudé
  2024-08-07 12:37 ` [PATCH v2 2/4] linux-user: Factor print_buf_len() out Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-07 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Zach van Rijn, Philippe Mathieu-Daudé,
	Richard Henderson

Rather than 'raw param', display as pointer to get
"NULL" instead of "0x00000000". Remove spurious space.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/strace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index b4d1098170..80f64ff40c 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -434,9 +434,9 @@ print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
         }
         unlock_user(sa, addr, 0);
     } else {
-        print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
+        print_pointer(addr, 1);
     }
-    qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
+    qemu_log(","TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
 }
 
 static void
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/4] linux-user: Factor print_buf_len() out
  2024-08-07 12:37 [PATCH v2 0/4] linux-user: Trace sendto/recvfrom Philippe Mathieu-Daudé
  2024-08-07 12:37 ` [PATCH v2 1/4] linux-user: Display sockaddr buffer as pointer Philippe Mathieu-Daudé
@ 2024-08-07 12:37 ` Philippe Mathieu-Daudé
  2024-08-07 12:37 ` [PATCH v2 3/4] linux-user: Add strace for sendto() Philippe Mathieu-Daudé
  2024-08-07 12:37 ` [PATCH v2 4/4] linux-user: Add strace for recvfrom() Philippe Mathieu-Daudé
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-07 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Zach van Rijn, Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 linux-user/strace.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 80f64ff40c..210ff86afc 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1655,6 +1655,13 @@ print_buf(abi_long addr, abi_long len, int last)
     }
 }
 
+static void
+print_buf_len(abi_long addr, abi_long len, int last)
+{
+    print_buf(addr, len, 0);
+    print_raw_param(TARGET_ABI_FMT_ld, len, last);
+}
+
 /*
  * Prints out raw parameter using given format.  Caller needs
  * to do byte swapping if needed.
@@ -2742,8 +2749,7 @@ static void do_print_sendrecv(const char *name, abi_long arg1)
 
     qemu_log("%s(", name);
     print_sockfd(sockfd, 0);
-    print_buf(msg, len, 0);
-    print_raw_param(TARGET_ABI_FMT_ld, len, 0);
+    print_buf_len(msg, len, 0);
     print_flags(msg_flags, flags, 1);
     qemu_log(")");
 }
@@ -2761,8 +2767,7 @@ static void do_print_msgaddr(const char *name, abi_long arg1)
 
     qemu_log("%s(", name);
     print_sockfd(sockfd, 0);
-    print_buf(msg, len, 0);
-    print_raw_param(TARGET_ABI_FMT_ld, len, 0);
+    print_buf_len(msg, len, 0);
     print_flags(msg_flags, flags, 0);
     print_sockaddr(addr, addrlen, 0);
     qemu_log(")");
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/4] linux-user: Add strace for sendto()
  2024-08-07 12:37 [PATCH v2 0/4] linux-user: Trace sendto/recvfrom Philippe Mathieu-Daudé
  2024-08-07 12:37 ` [PATCH v2 1/4] linux-user: Display sockaddr buffer as pointer Philippe Mathieu-Daudé
  2024-08-07 12:37 ` [PATCH v2 2/4] linux-user: Factor print_buf_len() out Philippe Mathieu-Daudé
@ 2024-08-07 12:37 ` Philippe Mathieu-Daudé
  2024-08-07 12:37 ` [PATCH v2 4/4] linux-user: Add strace for recvfrom() Philippe Mathieu-Daudé
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-07 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Zach van Rijn, Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 linux-user/strace.c    | 15 +++++++++++++++
 linux-user/strace.list |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 210ff86afc..98ef26b917 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -3127,6 +3127,21 @@ print_bind(CPUArchState *cpu_env, const struct syscallname *name,
 }
 #endif
 
+#ifdef TARGET_NR_sendto
+static void
+print_sendto(CPUArchState *cpu_env, const struct syscallname *name,
+             abi_long arg0, abi_long arg1, abi_long arg2,
+             abi_long arg3, abi_long arg4, abi_long arg5)
+{
+    print_syscall_prologue(name);
+    print_sockfd(arg0, 0);
+    print_buf_len(arg1, arg2, 0);
+    print_flags(msg_flags, arg3, 0);
+    print_sockaddr(arg4, arg5, 1);
+    print_syscall_epilogue(name);
+}
+#endif
+
 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
     defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
 static void
diff --git a/linux-user/strace.list b/linux-user/strace.list
index dfd4237d14..5a86419e7d 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1285,7 +1285,7 @@
 { TARGET_NR_sendmsg, "sendmsg" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_sendto
-{ TARGET_NR_sendto, "sendto" , NULL, NULL, NULL },
+{ TARGET_NR_sendto, "sendto" , NULL, print_sendto, NULL },
 #endif
 #ifdef TARGET_NR_setdomainname
 { TARGET_NR_setdomainname, "setdomainname" , NULL, NULL, NULL },
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 4/4] linux-user: Add strace for recvfrom()
  2024-08-07 12:37 [PATCH v2 0/4] linux-user: Trace sendto/recvfrom Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2024-08-07 12:37 ` [PATCH v2 3/4] linux-user: Add strace for sendto() Philippe Mathieu-Daudé
@ 2024-08-07 12:37 ` Philippe Mathieu-Daudé
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-07 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Zach van Rijn, Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 linux-user/strace.c    | 19 +++++++++++++++++++
 linux-user/strace.list |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 98ef26b917..d76907fdc9 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -3127,6 +3127,25 @@ print_bind(CPUArchState *cpu_env, const struct syscallname *name,
 }
 #endif
 
+#ifdef TARGET_NR_recvfrom
+static void
+print_recvfrom(CPUArchState *cpu_env, const struct syscallname *name,
+               abi_long arg0, abi_long arg1, abi_long arg2,
+               abi_long arg3, abi_long arg4, abi_long arg5)
+{
+    abi_ulong addrlen;
+
+    get_user_ualx(addrlen, arg5, 0);
+
+    print_syscall_prologue(name);
+    print_sockfd(arg0, 0);
+    print_buf_len(arg1, arg2, 0);
+    print_flags(msg_flags, arg3, 0);
+    print_sockaddr(arg4, addrlen, 1);
+    print_syscall_epilogue(name);
+}
+#endif
+
 #ifdef TARGET_NR_sendto
 static void
 print_sendto(CPUArchState *cpu_env, const struct syscallname *name,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 5a86419e7d..77ca824f9c 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1135,7 +1135,7 @@
 { TARGET_NR_recv, "recv" , "%s(%d,%p,%u,%d)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_recvfrom
-{ TARGET_NR_recvfrom, "recvfrom" , NULL, NULL, NULL },
+{ TARGET_NR_recvfrom, "recvfrom" , NULL, print_recvfrom, NULL },
 #endif
 #ifdef TARGET_NR_recvmmsg
 { TARGET_NR_recvmmsg, "recvmmsg" , NULL, NULL, NULL },
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-07 12:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07 12:37 [PATCH v2 0/4] linux-user: Trace sendto/recvfrom Philippe Mathieu-Daudé
2024-08-07 12:37 ` [PATCH v2 1/4] linux-user: Display sockaddr buffer as pointer Philippe Mathieu-Daudé
2024-08-07 12:37 ` [PATCH v2 2/4] linux-user: Factor print_buf_len() out Philippe Mathieu-Daudé
2024-08-07 12:37 ` [PATCH v2 3/4] linux-user: Add strace for sendto() Philippe Mathieu-Daudé
2024-08-07 12:37 ` [PATCH v2 4/4] linux-user: Add strace for recvfrom() Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).