linux-user: Trace sendto/recvfrom
v2 cover linux-user: Trace sendto/recvfrom
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(-)
Signature · 1 line
2.45.2
PATCH v2 3/4 linux-user: Add strace for sendto()
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
--- linux-user/strace.c | 15 +++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-)
linux-user/strace.c +15 -0
@@ -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
linux-user/strace.list +1 -1
@@ -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 },
Signature · 1 line
2.45.2
PATCH v2 4/4 linux-user: Add strace for recvfrom()
In reply to Philippe Mathieu-DaudéSigned-off-by Philippe Mathieu-Daudé <[email protected]>
--- linux-user/strace.c | 19 +++++++++++++++++++ linux-user/strace.list | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-)
linux-user/strace.c +19 -0
@@ -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,
linux-user/strace.list +1 -1
@@ -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 },
Signature · 1 line
2.45.2
PATCH v2 2/4 linux-user: Factor print_buf_len() out
In reply to Philippe Mathieu-DaudéSigned-off-by Philippe Mathieu-Daudé <[email protected]>
--- linux-user/strace.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
linux-user/strace.c +9 -4
@@ -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 (")" );
Signature · 1 line
2.45.2
PATCH v2 1/4 linux-user: Display sockaddr buffer as pointer
In reply to 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é <[email protected]>
Reviewed-by Richard Henderson <[email protected]>
--- linux-user/strace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/strace.c +2 -2
@@ -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
Signature · 1 line
2.45.2