Blame SOURCES/0135-Use-printpid-in-decoders.patch

089393
From 4d1964761ad04028a0e6288821ee0feef5ca8fc1 Mon Sep 17 00:00:00 2001
089393
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
089393
Date: Wed, 10 Jun 2020 13:18:50 +0200
089393
Subject: [PATCH 135/138] Use printpid in decoders
089393
089393
* getpid.c: New file.
089393
* Makefile.am (libstrace_a_SOURCES): Add it.
089393
* linux/dummy.h (sys_getpid, sys_getppid, sys_gettid,
089393
sys_setpgid, sys_setpgrp): Remove.
089393
* util.c (printfd_pid_tracee_ns): Implement using translate_pid.
089393
* defs.h (printnum_pid): New function definition.
089393
(printfd_pid_tracee_ns): Update documentation
089393
* util.c: (printnum_pid): New function.
089393
* print_fields.h (PRINT_FIELD_TID): New macro.
089393
(PRINT_FIELD_TGID): Likewise.
089393
(PRINT_FIELD_PGID): Likewise.
089393
(PRINT_FIELD_SID): Likewise.
089393
* affinity.c: Print PIDs with printpid.
089393
* block.c: Likewise.
089393
* bpf.c: Likewise.
089393
* capability.c: Likewise.
089393
* clone.c: Likewise.
089393
* fcntl.c: Likewise.
089393
* get_robust_list.c: Likewise.
089393
* ioprio.c: Likewise.
089393
* kcmp.c: Likewise.
089393
* msghdr.c: Likewise.
089393
* net.c: Likewise.
089393
* netlink.c: Likewise.
089393
* numa.c: Likewise.
089393
* pidfd_open.c: Likewise.
089393
* printsiginfo.c: Likewise.
089393
* process.c: Likewise.
089393
* process_vm.c: Likewise.
089393
* resource.c: Likewise.
089393
* sched.c: Likewise.
089393
* signal.c: Likewise.
089393
* sockaddr.c: Likewise.
089393
* wait.c: Likewise.
089393
* kcmp.c (SYS_FUNC(kcmp)): Fix KCMP_FILE pid arguments.
089393
* tests/kcmp.c (printpidfd): Print path if VERBOSE_FD.
089393
(main): Use our real pid if real fds are used.
089393
---
089393
 Makefile.am       |  1 +
089393
 affinity.c        |  6 ++++--
089393
 block.c           |  2 +-
089393
 bpf.c             |  2 +-
089393
 capability.c      |  4 +++-
089393
 clone.c           | 14 +++++++-------
089393
 defs.h            |  5 ++++-
089393
 fcntl.c           | 24 ++++++++++++++++++++++--
089393
 get_robust_list.c |  3 ++-
089393
 getpid.c          | 46 ++++++++++++++++++++++++++++++++++++++++++++++
089393
 ioprio.c          | 26 ++++++++++++++++++++++----
089393
 ipc_shmctl.c      |  4 ++--
089393
 kcmp.c            |  5 ++++-
089393
 linux/dummy.h     |  8 +-------
089393
 msghdr.c          |  2 +-
089393
 net.c             |  2 +-
089393
 netlink.c         |  5 +++--
089393
 numa.c            |  6 ++++--
089393
 pidfd_open.c      |  2 +-
089393
 print_fields.h    | 24 ++++++++++++++++++++++++
089393
 printsiginfo.c    |  2 +-
089393
 process.c         |  3 ++-
089393
 process_vm.c      |  6 ++++--
089393
 resource.c        | 27 ++++++++++++++++++++++++---
089393
 sched.c           | 25 ++++++++++++++++---------
089393
 signal.c          | 21 +++++++++++++++------
089393
 sockaddr.c        |  2 +-
089393
 tests/kcmp.c      | 25 ++++++++++++++++++++++---
089393
 util.c            | 22 +++++++++++++++-------
089393
 wait.c            | 36 ++++++++++++++++++++++++------------
089393
 30 files changed, 278 insertions(+), 82 deletions(-)
089393
 create mode 100644 getpid.c
089393
089393
Index: strace-5.7/Makefile.am
089393
===================================================================
089393
--- strace-5.7.orig/Makefile.am	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/Makefile.am	2020-09-09 18:49:06.780401433 +0200
089393
@@ -135,6 +135,7 @@
089393
 	getcpu.c	\
089393
 	getcwd.c	\
089393
 	getpagesize.c \
089393
+	getpid.c	\
089393
 	getrandom.c	\
089393
 	hdio.c		\
089393
 	hostname.c	\
089393
Index: strace-5.7/affinity.c
089393
===================================================================
089393
--- strace-5.7.orig/affinity.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/affinity.c	2020-09-09 15:55:03.979108297 +0200
089393
@@ -82,7 +82,8 @@
089393
 	const int pid = tcp->u_arg[0];
089393
 	const unsigned int len = tcp->u_arg[1];
089393
 
089393
-	tprintf("%d, %u, ", pid, len);
089393
+	printpid(tcp, pid, PT_TGID);
089393
+	tprintf(", %u, ", len);
089393
 	print_affinitylist(tcp, tcp->u_arg[2], len);
089393
 
089393
 	return RVAL_DECODED;
089393
@@ -94,7 +95,8 @@
089393
 	const unsigned int len = tcp->u_arg[1];
089393
 
089393
 	if (entering(tcp)) {
089393
-		tprintf("%d, %u, ", pid, len);
089393
+		printpid(tcp, pid, PT_TGID);
089393
+		tprintf(", %u, ", len);
089393
 	} else {
089393
 		print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
089393
 	}
089393
Index: strace-5.7/block.c
089393
===================================================================
089393
--- strace-5.7.orig/block.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/block.c	2020-09-09 15:55:03.979108297 +0200
089393
@@ -179,7 +179,7 @@
089393
 			PRINT_FIELD_U(", ", buts, buf_nr);
089393
 			PRINT_FIELD_U(", ", buts, start_lba);
089393
 			PRINT_FIELD_U(", ", buts, end_lba);
089393
-			PRINT_FIELD_D(", ", buts, pid);
089393
+			PRINT_FIELD_TGID(", ", buts, pid, tcp);
089393
 			return 0;
