Extract common print_sockfd() from various socket related syscalls. Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> --- v6: use another ifdef TARGET_NR_socketcall --- linux-user/strace.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/linux-user/strace.c b/linux-user/strace.c index 22dd453d26..01c802c4e3 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1709,6 +1709,15 @@ print_socket(const struct syscallname *name, #if defined(TARGET_NR_socketcall) +static void print_sockfd(abi_long sockfd, int last) +{ + print_raw_param(TARGET_ABI_FMT_ld, sockfd, last); +} + +#endif + +#if defined(TARGET_NR_socketcall) + #define get_user_ualx(x, gaddr, idx) \ get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long)) @@ -1741,7 +1750,7 @@ static void do_print_sockaddr(const char *name, abi_long arg1) get_user_ualx(addrlen, arg1, 2); gemu_log("%s(", name); - print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); + print_sockfd(sockfd, 0); print_sockaddr(addr, addrlen); gemu_log(")"); } @@ -1754,7 +1763,7 @@ static void do_print_listen(const char *name, abi_long arg1) get_user_ualx(backlog, arg1, 1); gemu_log("%s(", name); - print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); + print_sockfd(sockfd, 0); print_raw_param(TARGET_ABI_FMT_ld, backlog, 1); gemu_log(")"); } @@ -1789,7 +1798,7 @@ static void do_print_sendrecv(const char *name, abi_long arg1) get_user_ualx(flags, arg1, 3); gemu_log("%s(", name); - print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); + print_sockfd(sockfd, 0); print_buf(msg, len, 0); print_raw_param(TARGET_ABI_FMT_ld, len, 0); print_flags(msg_flags, flags, 1); @@ -1808,7 +1817,7 @@ static void do_print_msgaddr(const char *name, abi_long arg1) get_user_ualx(addrlen, arg1, 5); gemu_log("%s(", name); - print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); + print_sockfd(sockfd, 0); print_buf(msg, len, 0); print_raw_param(TARGET_ABI_FMT_ld, len, 0); print_flags(msg_flags, flags, 0); @@ -1824,7 +1833,7 @@ static void do_print_shutdown(const char *name, abi_long arg1) get_user_ualx(how, arg1, 1); gemu_log("shutdown("); - print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); + print_sockfd(sockfd, 0); switch (how) { case SHUT_RD: gemu_log("SHUT_RD"); @@ -1851,7 +1860,7 @@ static void do_print_msg(const char *name, abi_long arg1) get_user_ualx(flags, arg1, 2); gemu_log("%s(", name); - print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); + print_sockfd(sockfd, 0); print_pointer(msg, 0); print_flags(msg_flags, flags, 1); gemu_log(")"); @@ -1868,7 +1877,7 @@ static void do_print_sockopt(const char *name, abi_long arg1) get_user_ualx(optlen, arg1, 4); gemu_log("%s(", name); - print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); + print_sockfd(sockfd, 0); switch (level) { case SOL_TCP: gemu_log("SOL_TCP,"); -- 2.20.1