[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/3] linux-user: Add strace support for printing arguments of
From: |
Laurent Vivier |
Subject: |
Re: [PATCH 1/3] linux-user: Add strace support for printing arguments of truncate()/ftruncate() and getsid() |
Date: |
Thu, 2 Jul 2020 19:06:00 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
Le 26/06/2020 à 23:39, Filip Bozuta a écrit :
> This patch implements strace argument printing functionality for following
> syscalls:
>
> * truncate, ftruncate - truncate a file to a specified length
>
> int truncate(const char *path, off_t length)
> int ftruncate(int fd, off_t length)
> man page: https://man7.org/linux/man-pages/man2/truncate.2.html
>
> * getsid - get session ID
>
> pid_t getsid(pid_t pid)
> man page: https://man7.org/linux/man-pages/man2/getsid.2.html
>
> Implementation notes:
>
> Syscalls truncate/truncate64 takes string as argument type and thus a
> separate print function "print_truncate/print_truncate64" is stated in
> file "strace.list". This function is defined and implemented in "strace.c"
> by using an existing function used to print string arguments:
> "print_string()".
> The other syscalls have only primitive argument types, so the rest of the
> implementation was handled by stating an appropriate printing format in
> file
> "strace.list".
>
> Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
> ---
> linux-user/strace.c | 14 ++++++++++++++
> linux-user/strace.list | 10 +++++-----
> 2 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 6044c66954..dccfbc46e9 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1925,6 +1925,20 @@ print_lseek(const struct syscallname *name,
> }
> #endif
>
> +#ifdef TARGET_NR_truncate
> +static void
> +print_truncate(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_string(arg0, 0);
> + print_raw_param(TARGET_ABI_FMT_ld, arg1, 1);
> + print_syscall_epilogue(name);
> +}
> +#define print_truncate64 print_truncate
> +#endif
> +
> #if defined(TARGET_NR_socket)
> static void
> print_socket(const struct syscallname *name,
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 10e3e4a814..3b77b22daf 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -258,10 +258,10 @@
> { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL },
> #endif
> #ifdef TARGET_NR_ftruncate
> -{ TARGET_NR_ftruncate, "ftruncate" , NULL, NULL, NULL },
> +{ TARGET_NR_ftruncate, "ftruncate" , "%s(%d," TARGET_ABI_FMT_ld ")", NULL,
> NULL },
> #endif
> #ifdef TARGET_NR_ftruncate64
> -{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, NULL, NULL },
> +{ TARGET_NR_ftruncate64, "ftruncate64" , "%s(%d," TARGET_ABI_FMT_ld ")",
> NULL, NULL },
This a little bit more complicated, see function target_ftruncate64().
> #endif
> #ifdef TARGET_NR_futex
> { TARGET_NR_futex, "futex" , NULL, print_futex, NULL },
> @@ -372,7 +372,7 @@
> { TARGET_NR_getrusage, "getrusage" , NULL, NULL, NULL },
> #endif
> #ifdef TARGET_NR_getsid
> -{ TARGET_NR_getsid, "getsid" , NULL, NULL, NULL },
> +{ TARGET_NR_getsid, "getsid" , "%s(%d)", NULL, NULL },
> #endif
> #ifdef TARGET_NR_getsockname
> { TARGET_NR_getsockname, "getsockname" , NULL, NULL, NULL },
> @@ -1534,10 +1534,10 @@
> { TARGET_NR_tkill, "tkill" , NULL, print_tkill, NULL },
> #endif
> #ifdef TARGET_NR_truncate
> -{ TARGET_NR_truncate, "truncate" , NULL, NULL, NULL },
> +{ TARGET_NR_truncate, "truncate" , NULL, print_truncate, NULL },
> #endif
> #ifdef TARGET_NR_truncate64
> -{ TARGET_NR_truncate64, "truncate64" , NULL, NULL, NULL },
> +{ TARGET_NR_truncate64, "truncate64" , NULL, print_truncate64, NULL },
See target_truncate64() for the arguments decoding.
> #endif
> #ifdef TARGET_NR_tuxcall
> { TARGET_NR_tuxcall, "tuxcall" , NULL, NULL, NULL },
>
Thanks,
Laurent
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH 1/3] linux-user: Add strace support for printing arguments of truncate()/ftruncate() and getsid(),
Laurent Vivier <=