089393
 		} else {
089393
 			struct_blk_user_trace_setup buts;
089393
Index: strace-5.7/bpf.c
089393
===================================================================
089393
--- strace-5.7.orig/bpf.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/bpf.c	2020-09-09 15:55:03.980108298 +0200
089393
@@ -927,7 +927,7 @@
089393
 	if (entering(tcp)) {
089393
 		set_tcb_priv_ulong(tcp, attr.buf_len);
089393
 
089393
-		PRINT_FIELD_D("{task_fd_query={", attr, pid);
089393
+		PRINT_FIELD_TGID("{task_fd_query={", attr, pid, tcp);
089393
 		PRINT_FIELD_FD(", ", attr, fd, tcp);
089393
 		PRINT_FIELD_U(", ", attr, flags);
089393
 		PRINT_FIELD_U(", ", attr, buf_len);
089393
Index: strace-5.7/capability.c
089393
===================================================================
089393
--- strace-5.7.orig/capability.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/capability.c	2020-09-09 15:55:03.980108298 +0200
089393
@@ -70,7 +70,9 @@
089393
 	tprints("{version=");
089393
 	printxval(cap_version, h->version,
089393
 		  "_LINUX_CAPABILITY_VERSION_???");
089393
-	tprintf(", pid=%d}", h->pid);
089393
+	tprints(", pid=");
089393
+	printpid(tcp, h->pid, PT_TGID);
089393
+	tprints("}");
089393
 }
089393
 
089393
 static void
089393
Index: strace-5.7/clone.c
089393
===================================================================
089393
--- strace-5.7.orig/clone.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/clone.c	2020-09-09 15:55:03.980108298 +0200
089393
@@ -114,14 +114,14 @@
089393
 		 */
089393
 		if ((flags & (CLONE_PARENT_SETTID|CLONE_PIDFD|CLONE_CHILD_SETTID
089393
 			      |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
089393
-			return RVAL_DECODED;
089393
+			return RVAL_DECODED | RVAL_TID;
089393
 	} else {
089393
 		if (flags & (CLONE_PARENT_SETTID|CLONE_PIDFD)) {
089393
 			kernel_ulong_t addr = tcp->u_arg[ARG_PTID];
089393
 
089393
 			tprints(", parent_tid=");
089393
 			if (flags & CLONE_PARENT_SETTID)
089393
-				printnum_int(tcp, addr, "%u");
089393
+				printnum_pid(tcp, addr, PT_TID);
089393
 			else
089393
 				printnum_fd(tcp, addr);
089393
 		}
089393
@@ -134,7 +134,7 @@
089393
 			printaddr(tcp->u_arg[ARG_CTID]);
089393
 		}
089393
 	}
089393
-	return 0;
089393
+	return RVAL_TID;
089393
 }
089393
 
089393
 
089393
@@ -229,7 +229,7 @@
089393
 
089393
 		if ((arg.flags & (CLONE_PIDFD | CLONE_PARENT_SETTID)) ||
089393
 		    (size > fetch_size))
089393
-			return 0;
089393
+			return RVAL_TID;
089393
 
089393
 		goto out;
089393
 	}
089393
@@ -256,7 +256,7 @@
089393
 
089393
 	if (arg.flags & CLONE_PARENT_SETTID) {
089393
 		tprintf("%sparent_tid=", pfx);
089393
-		printnum_int(tcp, arg.parent_tid, "%d"); /* TID */
089393
+		printnum_pid(tcp, arg.parent_tid, PT_TID);
089393
 		pfx = ", ";
089393
 	}
089393
 
089393
@@ -279,7 +279,7 @@
089393
 out:
089393
 	tprintf(", %" PRI_klu, size);
089393
 
089393
-	return RVAL_DECODED;
089393
+	return RVAL_DECODED | RVAL_TID;
089393
 }
089393
 
089393
 
089393
@@ -300,5 +300,5 @@
089393
 
089393
 SYS_FUNC(fork)
089393
 {
089393
-	return RVAL_DECODED;
089393
+	return RVAL_DECODED | RVAL_TGID;
089393
 }
089393
Index: strace-5.7/defs.h
089393
===================================================================
089393
--- strace-5.7.orig/defs.h	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/defs.h	2020-09-09 15:55:03.980108298 +0200
089393
@@ -1101,7 +1101,7 @@
089393
 
089393
 /**
089393
  * Print file descriptor fd owned by process with ID pid (from the PID NS
089393
- * of the tracee the descriptor tcp).  This is a stub.
089393
+ * of the tracee).
089393
  */
089393
 extern void printfd_pid_tracee_ns(struct tcb *tcp, pid_t pid, int fd);
089393
 
089393
@@ -1562,6 +1562,9 @@
089393
 extern bool
089393
 printnum_fd(struct tcb *, kernel_ulong_t addr);
089393
 
089393
+extern bool
089393
+printnum_pid(struct tcb *const tcp, const kernel_ulong_t addr, enum pid_type type);
089393
+
089393
 static inline bool
089393
 printnum_slong(struct tcb *tcp, kernel_ulong_t addr)
089393
 {
089393
Index: strace-5.7/fcntl.c
089393
===================================================================
089393
--- strace-5.7.orig/fcntl.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/fcntl.c	2020-09-09 15:55:03.981108298 +0200
089393
@@ -28,7 +28,7 @@
089393
 	PRINT_FIELD_D(", ", *fl, l_start);
089393
 	PRINT_FIELD_D(", ", *fl, l_len);
089393
 	if (getlk)
089393
-		PRINT_FIELD_D(", ", *fl, l_pid);
089393
+		PRINT_FIELD_TGID(", ", *fl, l_pid, tcp);
089393
 	tprints("}");
089393
 }
089393
 
089393
@@ -59,7 +59,22 @@
089393
 		return;
089393
 
089393
 	PRINT_FIELD_XVAL("{", owner, type, f_owner_types, "F_OWNER_???");
089393
-	PRINT_FIELD_D(", ", owner, pid);
089393
+
089393
+	enum pid_type pid_type = PT_NONE;
089393
+	switch (owner.type)
089393
+	{
089393
+	case F_OWNER_TID:
089393
+		pid_type = PT_TID;
089393
+		break;
089393
+	case F_OWNER_PID:
089393
+		pid_type = PT_TGID;
089393
+		break;
089393
+	case F_OWNER_PGRP:
089393
+		pid_type = PT_PGID;
089393
+		break;
089393
+	}
089393
+	tprints(", pid=");
089393
+	printpid(tcp, owner.pid, pid_type);
089393
 	tprints("}");
089393
 }
089393
 
089393
@@ -74,6 +89,9 @@
089393
 		printflags(fdflags, tcp->u_arg[2], "FD_???");
089393
 		break;
089393
 	case F_SETOWN:
089393
+		tprints(", ");
089393
+		printpid_tgid_pgid(tcp, tcp->u_arg[2]);
089393
+		break;
089393
 	case F_SETPIPE_SZ:
089393
 		tprintf(", %" PRI_kld, tcp->u_arg[2]);
089393
 		break;
089393
@@ -116,6 +134,8 @@
089393
 		printsignal(tcp->u_arg[2]);
089393
 		break;
089393
 	case F_GETOWN:
089393
+		return RVAL_DECODED |
089393
+		       ((int) tcp->u_rval < 0 ? RVAL_PGID : RVAL_TGID);
089393
 	case F_GETPIPE_SZ:
089393
 		break;
089393
 	case F_GETFD:
089393
Index: strace-5.7/get_robust_list.c
089393
===================================================================
089393
--- strace-5.7.orig/get_robust_list.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/get_robust_list.c	2020-09-09 15:55:03.981108298 +0200
089393
@@ -10,7 +10,8 @@
089393
 SYS_FUNC(get_robust_list)
