diff mbox series

[v2] linux-user: fix socket() strace

Message ID 20200312165530.53450-1-laurent@vivier.eu
State New
Headers show
Series [v2] linux-user: fix socket() strace | expand

Commit Message

Laurent Vivier March 12, 2020, 4:55 p.m. UTC
print_socket_type() doesn't manage flags and the correct type cannot
be displayed

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---

Notes:
    v2: replace gemu_log() by qemu_log() as it has been removed from qemu

 linux-user/strace.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé March 12, 2020, 8:31 p.m. UTC | #1
On 3/12/20 5:55 PM, Laurent Vivier wrote:
> print_socket_type() doesn't manage flags and the correct type cannot
> be displayed
> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> 
> Notes:
>      v2: replace gemu_log() by qemu_log() as it has been removed from qemu
> 
>   linux-user/strace.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 4f7130b2ff63..69232f7e27b8 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -444,7 +444,7 @@ print_socket_domain(int domain)
>   static void
>   print_socket_type(int type)
>   {
> -    switch (type) {
> +    switch (type & TARGET_SOCK_TYPE_MASK) {
>       case TARGET_SOCK_DGRAM:
>           qemu_log("SOCK_DGRAM");
>           break;
> @@ -464,6 +464,12 @@ print_socket_type(int type)
>           qemu_log("SOCK_PACKET");
>           break;
>       }
> +    if (type & TARGET_SOCK_CLOEXEC) {
> +        qemu_log("|SOCK_CLOEXEC");
> +    }
> +    if (type & TARGET_SOCK_NONBLOCK) {
> +        qemu_log("|SOCK_NONBLOCK");
> +    }
>   }
>   
>   static void
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Laurent Vivier March 13, 2020, 9:42 p.m. UTC | #2
Le 12/03/2020 à 17:55, Laurent Vivier a écrit :
> print_socket_type() doesn't manage flags and the correct type cannot
> be displayed
> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> 
> Notes:
>     v2: replace gemu_log() by qemu_log() as it has been removed from qemu
> 
>  linux-user/strace.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 4f7130b2ff63..69232f7e27b8 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -444,7 +444,7 @@ print_socket_domain(int domain)
>  static void
>  print_socket_type(int type)
>  {
> -    switch (type) {
> +    switch (type & TARGET_SOCK_TYPE_MASK) {
>      case TARGET_SOCK_DGRAM:
>          qemu_log("SOCK_DGRAM");
>          break;
> @@ -464,6 +464,12 @@ print_socket_type(int type)
>          qemu_log("SOCK_PACKET");
>          break;
>      }
> +    if (type & TARGET_SOCK_CLOEXEC) {
> +        qemu_log("|SOCK_CLOEXEC");
> +    }
> +    if (type & TARGET_SOCK_NONBLOCK) {
> +        qemu_log("|SOCK_NONBLOCK");
> +    }
>  }
>  
>  static void
> 

Applied to my linux-user branch.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 4f7130b2ff63..69232f7e27b8 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -444,7 +444,7 @@  print_socket_domain(int domain)
 static void
 print_socket_type(int type)
 {
-    switch (type) {
+    switch (type & TARGET_SOCK_TYPE_MASK) {
     case TARGET_SOCK_DGRAM:
         qemu_log("SOCK_DGRAM");
         break;
@@ -464,6 +464,12 @@  print_socket_type(int type)
         qemu_log("SOCK_PACKET");
         break;
     }
+    if (type & TARGET_SOCK_CLOEXEC) {
+        qemu_log("|SOCK_CLOEXEC");
+    }
+    if (type & TARGET_SOCK_NONBLOCK) {
+        qemu_log("|SOCK_NONBLOCK");
+    }
 }
 
 static void