[PATCH] Enable strace for TARGET_NR_llseek

Taylor Simpson posted 1 patch 4 years, 1 month ago
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test checkpatch passed
Test FreeBSD passed
Test asan passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1584391940-29281-1-git-send-email-tsimpson@quicinc.com
Maintainers: Riku Voipio <riku.voipio@iki.fi>, Laurent Vivier <laurent@vivier.eu>
linux-user/strace.c    | 2 +-
linux-user/strace.list | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
[PATCH] Enable strace for TARGET_NR_llseek
Posted by Taylor Simpson 4 years, 1 month ago
linux-user/syscall.c handles the case where TARGET_NR_llseek (one underscore)
is defined and TARGET_NR__llseek (two underscores)
    /* Newer kernel ports have llseek() instead of _llseek() */
    #if defined(TARGET_NR_llseek) && !defined(TARGET_NR__llseek)
    #define TARGET_NR__llseek TARGET_NR_llseek
    #endif

Unfortunately, strace will print "Unknown syscall" in this case.  This patch
fixes that problem.

Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
---
 linux-user/strace.c    | 2 +-
 linux-user/strace.list | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 4f7130b..4bcc00b 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1667,7 +1667,7 @@ print_linkat(const struct syscallname *name,
 }
 #endif
 
-#ifdef TARGET_NR__llseek
+#ifdef defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek)
 static void
 print__llseek(const struct syscallname *name,
     abi_long arg0, abi_long arg1, abi_long arg2,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index d49a1e9..5a01e95 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -503,6 +503,9 @@
 #ifdef TARGET_NR__llseek
 { TARGET_NR__llseek, "_llseek" , NULL, print__llseek, NULL },
 #endif
+#ifdef TARGET_NR_llseek
+{ TARGET_NR_llseek, "_llseek" , NULL, print__llseek, NULL },
+#endif
 #ifdef TARGET_NR_lock
 { TARGET_NR_lock, "lock" , NULL, NULL, NULL },
 #endif
-- 
2.7.4


Re: [PATCH] Enable strace for TARGET_NR_llseek
Posted by Philippe Mathieu-Daudé 4 years, 1 month ago
On 3/16/20 9:52 PM, Taylor Simpson wrote:
> linux-user/syscall.c handles the case where TARGET_NR_llseek (one underscore)
> is defined and TARGET_NR__llseek (two underscores)
>      /* Newer kernel ports have llseek() instead of _llseek() */
>      #if defined(TARGET_NR_llseek) && !defined(TARGET_NR__llseek)
>      #define TARGET_NR__llseek TARGET_NR_llseek
>      #endif
> 
> Unfortunately, strace will print "Unknown syscall" in this case.  This patch
> fixes that problem.
> 
> Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
> ---
>   linux-user/strace.c    | 2 +-
>   linux-user/strace.list | 3 +++
>   2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 4f7130b..4bcc00b 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1667,7 +1667,7 @@ print_linkat(const struct syscallname *name,
>   }
>   #endif
>   
> -#ifdef TARGET_NR__llseek
> +#ifdef defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek)
>   static void
>   print__llseek(const struct syscallname *name,
>       abi_long arg0, abi_long arg1, abi_long arg2,
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index d49a1e9..5a01e95 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -503,6 +503,9 @@
>   #ifdef TARGET_NR__llseek
>   { TARGET_NR__llseek, "_llseek" , NULL, print__llseek, NULL },
>   #endif
> +#ifdef TARGET_NR_llseek
> +{ TARGET_NR_llseek, "_llseek" , NULL, print__llseek, NULL },
> +#endif
>   #ifdef TARGET_NR_lock
>   { TARGET_NR_lock, "lock" , NULL, NULL, NULL },
>   #endif
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>