089393
 {
089393
 	if (entering(tcp)) {
089393
-		tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+		printpid(tcp, tcp->u_arg[0], PT_TID);
089393
+		tprints(", ");
089393
 	} else {
089393
 		printnum_ptr(tcp, tcp->u_arg[1]);
089393
 		tprints(", ");
089393
Index: strace-5.7/getpid.c
089393
===================================================================
089393
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
089393
+++ strace-5.7/getpid.c	2020-09-09 15:55:03.981108298 +0200
089393
@@ -0,0 +1,46 @@
089393
+/*
089393
+ * Copyright (c) 2020 Ákos Uzonyi <uzonyi.akos@gmail.com>
089393
+ * All rights reserved.
089393
+ *
089393
+ * SPDX-License-Identifier: LGPL-2.1-or-later
089393
+ */
089393
+
089393
+#include "defs.h"
089393
+
089393
+SYS_FUNC(getpid)
089393
+{
089393
+	return RVAL_DECODED | RVAL_TGID;
089393
+}
089393
+
089393
+SYS_FUNC(gettid)
089393
+{
089393
+	return RVAL_DECODED | RVAL_TID;
089393
+}
089393
+
089393
+SYS_FUNC(getpgrp)
089393
+{
089393
+	return RVAL_DECODED | RVAL_PGID;
089393
+}
089393
+
089393
+SYS_FUNC(getpgid)
089393
+{
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+
089393
+	return RVAL_DECODED | RVAL_PGID;
089393
+}
089393
+
089393
+SYS_FUNC(getsid)
089393
+{
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+
089393
+	return RVAL_DECODED | RVAL_SID;
089393
+}
089393
+
089393
+SYS_FUNC(setpgid)
089393
+{
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+	tprints(", ");
089393
+	printpid(tcp, tcp->u_arg[1], PT_PGID);
089393
+
089393
+	return RVAL_DECODED;
089393
+}
089393
Index: strace-5.7/ioprio.c
089393
===================================================================
089393
--- strace-5.7.orig/ioprio.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/ioprio.c	2020-09-09 15:55:03.981108298 +0200
089393
@@ -49,13 +49,30 @@
089393
 		? tprints_comment : tprints)(str);
089393
 }
089393
 
089393
+static void
089393
+ioprio_print_who(struct tcb *tcp, int which, int who)
089393
+{
089393
+	switch (which)
089393
+	{
089393
+	case IOPRIO_WHO_PROCESS:
089393
+		printpid(tcp, who, PT_TGID);
089393
+		break;
089393
+	case IOPRIO_WHO_PGRP:
089393
+		printpid(tcp, who, PT_PGID);
089393
+		break;
089393
+	default:
089393
+		tprintf("%d", who);
089393
+		break;
089393
+	}
089393
+}
089393
+
089393
 SYS_FUNC(ioprio_get)
