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

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