[PATCH 2/2] decode-fds: add signalfd fdinfo decoding support

Dmitry V. Levin ldv at strace.io
Sat Mar 25 21:32:48 UTC 2023


On Sun, Mar 26, 2023 at 01:06:03AM +0800, leedagee wrote:
> When signalfds are used, normal signal handling method is not used
> causing strace unable to catch these signals and therefore unable to
> decode them.
> 
> This patch adds a basic a support for signalfd fdinfo decoding.
> Decoding the buffer content needs more patch but there's also previous
> work byh esyr and masatake (see github #199).
> 
> Signed-off-by: leedagee <leedageea at gmail.com>
> ---
>  src/filter_qualify.c        |  1 +
>  src/number_set.h            |  1 +
>  src/strace.c                |  3 ++-
>  src/util.c                  | 44 +++++++++++++++++++++++++++++++++++++
>  tests/.gitignore            |  1 +
>  tests/gen_tests.in          |  3 ++-
>  tests/pure_executables.list |  1 +
>  tests/signalfd4-yy.c        |  4 ++++
>  tests/signalfd4.c           | 30 +++++++++++++++++++++----
>  9 files changed, 82 insertions(+), 6 deletions(-)
>  create mode 100644 tests/signalfd4-yy.c

The manual page needs to be updated.
Also, this worth an entry in NEWS file.

[...]
> --- a/tests/signalfd4.c
> +++ b/tests/signalfd4.c
> @@ -20,20 +20,42 @@
>  # include <sys/signalfd.h>
>  # include "kernel_fcntl.h"
>  
> +#ifndef SKIP_IF_PROC_IS_UNAVAILABLE
> +# define SKIP_IF_PROC_IS_UNAVAILABLE
> +#endif
> +
>  int
>  main(void)
>  {
> -	const char *const sigs = SIGUSR2 < SIGCHLD ? "USR2 CHLD" : "CHLD USR2";
> +	SKIP_IF_PROC_IS_UNAVAILABLE;
> +
> +	const char *const sigs1 = "USR2";
> +	const char *const sigs2 = SIGUSR2 < SIGCHLD ? "USR2 CHLD" : "CHLD USR2";
>  	const unsigned int size = get_sigset_size();
>  
>  	sigset_t mask;
>  	sigemptyset(&mask);
>  	sigaddset(&mask, SIGUSR2);
> +
> +	int fd = signalfd(-1, &mask, SFD_CLOEXEC | SFD_NONBLOCK);
> +
> +	printf("signalfd4(-1, [%s], %u, SFD_CLOEXEC|SFD_NONBLOCK) = %s",
> +	       sigs1, size, sprintrc(fd));
> +#ifdef PRINT_SIGNALFD
> +	printf("<signalfd:[%s]>\n", sigs1);
> +#else
> +	putchar('\n');
> +#endif
> +

I suggest skipping the PRINT_SIGNALFD flavour of the test when signalfd
fails.


-- 
ldv


More information about the Strace-devel mailing list