089393
 {
089393
 	if (entering(tcp)) {
089393
 		/* int which */
089393
 		printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???");
089393
-		/* int who */
089393
-		tprintf(", %d", (int) tcp->u_arg[1]);
089393
+		tprints(", ");
089393
+		ioprio_print_who(tcp, tcp->u_arg[0], tcp->u_arg[1]);
089393
 		return 0;
089393
 	} else {
089393
 		if (syserror(tcp))
089393
@@ -72,8 +89,9 @@
089393
 {
089393
 	/* int which */
089393
 	printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???");
089393
-	/* int who */
089393
-	tprintf(", %d, ", (int) tcp->u_arg[1]);
089393
+	tprints(", ");
089393
+	ioprio_print_who(tcp, tcp->u_arg[0], tcp->u_arg[1]);
089393
+	tprints(", ");
089393
 	/* int ioprio */
089393
 	if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
089393
 		tprintf("%d", (int) tcp->u_arg[2]);
089393
Index: strace-5.7/ipc_shmctl.c
089393
===================================================================
089393
--- strace-5.7.orig/ipc_shmctl.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/ipc_shmctl.c	2020-09-09 15:55:03.981108298 +0200
089393
@@ -54,8 +54,8 @@
089393
 		PRINT_FIELD_UID(", ", shmid_ds.shm_perm, cgid);
089393
 		tprints("}");
089393
 		tprintf(", shm_segsz=%u", (unsigned) shmid_ds.shm_segsz);
089393
-		PRINT_FIELD_D(", ", shmid_ds, shm_cpid);
089393
-		PRINT_FIELD_D(", ", shmid_ds, shm_lpid);
089393
+		PRINT_FIELD_TGID(", ", shmid_ds, shm_cpid, tcp);
089393
+		PRINT_FIELD_TGID(", ", shmid_ds, shm_lpid, tcp);
089393
 		tprintf(", shm_nattch=%u", (unsigned) shmid_ds.shm_nattch);
089393
 		tprintf(", shm_atime=%u", (unsigned) shmid_ds.shm_atime);
089393
 		tprintf(", shm_dtime=%u", (unsigned) shmid_ds.shm_dtime);
089393
Index: strace-5.7/kcmp.c
089393
===================================================================
089393
--- strace-5.7.orig/kcmp.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/kcmp.c	2020-09-09 15:55:03.981108298 +0200
089393
@@ -30,7 +30,10 @@
089393
 	kernel_ulong_t idx1 = tcp->u_arg[3];
089393
 	kernel_ulong_t idx2 = tcp->u_arg[4];
089393
 
089393
-	tprintf("%d, %d, ", pid1, pid2);
089393
+	printpid(tcp, pid1, PT_TGID);
089393
+	tprints(", ");
089393
+	printpid(tcp, pid2, PT_TGID);
089393
+	tprints(", ");
089393
 	printxval(kcmp_types, type, "KCMP_???");
089393
 
089393
 	switch (type) {
089393
Index: strace-5.7/linux/dummy.h
089393
===================================================================
089393
--- strace-5.7.orig/linux/dummy.h	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/linux/dummy.h	2020-09-09 15:55:03.982108299 +0200
089393
@@ -53,6 +53,7 @@
089393
 # define sys_getgid		sys_getuid
089393
 # define sys_getgid16		sys_getuid16
089393
 # define sys_getpeername		sys_getsockname
089393
+# define sys_getppid		sys_getpid
089393
 # define sys_getresgid		sys_getresuid
089393
 # define sys_getresgid16		sys_getresuid16
089393
 # define sys_lstat		sys_stat
089393
@@ -87,10 +88,6 @@
089393
 # define sys_vfork		sys_fork
089393
 
089393
 /* printargs does the right thing */
089393
-# define sys_getpgrp		printargs
089393
-# define sys_getpid		printargs
089393
-# define sys_getppid		printargs
089393
-# define sys_gettid		printargs
089393
 # define sys_idle		printargs
089393
 # define sys_munlockall		printargs
089393
 # define sys_pause		printargs
089393
@@ -108,10 +105,7 @@
089393
 
089393
 /* printargs_d does the right thing */
089393
 # define sys_exit		printargs_d
089393
-# define sys_getpgid		printargs_d
089393
-# define sys_getsid		printargs_d
089393
 # define sys_nice		printargs_d
089393
-# define sys_setpgid		printargs_d
089393
 # define sys_setpgrp		printargs_d
089393
 # define sys_timer_delete	printargs_d
089393
 # define sys_timer_getoverrun	printargs_d
089393
Index: strace-5.7/msghdr.c
089393
===================================================================
089393
--- strace-5.7.orig/msghdr.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/msghdr.c	2020-09-09 15:55:03.982108299 +0200
089393
@@ -69,7 +69,7 @@
089393
 {
089393
 	const struct ucred *uc = cmsg_data;
089393
 
089393
-	PRINT_FIELD_D("{", *uc, pid);
089393
+	PRINT_FIELD_TGID("{", *uc, pid, tcp);
089393
 	PRINT_FIELD_UID(", ", *uc, uid);
089393
 	PRINT_FIELD_UID(", ", *uc, gid);
089393
 	tprints("}");
089393
Index: strace-5.7/net.c
089393
===================================================================
089393
--- strace-5.7.orig/net.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/net.c	2020-09-09 15:55:03.982108299 +0200
089393
@@ -601,7 +601,7 @@
089393
 	if (umoven_or_printaddr(tcp, addr, len, &uc))
089393
 		return;
089393
 
089393
-	PRINT_FIELD_LEN("{", uc, pid, len, PRINT_FIELD_D);
089393
+	PRINT_FIELD_LEN("{", uc, pid, len, PRINT_FIELD_TGID, tcp);
089393
 	PRINT_FIELD_LEN(", ", uc, uid, len, PRINT_FIELD_UID);
089393
 	PRINT_FIELD_LEN(", ", uc, gid, len, PRINT_FIELD_UID);
089393
 	tprints("}");
089393
Index: strace-5.7/netlink.c
089393
===================================================================
089393
--- strace-5.7.orig/netlink.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/netlink.c	2020-09-09 15:55:03.982108299 +0200
089393
@@ -446,8 +446,9 @@
089393
 	decode_nlmsg_flags(nlmsghdr->nlmsg_flags,
089393
 			   nlmsghdr->nlmsg_type, family);
089393
 
089393
-	tprintf(", seq=%u, pid=%d}", nlmsghdr->nlmsg_seq,
089393
-		nlmsghdr->nlmsg_pid);
089393
+	tprintf(", seq=%u, pid=", nlmsghdr->nlmsg_seq);
089393
+	printpid(tcp, nlmsghdr->nlmsg_pid, PT_TGID);
089393
+	tprints("}");
089393
 }
089393
 
089393
 static bool
089393
Index: strace-5.7/numa.c
089393
===================================================================
089393
--- strace-5.7.orig/numa.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/numa.c	2020-09-09 15:55:03.982108299 +0200
089393
@@ -44,7 +44,8 @@
089393
 
089393
 SYS_FUNC(migrate_pages)
089393
 {
089393
-	tprintf("%d, %" PRI_klu ", ", (int) tcp->u_arg[0], tcp->u_arg[1]);
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+	tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
089393
 	print_nodemask(tcp, tcp->u_arg[2], tcp->u_arg[1]);
089393
 	tprints(", ");
089393
 	print_nodemask(tcp, tcp->u_arg[3], tcp->u_arg[1]);
089393
@@ -170,7 +171,8 @@
089393
 	kernel_ulong_t buf;
089393
 
089393
 	if (entering(tcp)) {
089393
-		tprintf("%d, %" PRI_klu ", ", (int) tcp->u_arg[0], npages);
089393
+		printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+		tprintf(", %" PRI_klu ", ", npages);
089393
 		print_array(tcp, tcp->u_arg[2], npages, &buf, current_wordsize,
089393
 			    tfetch_mem, print_addr, 0);
089393
 		tprints(", ");
089393
Index: strace-5.7/pidfd_open.c
089393
===================================================================
089393
--- strace-5.7.orig/pidfd_open.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/pidfd_open.c	2020-09-09 15:55:03.983108300 +0200
089393
@@ -10,7 +10,7 @@
089393
 SYS_FUNC(pidfd_open)
089393
 {
089393
 	/* pid_t pid */
089393
-	tprintf("%d", (int) tcp->u_arg[0]);
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
 
089393
 	/* unsigned int flags */
089393
 	tprintf(", %#x", (unsigned int) tcp->u_arg[1]);
089393
Index: strace-5.7/print_fields.h
089393
===================================================================
089393
--- strace-5.7.orig/print_fields.h	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/print_fields.h	2020-09-09 15:55:03.983108300 +0200
089393
@@ -236,6 +236,30 @@
089393
 		printfd((tcp_), (where_).field_);			\
089393
 	} while (0)
089393
 
089393
+# define PRINT_FIELD_TID(prefix_, where_, field_, tcp_)			\
089393
+	do {								\
089393
+		STRACE_PRINTF("%s%s=", (prefix_), #field_);		\
089393
+		printpid((tcp_), (where_).field_, PT_TID);			\
089393
+	} while (0)
089393
+
089393
+# define PRINT_FIELD_TGID(prefix_, where_, field_, tcp_)			\
089393
+	do {								\
089393
+		STRACE_PRINTF("%s%s=", (prefix_), #field_);		\
089393
+		printpid((tcp_), (where_).field_, PT_TGID);			\
089393
+	} while (0)
089393
+
089393
+# define PRINT_FIELD_PGID(prefix_, where_, field_, tcp_)			\
089393
+	do {								\
089393
+		STRACE_PRINTF("%s%s=", (prefix_), #field_);		\
089393
+		printpid((tcp_), (where_).field_, PT_PGID);			\
089393
+	} while (0)
089393
+
089393
+# define PRINT_FIELD_SID(prefix_, where_, field_, tcp_)			\
089393
+	do {								\
089393
+		STRACE_PRINTF("%s%s=", (prefix_), #field_);		\
089393
+		printpid((tcp_), (where_).field_, PT_SID);			\
089393
+	} while (0)
089393
+
089393
 # define PRINT_FIELD_STRN(prefix_, where_, field_, len_, tcp_)		\
089393
 	do {								\
089393
 		STRACE_PRINTF("%s%s=", (prefix_), #field_);		\
089393
Index: strace-5.7/printsiginfo.c
089393
===================================================================
089393
--- strace-5.7.orig/printsiginfo.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/printsiginfo.c	2020-09-09 15:55:03.983108300 +0200
089393
@@ -58,7 +58,7 @@
089393
 static void
089393
 printsigsource(struct tcb *tcp, const siginfo_t *sip)
089393
 {
089393
-	PRINT_FIELD_D(", ", *sip, si_pid);
089393
+	PRINT_FIELD_TGID(", ", *sip, si_pid, tcp);
089393
 	PRINT_FIELD_UID(", ", *sip, si_uid);
089393
 }
089393
 
089393
Index: strace-5.7/process.c
089393
===================================================================
089393
--- strace-5.7.orig/process.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/process.c	2020-09-09 15:55:03.983108300 +0200
089393
@@ -92,7 +92,8 @@
089393
 		}
089393
 
089393
 		/* pid */
089393
-		tprintf(", %d", pid);
089393
+		tprints(", ");
089393
+		printpid(tcp, pid, PT_TGID);
089393
 
089393
 		/* addr */
089393
 		switch (request) {
089393
Index: strace-5.7/process_vm.c
089393
===================================================================
089393
--- strace-5.7.orig/process_vm.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/process_vm.c	2020-09-09 15:55:03.983108300 +0200
089393
@@ -13,7 +13,8 @@
089393
 {
089393
 	if (entering(tcp)) {
089393
 		/* arg 1: pid */
089393
-		tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+		printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+		tprints(", ");
089393
 	} else {
089393
 		kernel_ulong_t local_iovcnt = tcp->u_arg[2];
089393
 		kernel_ulong_t remote_iovcnt = tcp->u_arg[4];
089393
@@ -42,7 +43,8 @@
089393
 	kernel_ulong_t flags = tcp->u_arg[5];
089393
 
089393
 	/* arg 1: pid */
089393
-	tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+	tprints(", ");
089393
 	/* arg 2: local iov */
089393
 	tprint_iov(tcp, local_iovcnt, tcp->u_arg[1], IOV_DECODE_STR);
089393
 	/* arg 3: local iovcnt */
089393
Index: strace-5.7/resource.c
089393
===================================================================
089393
--- strace-5.7.orig/resource.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/resource.c	2020-09-09 15:55:03.984108300 +0200
089393
@@ -142,7 +142,8 @@
089393
 SYS_FUNC(prlimit64)
089393
 {
089393
 	if (entering(tcp)) {
089393
-		tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+		printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+		tprints(", ");
089393
 		printxval(resources, tcp->u_arg[1], "RLIMIT_???");
089393
 		tprints(", ");
089393
 		print_rlimit64(tcp, tcp->u_arg[2]);
089393
@@ -179,10 +180,28 @@
089393
 
089393
 #include "xlat/priorities.h"
089393
 
089393
+static void
089393
+priority_print_who(struct tcb *tcp, int which, int who)
089393
+{
089393
+	switch (which)
089393
+	{
089393
+	case PRIO_PROCESS:
089393
+		printpid(tcp, who, PT_TGID);
089393
+		break;
089393
+	case PRIO_PGRP:
089393
+		printpid(tcp, who, PT_PGID);
089393
+		break;
089393
+	default:
089393
+		tprintf("%d", who);
089393
+		break;
089393
+	}
089393
+}
089393
+
089393
 SYS_FUNC(getpriority)
089393
 {
089393
 	printxval(priorities, tcp->u_arg[0], "PRIO_???");
089393
-	tprintf(", %d", (int) tcp->u_arg[1]);
089393
+	tprints(", ");
089393
+	priority_print_who(tcp, tcp->u_arg[0], tcp->u_arg[1]);
089393
 
089393
 	return RVAL_DECODED;
089393
 }
089393
@@ -190,7 +209,9 @@
089393
 SYS_FUNC(setpriority)
089393
 {
089393
 	printxval(priorities, tcp->u_arg[0], "PRIO_???");
089393
-	tprintf(", %d, %d", (int) tcp->u_arg[1], (int) tcp->u_arg[2]);
089393
+	tprints(", ");
089393
+	priority_print_who(tcp, tcp->u_arg[0], tcp->u_arg[1]);
089393
+	tprintf(", %d", (int) tcp->u_arg[2]);
089393
 
089393
 	return RVAL_DECODED;
089393
 }
089393
Index: strace-5.7/sched.c
089393
===================================================================
089393
--- strace-5.7.orig/sched.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/sched.c	2020-09-09 15:55:03.984108300 +0200
089393
@@ -21,7 +21,7 @@
089393
 SYS_FUNC(sched_getscheduler)
089393
 {
089393
 	if (entering(tcp)) {
089393
-		tprintf("%d", (int) tcp->u_arg[0]);
089393
+		printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
 	} else if (!syserror(tcp)) {
089393
 		tcp->auxstr = xlookup(schedulers, (kernel_ulong_t) tcp->u_rval);
089393
 		return RVAL_STR;
089393
@@ -31,7 +31,8 @@
089393
 
089393
 SYS_FUNC(sched_setscheduler)
089393
 {
089393
-	tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+	tprints(", ");
089393
 	printxval(schedulers, tcp->u_arg[1], "SCHED_???");
089393
 	tprints(", ");
089393
 	printnum_int(tcp, tcp->u_arg[2], "%d");
089393
@@ -41,16 +42,19 @@
089393
 
089393
 SYS_FUNC(sched_getparam)
089393
 {
089393
-	if (entering(tcp))
089393
-		tprintf("%d, ", (int) tcp->u_arg[0]);
089393
-	else
089393
+	if (entering(tcp)) {
089393
+		printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+		tprints(", ");
089393
+	} else {
089393
 		printnum_int(tcp, tcp->u_arg[1], "%d");
089393
+	}
089393
 	return 0;
089393
 }
089393
 
089393
 SYS_FUNC(sched_setparam)
089393
 {
089393
-	tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+	tprints(", ");
089393
 	printnum_int(tcp, tcp->u_arg[1], "%d");
089393
 
089393
 	return RVAL_DECODED;
089393
@@ -68,7 +72,8 @@
089393
 			 const print_obj_by_addr_fn print_ts)
089393
 {
089393
 	if (entering(tcp)) {
089393
-		tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+		printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+		tprints(", ");
089393
 	} else {
089393
 		if (syserror(tcp))
089393
 			printaddr(tcp->u_arg[1]);
089393
@@ -160,7 +165,8 @@
089393
 SYS_FUNC(sched_setattr)
089393
 {
089393
 	if (entering(tcp)) {
089393
-		tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+		printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+		tprints(", ");
089393
 		print_sched_attr(tcp, tcp->u_arg[1], 0);
089393
 	} else {
089393
 		struct sched_attr attr;
089393
@@ -179,7 +185,8 @@
089393
 SYS_FUNC(sched_getattr)
089393
 {
089393
 	if (entering(tcp)) {
089393
-		tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+		printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+		tprints(", ");
089393
 	} else {
089393
 		const unsigned int size = tcp->u_arg[2];
089393
 
089393
Index: strace-5.7/signal.c
089393
===================================================================
089393
--- strace-5.7.orig/signal.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/signal.c	2020-09-09 15:55:03.984108300 +0200
089393
@@ -439,7 +439,8 @@
089393
 SYS_FUNC(kill)
089393
 {
089393
 	/* pid */
089393
-	tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+	printpid_tgid_pgid(tcp, tcp->u_arg[0]);
089393
+	tprints(", ");
089393
 	/* signal */
089393
 	printsignal(tcp->u_arg[1]);
089393
 
089393
@@ -448,7 +449,7 @@
089393
 
089393
 SYS_FUNC(tkill)
089393
 {
089393
-	tprintf("%d", (int) tcp->u_arg[0]);
089393
+	printpid(tcp, tcp->u_arg[0], PT_TID);
089393
 	tprints(", ");
089393
 	printsignal(tcp->u_arg[1]);
089393
 
089393
@@ -457,8 +458,12 @@
089393
 
089393
 SYS_FUNC(tgkill)
089393
 {
089393
-	/* tgid, tid */
089393
-	tprintf("%d, %d, ", (int) tcp->u_arg[0], (int) tcp->u_arg[1]);
089393
+	/* tgid */
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+	tprints(", ");
089393
+	/* tid */
089393
+	printpid(tcp, tcp->u_arg[1], PT_TID);
089393
+	tprints(", ");
089393
 	/* signal */
089393
 	printsignal(tcp->u_arg[2]);
089393
 
089393
@@ -624,7 +629,8 @@
089393
 
089393
 SYS_FUNC(rt_sigqueueinfo)
089393
 {
089393
-	tprintf("%d, ", (int) tcp->u_arg[0]);
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+	tprints(", ");
089393
 	print_sigqueueinfo(tcp, tcp->u_arg[1], tcp->u_arg[2]);
089393
 
089393
 	return RVAL_DECODED;
089393
@@ -632,7 +638,10 @@
089393
 
089393
 SYS_FUNC(rt_tgsigqueueinfo)
089393
 {
089393
-	tprintf("%d, %d, ", (int) tcp->u_arg[0], (int) tcp->u_arg[1]);
089393
+	printpid(tcp, tcp->u_arg[0], PT_TGID);
089393
+	tprints(", ");
089393
+	printpid(tcp, tcp->u_arg[1], PT_TID);
089393
+	tprints(", ");
089393
 	print_sigqueueinfo(tcp, tcp->u_arg[2], tcp->u_arg[3]);
089393
 
089393
 	return RVAL_DECODED;
089393
Index: strace-5.7/sockaddr.c
089393
===================================================================
089393
--- strace-5.7.orig/sockaddr.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/sockaddr.c	2020-09-09 15:55:03.984108300 +0200
089393
@@ -416,7 +416,7 @@
089393
 {
089393
 	const struct sockaddr_nl *const sa_nl = buf;
089393
 
089393
-	PRINT_FIELD_D("", *sa_nl, nl_pid);
089393
+	PRINT_FIELD_TGID("", *sa_nl, nl_pid, tcp);
089393
 	PRINT_FIELD_0X(", ", *sa_nl, nl_groups);
089393
 }
089393
 
089393
Index: strace-5.7/tests/kcmp.c
089393
===================================================================
089393
--- strace-5.7.orig/tests/kcmp.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/tests/kcmp.c	2020-09-09 18:49:06.780401433 +0200
089393
@@ -64,7 +64,26 @@
089393
 static void
089393
 printpidfd(const char *prefix, pid_t pid, unsigned fd)
089393
 {
089393
-	printf("%s%d", prefix, fd);
089393
+	const char *path = NULL;
089393
+
089393
+# if VERBOSE_FD
089393
+	if (pid == getpid()) {
089393
+		switch (fd)
089393
+		{
089393
+		case NULL_FD:
089393
+			path = null_path;
089393
+			break;
089393
+		case ZERO_FD:
089393
+			path = zero_path;
089393
+			break;
089393
+		}
089393
+	}
089393
+# endif
089393
+
089393
+	if (path)
089393
+		printf("%s%d<%s>", prefix, fd, path);
089393
+	else
089393
+		printf("%s%d", prefix, fd);
089393
 }
089393
 
089393
 /*
089393
@@ -179,7 +198,7 @@
089393
 	/* KCMP_FILE is the only type which has additional args */
089393
 	do_kcmp(3141592653U, 2718281828U, ARG_STR(KCMP_FILE), bogus_idx1,
089393
 		bogus_idx2);
089393
-	do_kcmp(-1, -1, ARG_STR(KCMP_FILE), NULL_FD, ZERO_FD);
089393
+	do_kcmp(getpid(), getpid(), ARG_STR(KCMP_FILE), NULL_FD, ZERO_FD);
089393
 
089393
 	/* Types without additional args */
089393
 	do_kcmp(-1, -1, ARG_STR(KCMP_VM), bogus_idx1, bogus_idx2);
089393
@@ -198,7 +217,7 @@
089393
 	for (i = 0; i < ARRAY_SIZE(slot_data); i++) {
089393
 		memcpy(slot, slot_data + i, sizeof(*slot));
089393
 
089393
-		do_kcmp(getpid(), getppid(), ARG_STR(KCMP_EPOLL_TFD), NULL_FD,
089393
+		do_kcmp(getpid(), -1, ARG_STR(KCMP_EPOLL_TFD), NULL_FD,
089393
 			(uintptr_t) slot, 1);
089393
 	}
089393
 
089393
Index: strace-5.7/util.c
089393
===================================================================
089393
--- strace-5.7.orig/util.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/util.c	2020-09-09 18:49:07.951402131 +0200
089393
@@ -392,6 +392,18 @@
089393
 	return true;
089393
 }
089393
 
089393
+bool
089393
+printnum_pid(struct tcb *const tcp, const kernel_ulong_t addr, enum pid_type type)
089393
+{
089393
+	int pid;
089393
+	if (umove_or_printaddr(tcp, addr, &pid))
089393
+		return false;
089393
+	tprints("[");
089393
+	printpid(tcp, pid, type);
089393
+	tprints("]");
089393
+	return true;
089393
+}
089393
+
089393
 /**
089393
  * Prints time to a (static internal) buffer and returns pointer to it.
089393
  * Returns NULL if the provided time specification is not correct.
089393
@@ -616,7 +628,7 @@
089393
 printfd_pid(struct tcb *tcp, pid_t pid, int fd)
089393
 {
089393
 	char path[PATH_MAX + 1];
089393
-	if (!number_set_array_is_empty(decode_fd_set, 0)
089393
+	if (pid > 0 && !number_set_array_is_empty(decode_fd_set, 0)
089393
 	    && getfdpath_pid(pid, fd, path, sizeof(path)) >= 0) {
089393
 		tprintf("%d<", (int) fd);
089393
 		if (is_number_in_set(DECODE_FD_SOCKET, decode_fd_set) &&
089393
@@ -641,12 +653,8 @@
089393
 void
089393
 printfd_pid_tracee_ns(struct tcb *tcp, pid_t pid, int fd)
089393
 {
089393
-	/*
089393
-	 * TODO: We want to have the same formatting as printfd here,
089393
-	 *       but we should figure out first which process in strace's
089393
-	 *       PID NS is referred to by pid in tracee's PID NS.
089393
-	 */
089393
-	tprintf("%d", fd);
089393
+	int strace_pid = translate_pid(tcp, pid, PT_TGID, NULL);
089393
+	printfd_pid(tcp, strace_pid, fd);
089393
 }
089393
 
089393
 /*
089393
Index: strace-5.7/wait.c
089393
===================================================================
089393
--- strace-5.7.orig/wait.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/wait.c	2020-09-09 15:55:03.985108301 +0200
089393
@@ -80,14 +80,8 @@
089393
 	   void (*const print_rusage)(struct tcb *, kernel_ulong_t))
089393
 {
089393
 	if (entering(tcp)) {
089393
-		/* On Linux, kernel-side pid_t is typedef'ed to int
089393
-		 * on all arches. Also, glibc-2.8 truncates wait3 and wait4
089393
-		 * pid argument to int on 64bit arches, producing,
089393
-		 * for example, wait4(4294967295, ...) instead of -1
089393
-		 * in strace. We have to use int here, not long.
089393
-		 */
089393
-		int pid = tcp->u_arg[0];
089393
-		tprintf("%d, ", pid);
089393
+		printpid_tgid_pgid(tcp, tcp->u_arg[0]);
089393
+		tprintf(", ");
089393
 	} else {
089393
 		int status;
089393
 
089393
@@ -108,7 +102,7 @@
089393
 				printaddr(tcp->u_arg[3]);
089393
 		}
089393
 	}
089393
-	return 0;
089393
+	return RVAL_TGID;
089393
 }
089393
 
089393
 SYS_FUNC(waitpid)
089393
@@ -134,10 +128,28 @@
089393
 
089393
 SYS_FUNC(waitid)
089393
 {
089393
+	unsigned int idtype = (unsigned int) tcp->u_arg[0];
089393
+	int id = tcp->u_arg[1];
089393
+
089393
 	if (entering(tcp)) {
089393
-		printxval(waitid_types, tcp->u_arg[0], "P_???");
089393
-		int pid = tcp->u_arg[1];
089393
-		tprintf(", %d, ", pid);
089393
+		printxval(waitid_types, idtype, "P_???");
089393
+		tprints(", ");
089393
+		switch (idtype)
089393
+		{
089393
+		case P_PID:
089393
+			printpid(tcp, id, PT_TGID);
089393
+			break;
089393
+		case P_PIDFD:
089393
+			printfd(tcp, id);
089393
+			break;
089393
+		case P_PGID:
089393
+			printpid(tcp, id, PT_PGID);
089393
+			break;
089393
+		default:
089393
+			tprintf("%d", id);
089393
+			break;
089393
+		}
089393
+		tprints(", ");
089393
 	} else {
089393
 		/* siginfo */
089393
 		printsiginfo_at(tcp, tcp->u_arg[2]);
089393
Index: strace-5.7/tests-m32/kcmp.c
089393
===================================================================
089393
--- strace-5.7.orig/tests-m32/kcmp.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/tests-m32/kcmp.c	2020-09-09 18:49:06.780401433 +0200
089393
@@ -64,7 +64,26 @@
089393
 static void
089393
 printpidfd(const char *prefix, pid_t pid, unsigned fd)
089393
 {
089393
-	printf("%s%d", prefix, fd);
089393
+	const char *path = NULL;
089393
+
089393
+# if VERBOSE_FD
089393
+	if (pid == getpid()) {
089393
+		switch (fd)
089393
+		{
089393
+		case NULL_FD:
089393
+			path = null_path;
089393
+			break;
089393
+		case ZERO_FD:
089393
+			path = zero_path;
089393
+			break;
089393
+		}
089393
+	}
089393
+# endif
089393
+
089393
+	if (path)
089393
+		printf("%s%d<%s>", prefix, fd, path);
089393
+	else
089393
+		printf("%s%d", prefix, fd);
089393
 }
089393
 
089393
 /*
089393
@@ -179,7 +198,7 @@
089393
 	/* KCMP_FILE is the only type which has additional args */
089393
 	do_kcmp(3141592653U, 2718281828U, ARG_STR(KCMP_FILE), bogus_idx1,
089393
 		bogus_idx2);
089393
-	do_kcmp(-1, -1, ARG_STR(KCMP_FILE), NULL_FD, ZERO_FD);
089393
+	do_kcmp(getpid(), getpid(), ARG_STR(KCMP_FILE), NULL_FD, ZERO_FD);
089393
 
089393
 	/* Types without additional args */
089393
 	do_kcmp(-1, -1, ARG_STR(KCMP_VM), bogus_idx1, bogus_idx2);
089393
@@ -198,7 +217,7 @@
089393
 	for (i = 0; i < ARRAY_SIZE(slot_data); i++) {
089393
 		memcpy(slot, slot_data + i, sizeof(*slot));
089393
 
089393
-		do_kcmp(getpid(), getppid(), ARG_STR(KCMP_EPOLL_TFD), NULL_FD,
089393
+		do_kcmp(getpid(), -1, ARG_STR(KCMP_EPOLL_TFD), NULL_FD,
089393
 			(uintptr_t) slot, 1);
089393
 	}
089393
 
089393
Index: strace-5.7/tests-mx32/kcmp.c
089393
===================================================================
089393
--- strace-5.7.orig/tests-mx32/kcmp.c	2020-09-09 15:52:09.159983257 +0200
089393
+++ strace-5.7/tests-mx32/kcmp.c	2020-09-09 18:49:06.780401433 +0200
089393
@@ -64,7 +64,26 @@
089393
 static void
089393
 printpidfd(const char *prefix, pid_t pid, unsigned fd)
089393
 {
089393
-	printf("%s%d", prefix, fd);
089393
+	const char *path = NULL;
089393
+
089393
+# if VERBOSE_FD
089393
+	if (pid == getpid()) {
089393
+		switch (fd)
089393
+		{
089393
+		case NULL_FD:
089393
+			path = null_path;
089393
+			break;
089393
+		case ZERO_FD:
089393
+			path = zero_path;
089393
+			break;
089393
+		}
089393
+	}
089393
+# endif
089393
+
089393
+	if (path)
089393
+		printf("%s%d<%s>", prefix, fd, path);
089393
+	else
089393
+		printf("%s%d", prefix, fd);
089393
 }
089393
 
089393
 /*
089393
@@ -179,7 +198,7 @@
089393
 	/* KCMP_FILE is the only type which has additional args */
089393
 	do_kcmp(3141592653U, 2718281828U, ARG_STR(KCMP_FILE), bogus_idx1,
089393
 		bogus_idx2);
089393
-	do_kcmp(-1, -1, ARG_STR(KCMP_FILE), NULL_FD, ZERO_FD);
089393
+	do_kcmp(getpid(), getpid(), ARG_STR(KCMP_FILE), NULL_FD, ZERO_FD);
089393
 
089393
 	/* Types without additional args */
089393
 	do_kcmp(-1, -1, ARG_STR(KCMP_VM), bogus_idx1, bogus_idx2);
089393
@@ -198,7 +217,7 @@
089393
 	for (i = 0; i < ARRAY_SIZE(slot_data); i++) {
089393
 		memcpy(slot, slot_data + i, sizeof(*slot));
089393
 
089393
-		do_kcmp(getpid(), getppid(), ARG_STR(KCMP_EPOLL_TFD), NULL_FD,
089393
+		do_kcmp(getpid(), -1, ARG_STR(KCMP_EPOLL_TFD), NULL_FD,
089393
 			(uintptr_t) slot, 1);
089393
 	}
089393
 
089393
Index: strace-5.7/Makefile.in
089393
===================================================================
089393
--- strace-5.7.orig/Makefile.in	2020-09-09 15:54:59.569105143 +0200
089393
+++ strace-5.7/Makefile.in	2020-09-09 19:06:15.159014394 +0200
089393
@@ -322,13 +322,13 @@
089393
 	flock.c flock.h fs_x_ioctl.c fsconfig.c fsmount.c fsopen.c \
089393
 	fspick.c fstatfs.c fstatfs64.c futex.c gcc_compat.h \
089393
 	get_personality.c get_personality.h get_robust_list.c getcpu.c \
089393
-	getcwd.c getpagesize.c getrandom.c hdio.c hostname.c inotify.c \
089393
-	inotify_ioctl.c io.c io_uring.c ioctl.c ioperm.c iopl.c \
089393
-	ioprio.c ipc.c ipc_defs.h ipc_msg.c ipc_msgctl.c ipc_sem.c \
089393
-	ipc_shm.c ipc_shmctl.c kcmp.c kernel_dirent.h kernel_rusage.h \
089393
-	kernel_timespec.h kernel_timeval.h kernel_timex.h \
089393
-	kernel_types.h kernel_v4l2_types.h kexec.c keyctl.c \
089393
-	keyctl_kdf_params.h kill_save_errno.h kvm.c \
089393
+	getcwd.c getpagesize.c getpid.c getrandom.c hdio.c hostname.c \
089393
+	inotify.c inotify_ioctl.c io.c io_uring.c ioctl.c ioperm.c \
089393
+	iopl.c ioprio.c ipc.c ipc_defs.h ipc_msg.c ipc_msgctl.c \
089393
+	ipc_sem.c ipc_shm.c ipc_shmctl.c kcmp.c kernel_dirent.h \
089393
+	kernel_rusage.h kernel_timespec.h kernel_timeval.h \
089393
+	kernel_timex.h kernel_types.h kernel_v4l2_types.h kexec.c \
089393
+	keyctl.c keyctl_kdf_params.h kill_save_errno.h kvm.c \
089393
 	largefile_wrappers.h ldt.c link.c linux/asm_stat.h \
089393
 	linux/x32/asm_stat.h linux/x86_64/asm_stat.h list.h listen.c \
089393
 	lookup_dcookie.c loop.c lseek.c macros.h mem.c membarrier.c \
089393
@@ -443,7 +443,7 @@
089393
 	libstrace_a-get_personality.$(OBJEXT) \
089393
 	libstrace_a-get_robust_list.$(OBJEXT) \
089393
 	libstrace_a-getcpu.$(OBJEXT) libstrace_a-getcwd.$(OBJEXT) \
089393
-	libstrace_a-getpagesize.$(OBJEXT) \
089393
+	libstrace_a-getpagesize.$(OBJEXT) libstrace_a-getpid.$(OBJEXT) \
089393
 	libstrace_a-getrandom.$(OBJEXT) libstrace_a-hdio.$(OBJEXT) \
089393
 	libstrace_a-hostname.$(OBJEXT) libstrace_a-inotify.$(OBJEXT) \
089393
 	libstrace_a-inotify_ioctl.$(OBJEXT) libstrace_a-io.$(OBJEXT) \
089393
@@ -769,6 +769,7 @@
089393
 	./$(DEPDIR)/libstrace_a-getcpu.Po \
089393
 	./$(DEPDIR)/libstrace_a-getcwd.Po \
089393
 	./$(DEPDIR)/libstrace_a-getpagesize.Po \
089393
+	./$(DEPDIR)/libstrace_a-getpid.Po \
089393
 	./$(DEPDIR)/libstrace_a-getrandom.Po \
089393
 	./$(DEPDIR)/libstrace_a-hdio.Po \
089393
 	./$(DEPDIR)/libstrace_a-hostname.Po \
089393
@@ -1810,13 +1811,13 @@
089393
 	flock.c flock.h fs_x_ioctl.c fsconfig.c fsmount.c fsopen.c \
089393
 	fspick.c fstatfs.c fstatfs64.c futex.c gcc_compat.h \
089393
 	get_personality.c get_personality.h get_robust_list.c getcpu.c \
089393
-	getcwd.c getpagesize.c getrandom.c hdio.c hostname.c inotify.c \
089393
-	inotify_ioctl.c io.c io_uring.c ioctl.c ioperm.c iopl.c \
089393
-	ioprio.c ipc.c ipc_defs.h ipc_msg.c ipc_msgctl.c ipc_sem.c \
089393
-	ipc_shm.c ipc_shmctl.c kcmp.c kernel_dirent.h kernel_rusage.h \
089393
-	kernel_timespec.h kernel_timeval.h kernel_timex.h \
089393
-	kernel_types.h kernel_v4l2_types.h kexec.c keyctl.c \
089393
-	keyctl_kdf_params.h kill_save_errno.h kvm.c \
089393
+	getcwd.c getpagesize.c getpid.c getrandom.c hdio.c hostname.c \
089393
+	inotify.c inotify_ioctl.c io.c io_uring.c ioctl.c ioperm.c \
089393
+	iopl.c ioprio.c ipc.c ipc_defs.h ipc_msg.c ipc_msgctl.c \
089393
+	ipc_sem.c ipc_shm.c ipc_shmctl.c kcmp.c kernel_dirent.h \
089393
+	kernel_rusage.h kernel_timespec.h kernel_timeval.h \
089393
+	kernel_timex.h kernel_types.h kernel_v4l2_types.h kexec.c \
089393
+	keyctl.c keyctl_kdf_params.h kill_save_errno.h kvm.c \
089393
 	largefile_wrappers.h ldt.c link.c linux/asm_stat.h \
089393
 	linux/x32/asm_stat.h linux/x86_64/asm_stat.h list.h listen.c \
089393
 	lookup_dcookie.c loop.c lseek.c macros.h mem.c membarrier.c \
089393
@@ -2835,6 +2836,7 @@
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-getcpu.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-getcwd.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-getpagesize.Po@am__quote@ # am--include-marker
089393
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-getpid.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-getrandom.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-hdio.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-hostname.Po@am__quote@ # am--include-marker
089393
@@ -5082,6 +5084,20 @@
089393
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -c -o libstrace_a-getpagesize.obj `if test -f 'getpagesize.c'; then $(CYGPATH_W) 'getpagesize.c'; else $(CYGPATH_W) '$(srcdir)/getpagesize.c'; fi`
089393
 
089393
+libstrace_a-getpid.o: getpid.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -MT libstrace_a-getpid.o -MD -MP -MF $(DEPDIR)/libstrace_a-getpid.Tpo -c -o libstrace_a-getpid.o `test -f 'getpid.c' || echo '$(srcdir)/'`getpid.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstrace_a-getpid.Tpo $(DEPDIR)/libstrace_a-getpid.Po
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='getpid.c' object='libstrace_a-getpid.o' libtool=no @AMDEPBACKSLASH@
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -c -o libstrace_a-getpid.o `test -f 'getpid.c' || echo '$(srcdir)/'`getpid.c
089393
+
089393
+libstrace_a-getpid.obj: getpid.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -MT libstrace_a-getpid.obj -MD -MP -MF $(DEPDIR)/libstrace_a-getpid.Tpo -c -o libstrace_a-getpid.obj `if test -f 'getpid.c'; then $(CYGPATH_W) 'getpid.c'; else $(CYGPATH_W) '$(srcdir)/getpid.c'; fi`
089393
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstrace_a-getpid.Tpo $(DEPDIR)/libstrace_a-getpid.Po
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='getpid.c' object='libstrace_a-getpid.obj' libtool=no @AMDEPBACKSLASH@
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -c -o libstrace_a-getpid.obj `if test -f 'getpid.c'; then $(CYGPATH_W) 'getpid.c'; else $(CYGPATH_W) '$(srcdir)/getpid.c'; fi`
089393
+
089393
 libstrace_a-getrandom.o: getrandom.c
089393
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -MT libstrace_a-getrandom.o -MD -MP -MF $(DEPDIR)/libstrace_a-getrandom.Tpo -c -o libstrace_a-getrandom.o `test -f 'getrandom.c' || echo '$(srcdir)/'`getrandom.c
089393
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstrace_a-getrandom.Tpo $(DEPDIR)/libstrace_a-getrandom.Po
089393
@@ -8377,6 +8393,7 @@
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-getcpu.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-getcwd.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-getpagesize.Po
089393
+	-rm -f ./$(DEPDIR)/libstrace_a-getpid.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-getrandom.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-hdio.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-hostname.Po
089393
@@ -8764,6 +8781,7 @@
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-getcpu.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-getcwd.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-getpagesize.Po
089393
+	-rm -f ./$(DEPDIR)/libstrace_a-getpid.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-getrandom.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-hdio.Po
089393
 	-rm -f ./$(DEPDIR)/libstrace_a-hostname.Po