diff mbox

[3/5] linux-user: add socket() strace

Message ID 1465417472-11359-4-git-send-email-laurent@vivier.eu (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Vivier June 8, 2016, 8:24 p.m. UTC
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/strace.c    | 24 ++++++++++++++++++++++++
 linux-user/strace.list |  2 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

Comments

Peter Maydell June 10, 2016, 12:54 p.m. UTC | #1
On 8 June 2016 at 21:24, Laurent Vivier <laurent@vivier.eu> wrote:
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  linux-user/strace.c    | 24 ++++++++++++++++++++++++
>  linux-user/strace.list |  2 +-
>  2 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 398e56e..0c3675c 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1221,6 +1221,30 @@ print__llseek(const struct syscallname *name,
>  }
>  #endif
>
> +#if defined(TARGET_NR_socket)
> +static void
> +print_socket(const struct syscallname *name,
> +             abi_long arg0, abi_long arg1, abi_long arg2,
> +             abi_long arg3, abi_long arg4, abi_long arg5)
> +{
> +    abi_ulong domain = arg0, type = arg1, protocol = arg2;
> +
> +    print_syscall_prologue(name);
> +    print_socket_domain(domain);
> +    gemu_log(",");
> +    print_socket_type(type);
> +    gemu_log(",");
> +    if (domain == AF_PACKET ||
> +        type == TARGET_SOCK_PACKET) {
> +        protocol = tswapal(protocol); /* restore network endian long */
> +        protocol = abi_ntohl(protocol); /* a host endian long */

Same remarks apply about this not being the same swapping
we do in syscall.c for do_socket().

> +    }
> +    print_socket_protocol(domain, type, protocol);
> +    print_syscall_epilogue(name);
> +}
> +
> +#endif
> +
>  #if defined(TARGET_NR_socketcall)
>  static void
>  print_socketcall(const struct syscallname *name,
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index b379497..7c54dc6 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -1291,7 +1291,7 @@
>  { TARGET_NR_sigsuspend, "sigsuspend" , NULL, NULL, NULL },
>  #endif
>  #ifdef TARGET_NR_socket
> -{ TARGET_NR_socket, "socket" , NULL, NULL, NULL },
> +{ TARGET_NR_socket, "socket" , NULL, print_socket, NULL },
>  #endif
>  #ifdef TARGET_NR_socketcall
>  { TARGET_NR_socketcall, "socketcall" , NULL, print_socketcall, NULL },
> --
> 2.5.5
>
>

thanks
-- PMM
diff mbox

Patch

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 398e56e..0c3675c 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1221,6 +1221,30 @@  print__llseek(const struct syscallname *name,
 }
 #endif
 
+#if defined(TARGET_NR_socket)
+static void
+print_socket(const struct syscallname *name,
+             abi_long arg0, abi_long arg1, abi_long arg2,
+             abi_long arg3, abi_long arg4, abi_long arg5)
+{
+    abi_ulong domain = arg0, type = arg1, protocol = arg2;
+
+    print_syscall_prologue(name);
+    print_socket_domain(domain);
+    gemu_log(",");
+    print_socket_type(type);
+    gemu_log(",");
+    if (domain == AF_PACKET ||
+        type == TARGET_SOCK_PACKET) {
+        protocol = tswapal(protocol); /* restore network endian long */
+        protocol = abi_ntohl(protocol); /* a host endian long */
+    }
+    print_socket_protocol(domain, type, protocol);
+    print_syscall_epilogue(name);
+}
+
+#endif
+
 #if defined(TARGET_NR_socketcall)
 static void
 print_socketcall(const struct syscallname *name,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index b379497..7c54dc6 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1291,7 +1291,7 @@ 
 { TARGET_NR_sigsuspend, "sigsuspend" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_socket
-{ TARGET_NR_socket, "socket" , NULL, NULL, NULL },
+{ TARGET_NR_socket, "socket" , NULL, print_socket, NULL },
 #endif
 #ifdef TARGET_NR_socketcall
 { TARGET_NR_socketcall, "socketcall" , NULL, print_socketcall, NULL },