[PATCH v4 2/7] Use printpid in decoders

Dmitry V. Levin ldv at altlinux.org
Thu Jul 30 22:32:07 UTC 2020


On Mon, Jul 27, 2020 at 08:54:05PM +0200, Ákos Uzonyi wrote:
[...]
> @@ -74,6 +89,14 @@ print_fcntl(struct tcb *tcp)
>  		printflags(fdflags, tcp->u_arg[2], "FD_???");
>  		break;
>  	case F_SETOWN:
> +		tprintf(", ");
> +		const int pid = tcp->u_arg[2];
> +		tprintf("%d", pid);
> +		if (pid < 0)
> +			printpid_translation(tcp, -pid, PT_PGID);
> +		else
> +			printpid_translation(tcp,  pid, PT_TGID);
> +		break;
>  	case F_SETPIPE_SZ:
>  		tprintf(", %" PRI_kld, tcp->u_arg[2]);
>  		break;
[...]
> @@ -439,7 +439,14 @@ SYS_FUNC(sigprocmask)
>  SYS_FUNC(kill)
>  {
>  	/* pid */
> -	tprintf("%d, ", (int) tcp->u_arg[0]);
> +	int pid = (int) tcp->u_arg[0];
> +	tprintf("%d", pid);
> +	if (pid > 0)
> +		printpid_translation(tcp, pid, PT_TGID);
> +	else if (pid < -1)
> +		printpid_translation(tcp, -pid, PT_PGID);
> +
> +	tprintf(", ");
>  	/* signal */
>  	printsignal(tcp->u_arg[1]);
>  
[...]
> @@ -86,8 +86,13 @@ printwaitn(struct tcb *const tcp,
>  		 * for example, wait4(4294967295, ...) instead of -1
>  		 * in strace. We have to use int here, not long.
>  		 */
> -		int pid = tcp->u_arg[0];
> -		tprintf("%d, ", pid);
> +		int pid = (int) tcp->u_arg[0];
> +		tprintf("%d", pid);
> +		if (pid > 0)
> +			printpid_translation(tcp, pid, PT_TGID);
> +		else if (pid < -1)
> +			printpid_translation(tcp, -pid, PT_PGID);
> +		tprintf(", ");
>  	} else {
>  		int status;
>  

All these three cases have striking similarities which may warrant
a common function.


-- 
ldv


More information about the Strace-devel mailing list