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

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

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

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

-- 
2.45.2



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

* [PATCH 1/3] linux-user: Display sockaddr buffer as pointer
  2024-08-07  8:35 [PATCH 0/3] linux-user: Trace sendto/recvfrom Philippe Mathieu-Daudé
@ 2024-08-07  8:35 ` Philippe Mathieu-Daudé
  2024-08-07 10:53   ` Richard Henderson
  2024-08-07  8:35 ` [PATCH 2/3] linux-user: Add strace for sendto() Philippe Mathieu-Daudé
  2024-08-07  8:35 ` [PATCH 3/3] linux-user: Add strace for recvfrom() Philippe Mathieu-Daudé
  2 siblings, 1 reply; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-07  8:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Zach van Rijn, Philippe Mathieu-Daudé

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>
---
 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..7064afb486 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, 0);
     }
-    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] 8+ messages in thread

* [PATCH 2/3] linux-user: Add strace for sendto()
  2024-08-07  8:35 [PATCH 0/3] linux-user: Trace sendto/recvfrom Philippe Mathieu-Daudé
  2024-08-07  8:35 ` [PATCH 1/3] linux-user: Display sockaddr buffer as pointer Philippe Mathieu-Daudé
@ 2024-08-07  8:35 ` Philippe Mathieu-Daudé
  2024-08-07 10:55   ` Richard Henderson
  2024-08-07  8:35 ` [PATCH 3/3] linux-user: Add strace for recvfrom() Philippe Mathieu-Daudé
  2 siblings, 1 reply; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-07  8:35 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 7064afb486..f55b62f0c9 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -3122,6 +3122,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(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] 8+ messages in thread

* [PATCH 3/3] linux-user: Add strace for recvfrom()
  2024-08-07  8:35 [PATCH 0/3] linux-user: Trace sendto/recvfrom Philippe Mathieu-Daudé
  2024-08-07  8:35 ` [PATCH 1/3] linux-user: Display sockaddr buffer as pointer Philippe Mathieu-Daudé
  2024-08-07  8:35 ` [PATCH 2/3] linux-user: Add strace for sendto() Philippe Mathieu-Daudé
@ 2024-08-07  8:35 ` Philippe Mathieu-Daudé
  2024-08-07 10:55   ` Richard Henderson
  2 siblings, 1 reply; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-07  8:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Zach van Rijn, Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
RFC: Not sure about get_user_ualx() use here
---
 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 f55b62f0c9..f03e4229d6 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -3122,6 +3122,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(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] 8+ messages in thread

* Re: [PATCH 1/3] linux-user: Display sockaddr buffer as pointer
  2024-08-07  8:35 ` [PATCH 1/3] linux-user: Display sockaddr buffer as pointer Philippe Mathieu-Daudé
@ 2024-08-07 10:53   ` Richard Henderson
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2024-08-07 10:53 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Laurent Vivier, Zach van Rijn

On 8/7/24 18:35, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   linux-user/strace.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH 2/3] linux-user: Add strace for sendto()
  2024-08-07  8:35 ` [PATCH 2/3] linux-user: Add strace for sendto() Philippe Mathieu-Daudé
@ 2024-08-07 10:55   ` Richard Henderson
  2024-08-07 12:18     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2024-08-07 10:55 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Laurent Vivier, Zach van Rijn

On 8/7/24 18:35, Philippe Mathieu-Daudé wrote:
> +#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(arg1, arg2, 0);

You still need to log arg2.


r~


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

* Re: [PATCH 3/3] linux-user: Add strace for recvfrom()
  2024-08-07  8:35 ` [PATCH 3/3] linux-user: Add strace for recvfrom() Philippe Mathieu-Daudé
@ 2024-08-07 10:55   ` Richard Henderson
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2024-08-07 10:55 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Laurent Vivier, Zach van Rijn

On 8/7/24 18:35, Philippe Mathieu-Daudé wrote:
> +#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(arg1, arg2, 0);
> +    print_flags(msg_flags, arg3, 0);

Log arg2.

r~


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

* Re: [PATCH 2/3] linux-user: Add strace for sendto()
  2024-08-07 10:55   ` Richard Henderson
@ 2024-08-07 12:18     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-07 12:18 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: Laurent Vivier, Zach van Rijn

On 7/8/24 12:55, Richard Henderson wrote:
> On 8/7/24 18:35, Philippe Mathieu-Daudé wrote:
>> +#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(arg1, arg2, 0);
> 
> You still need to log arg2.

Oops.



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

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

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07  8:35 [PATCH 0/3] linux-user: Trace sendto/recvfrom Philippe Mathieu-Daudé
2024-08-07  8:35 ` [PATCH 1/3] linux-user: Display sockaddr buffer as pointer Philippe Mathieu-Daudé
2024-08-07 10:53   ` Richard Henderson
2024-08-07  8:35 ` [PATCH 2/3] linux-user: Add strace for sendto() Philippe Mathieu-Daudé
2024-08-07 10:55   ` Richard Henderson
2024-08-07 12:18     ` Philippe Mathieu-Daudé
2024-08-07  8:35 ` [PATCH 3/3] linux-user: Add strace for recvfrom() Philippe Mathieu-Daudé
2024-08-07 10:55   ` Richard Henderson

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).