Blame SOURCES/0134-PID-namespace-translation-support.patch

760e82
From bf533b84fd7200399c9b0e68fdf10c6aaf8b1a7a Mon Sep 17 00:00:00 2001
760e82
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
760e82
Date: Mon, 8 Jun 2020 19:01:03 +0200
760e82
Subject: [PATCH 134/138] PID namespace translation support
760e82
760e82
* defs.h (pidns_translation): New variable.
760e82
(tcb): Add pid_ns field.
760e82
(RVAL_MASK): Change value from 013 to 017.
760e82
(RVAL_TID, RVAL_SID, RVAL_TGID, RVAL_PGID): New definitions.
760e82
(pid_type): New enum.
760e82
(pidns_init, translate_pid, get_proc_pid, printpid, printpid_tgid_pgid):
760e82
New function declarations.
760e82
* largefile_wrappers.h (fstat_fd): New macro.
760e82
* pidns.c: New file.
760e82
* trie.c: New file.
760e82
* trie.h: New file.
760e82
* Makefile.am (libstrace_a_SOURCES): Add trie.c, trie.h, pidns.c.
760e82
* strace.c (pidns_translation): New variable.
760e82
(init): Add --pidns-translation option.
760e82
* syscall.c (syscall_exiting_trace): Handle RVAL_* return values.
760e82
* NEWS: Mention this.
760e82
* strace.1.in: Add description for new option.
760e82
760e82
Co-Authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
760e82
760e82
Conflicts:
760e82
	NEWS
760e82
---
760e82
 Makefile.am          |   3 +
760e82
 defs.h               |  56 ++++-
760e82
 largefile_wrappers.h |   2 +
760e82
 pidns.c              | 608 +++++++++++++++++++++++++++++++++++++++++++++++++++
760e82
 strace.1.in          |   4 +
760e82
 strace.c             |   9 +
760e82
 syscall.c            |  15 ++
760e82
 trie.c               | 290 ++++++++++++++++++++++++
760e82
 trie.h               |  92 ++++++++
760e82
 9 files changed, 1078 insertions(+), 1 deletion(-)
760e82
 create mode 100644 pidns.c
760e82
 create mode 100644 trie.c
760e82
 create mode 100644 trie.h
760e82
760e82
Index: strace-5.7/Makefile.am
760e82
===================================================================
760e82
--- strace-5.7.orig/Makefile.am	2020-09-09 15:50:13.471900510 +0200
760e82
+++ strace-5.7/Makefile.am	2020-09-09 15:52:09.159983257 +0200
760e82
@@ -233,6 +233,7 @@
760e82
 	personality.c	\
760e82
 	pidfd_getfd.c	\
760e82
 	pidfd_open.c	\
760e82
+	pidns.c		\
760e82
 	pkeys.c		\
760e82
 	poll.c		\
760e82
 	prctl.c		\
760e82
@@ -344,6 +345,8 @@
760e82
 	time.c		\
760e82
 	times.c		\
760e82
 	trace_event.h	\
760e82
+	trie.c 		\
760e82
+	trie.h 		\
760e82
 	truncate.c	\
760e82
 	ubi.c		\
760e82
 	ucopy.c		\
760e82
Index: strace-5.7/defs.h
760e82
===================================================================
760e82
--- strace-5.7.orig/defs.h	2020-09-09 15:50:13.473900511 +0200
760e82
+++ strace-5.7/defs.h	2020-09-09 15:52:09.159983257 +0200
760e82
@@ -280,6 +280,13 @@
760e82
 	struct timespec etime;	/* Syscall entry time (CLOCK_MONOTONIC) */
760e82
 	struct timespec delay_expiration_time; /* When does the delay end */
760e82
 
760e82
+	/*
760e82
+	 * The ID of the PID namespace of this process
760e82
+	 * (inode number of /proc/<pid>/ns/pid)
760e82
+	 * (0: not initialized)
760e82
+	 */
760e82
+	unsigned int pid_ns;
760e82
+
760e82
 	struct mmap_cache_t *mmap_cache;
760e82
 
760e82
 	/*
760e82
@@ -413,7 +420,11 @@
760e82
 # define RVAL_HEX	001	/* hex format */
760e82
 # define RVAL_OCTAL	002	/* octal format */
760e82
 # define RVAL_FD		010	/* file descriptor */
760e82
-# define RVAL_MASK	013	/* mask for these values */
760e82
+# define RVAL_TID	011	/* task ID */
760e82
+# define RVAL_SID	012	/* session ID */
760e82
+# define RVAL_TGID	013	/* thread group ID */
760e82
+# define RVAL_PGID	014	/* process group ID */
760e82
+# define RVAL_MASK	017	/* mask for these values */
760e82
 
760e82
 # define RVAL_STR	020	/* Print `auxstr' field after return val */
760e82
 # define RVAL_NONE	040	/* Print nothing */
760e82
@@ -428,6 +439,16 @@
760e82
 
760e82
 # define indirect_ipccall(tcp) (tcp_sysent(tcp)->sys_flags & TRACE_INDIRECT_SUBCALL)
760e82
 
760e82
+enum pid_type {
760e82
+	PT_TID,
760e82
+	PT_TGID,
760e82
+	PT_PGID,
760e82
+	PT_SID,
760e82
+
760e82
+	PT_COUNT,
760e82
+	PT_NONE = -1
760e82
+};
760e82
+
760e82
 enum sock_proto {
760e82
 	SOCK_PROTO_UNKNOWN,
760e82
 	SOCK_PROTO_UNIX,
760e82
@@ -469,6 +490,7 @@
760e82
 extern int Tflag_width;
760e82
 extern bool iflag;
760e82
 extern bool count_wallclock;
760e82
+extern unsigned int pidns_translation;
760e82
 /* are we filtering traces based on paths? */
760e82
 extern struct path_set {
760e82
 	const char **paths_selected;
760e82
@@ -984,6 +1006,29 @@
760e82
 extern kernel_ulong_t *
760e82
 fetch_indirect_syscall_args(struct tcb *, kernel_ulong_t addr, unsigned int n_args);
760e82
 
760e82
+extern void pidns_init(void);
760e82
+
760e82
+/**
760e82
+ * Returns the pid of the tracee as present in /proc of the tracer (can be
760e82
+ * different from tcp->pid if /proc and the tracer process are in different PID
760e82
+ * namespaces).
760e82
+ */
760e82
+extern int get_proc_pid(struct tcb *);
760e82
+
760e82
+/**
760e82
+ * Translates a pid from tracee's namespace to our namepace.
760e82
+ *
760e82
+ * @param tcp             The tcb of the tracee
760e82
+ *                        (NULL: from_id is in strace's namespace. Useful for
760e82
+ *                         getting the proc PID of from_id)
760e82
+ * @param from_id         The id to be translated
760e82
+ * @param type            The PID type of from_id
760e82
+ * @param proc_pid_ptr    If not NULL, writes the proc PID to this location
760e82
+ * @return                The translated id, or 0 if translation fails.
760e82
+ */
760e82
+extern int translate_pid(struct tcb *, int dest_id, enum pid_type type,
760e82
+		    int *proc_pid_ptr);
760e82
+
760e82
 extern void
760e82
 dumpiov_in_msghdr(struct tcb *, kernel_ulong_t addr, kernel_ulong_t data_size);
760e82
 
760e82
@@ -1059,6 +1104,15 @@
760e82
  * of the tracee the descriptor tcp).  This is a stub.
760e82
  */
760e82
 extern void printfd_pid_tracee_ns(struct tcb *tcp, pid_t pid, int fd);
760e82
+
760e82
+/** Prints a PID specified in the tracee's PID namespace */
760e82
+extern void printpid(struct tcb *, int pid, enum pid_type type);
760e82
+
760e82
+/**
760e82
+ * Prints pid as a TGID if positive, and PGID if negative
760e82
+ * (like the first argument of kill).
760e82
+ */
760e82
+extern void printpid_tgid_pgid(struct tcb *, int pid);
760e82
 extern void print_sockaddr(struct tcb *, const void *sa, int len);
760e82
 extern bool
760e82
 print_inet_addr(int af, const void *addr, unsigned int len, const char *var_name);
760e82
Index: strace-5.7/largefile_wrappers.h
760e82
===================================================================
760e82
--- strace-5.7.orig/largefile_wrappers.h	2020-09-09 15:50:13.473900511 +0200
760e82
+++ strace-5.7/largefile_wrappers.h	2020-09-09 15:50:18.017903762 +0200
760e82
@@ -29,6 +29,7 @@
760e82
 #  else
760e82
 #   define fcntl_fd fcntl
760e82
 #  endif
760e82
+#  define fstat_fd fstat64
760e82
 #  define strace_stat_t struct stat64
760e82
 #  define stat_file stat64
760e82
 #  define struct_dirent struct dirent64
760e82
@@ -39,6 +40,7 @@
760e82
 #  define open_file open
760e82
 #  define fopen_stream fopen
760e82
 #  define fcntl_fd fcntl
760e82
+#  define fstat_fd fstat
760e82
 #  define strace_stat_t struct stat
760e82
 #  define stat_file stat
760e82
 #  define struct_dirent struct dirent
760e82
Index: strace-5.7/pidns.c
760e82
===================================================================
760e82
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
760e82
+++ strace-5.7/pidns.c	2020-09-09 15:50:18.018903762 +0200
760e82
@@ -0,0 +1,608 @@
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
+
760e82
+#include <dirent.h>
760e82
+#include <fcntl.h>
760e82
+#include <stdint.h>
760e82
+#include <string.h>
760e82
+#include <unistd.h>
760e82
+
760e82
+#include <asm/unistd.h>
760e82
+
760e82
+#include <sys/ioctl.h>
760e82
+#include <sys/param.h>
760e82
+#include <sys/types.h>
760e82
+#include <sys/stat.h>
760e82
+
760e82
+#include "largefile_wrappers.h"
760e82
+#include "trie.h"
760e82
+#include "nsfs.h"
760e82
+#include "xmalloc.h"
760e82
+#include "xstring.h"
760e82
+
760e82
+/**
760e82
+ * Key:   PID NS ID
760e82
+ * Value: a btree:
760e82
+ *           Key:   a process PID in NS
760e82
+ *           Value: the process's PID as present in /proc
760e82
+ */
760e82
+static struct trie *ns_pid_to_proc_pid[PT_COUNT];
760e82
+
760e82
+/**
760e82
+ * Key:   Proc PID
760e82
+ * Value: struct proc_data
760e82
+ */
760e82
+static struct trie *proc_data_cache;
760e82
+
760e82
+static bool ns_get_parent_enotty = false;
760e82
+
760e82
+static const char tid_str[]  = "NSpid:\t";
760e82
+static const char tgid_str[] = "NStgid:\t";
760e82
+static const char pgid_str[] = "NSpgid:\t";
760e82
+static const char sid_str[]  = "NSsid:\t";
760e82
+
760e82
+static const struct {
760e82
+	const char *str;
760e82
+	size_t size;
760e82
+} id_strs[PT_COUNT] = {
760e82
+	[PT_TID] =  { tid_str,  sizeof(tid_str)  - 1 },
760e82
+	[PT_TGID] = { tgid_str, sizeof(tgid_str) - 1 },
760e82
+	[PT_PGID] = { pgid_str, sizeof(pgid_str) - 1 },
760e82
+	[PT_SID] =  { sid_str,  sizeof(sid_str)  - 1 },
760e82
+};
760e82
+
760e82
+
760e82
+/**
760e82
+ * Limit on PID NS hierarchy depth, imposed since Linux 3.7. NS traversal
760e82
+ * is not possible before Linux 4.9, so we consider this limit pretty universal.
760e82
+ */
760e82
+#define MAX_NS_DEPTH 32
760e82
+
760e82
+static const size_t ns_id_size = sizeof(unsigned int) * 8;
760e82
+static const uint8_t ptr_sz_lg = (sizeof(void *) == 8 ? 6 : 5);
760e82
+
760e82
+static int pid_max;
760e82
+static uint8_t pid_max_size, pid_max_size_lg;
760e82
+
760e82
+struct proc_data {
760e82
+	int proc_pid;
760e82
+	int ns_count;
760e82
+	unsigned int ns_hierarchy[MAX_NS_DEPTH];
760e82
+	int id_count[PT_COUNT];
760e82
+	int id_hierarchy[PT_COUNT][MAX_NS_DEPTH];
760e82
+};
760e82
+
760e82
+/**
760e82
+ * Helper function for creating a trie.
760e82
+ *
760e82
+ * For node_key_bits and data_block_key_bits 4 is used (so trie height is 32 / 4
760e82
+ * = 8, and node sizes are 8 byte * 2^4 = 128 bytes), which seems to be a good
760e82
+ * tradeoff between memory usage and lookup time. It should not be too large,
760e82
+ * since there can be large holes between PIDs, and it would be just a waste of
760e82
+ * memory having large nodes with lot of NULL pointers in them.
760e82
+ */
760e82
+static struct trie *
760e82
+create_trie_4(uint8_t key_size, uint8_t item_size_lg, uint64_t empty_value)
760e82
+{
760e82
+	struct trie *t = trie_create(key_size, item_size_lg, 4, 4, empty_value);
760e82
+	if (!t)
760e82
+		error_msg_and_die("creating trie failed");
760e82
+
760e82
+	return t;
760e82
+}
760e82
+
760e82
+void
760e82
+pidns_init(void)
760e82
+{
760e82
+	if (proc_data_cache)
760e82
+		return;
760e82
+
760e82
+	pid_max = INT_MAX;
760e82
+	if (read_int_from_file("/proc/sys/kernel/pid_max", &pid_max) < 0)
760e82
+		debug_func_perror_msg("reading /proc/sys/kernel/pid_max");
760e82
+	pid_max_size = ilog2_32(pid_max - 1) + 1;
760e82
+	pid_max_size_lg = ilog2_32(pid_max_size - 1) + 1;
760e82
+
760e82
+	for (int i = 0; i < PT_COUNT; i++)
760e82
+		ns_pid_to_proc_pid[i] = create_trie_4(ns_id_size, ptr_sz_lg, 0);
760e82
+
760e82
+	proc_data_cache = create_trie_4(pid_max_size, ptr_sz_lg, 0);
760e82
+}
760e82
+
760e82
+static void
760e82
+put_proc_pid(unsigned int ns, int ns_pid, enum pid_type type, int proc_pid)
760e82
+{
760e82
+	struct trie *b = (struct trie *) (uintptr_t) trie_get(ns_pid_to_proc_pid[type], ns);
760e82
+	if (!b) {
760e82
+		b = create_trie_4(pid_max_size, pid_max_size_lg, 0);
760e82
+		trie_set(ns_pid_to_proc_pid[type], ns, (uint64_t) (uintptr_t) b);
760e82
+	}
760e82
+	trie_set(b, ns_pid, proc_pid);
760e82
+}
760e82
+
760e82
+static int
760e82
+get_cached_proc_pid(unsigned int ns, int ns_pid, enum pid_type type)
760e82
+{
760e82
+	struct trie *b = (struct trie *) (uintptr_t)
760e82
+		trie_get(ns_pid_to_proc_pid[type], ns);
760e82
+	if (!b)
760e82
+		return 0;
760e82
+
760e82
+	return trie_get(b, ns_pid);
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Helper function, converts pid to string, or to "self" for pid == 0.
760e82
+ * Uses static buffer for operation.
760e82
+ */
760e82
+static const char *
760e82
+pid_to_str(pid_t pid)
760e82
+{
760e82
+	if (!pid)
760e82
+		return "self";
760e82
+
760e82
+	static char buf[sizeof("-2147483648")];
760e82
+	xsprintf(buf, "%d", pid);
760e82
+	return buf;
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Returns a list of PID NS IDs for the specified PID.
760e82
+ *
760e82
+ * @param proc_pid PID (as present in /proc) to get information for.
760e82
+ * @param ns_buf   Pointer to buffer that is able to contain at least
760e82
+ *                 ns_buf_size items.
760e82
+ * @return         Amount of NS in list. 0 indicates error.
760e82
+ */
760e82
+static size_t
760e82
+get_ns_hierarchy(int proc_pid, unsigned int *ns_buf, size_t ns_buf_size)
760e82
+{
760e82
+	char path[PATH_MAX + 1];
760e82
+	xsprintf(path, "/proc/%s/ns/pid", pid_to_str(proc_pid));
760e82
+
760e82
+	int fd = open_file(path, O_RDONLY);
760e82
+	if (fd < 0)
760e82
+		return 0;
760e82
+
760e82
+	size_t n = 0;
760e82
+	while (n < ns_buf_size) {
760e82
+		strace_stat_t st;
760e82
+		if (fstat_fd(fd, &st))
760e82
+			break;
760e82
+
760e82
+		ns_buf[n++] = st.st_ino;
760e82
+		if (n >= ns_buf_size)
760e82
+			break;
760e82
+
760e82
+		if (ns_get_parent_enotty)
760e82
+			break;
760e82
+
760e82
+		int parent_fd = ioctl(fd, NS_GET_PARENT);
760e82
+		if (parent_fd < 0) {
760e82
+			switch (errno) {
760e82
+			case EPERM:
760e82
+				break;
760e82
+
760e82
+			case ENOTTY:
760e82
+				ns_get_parent_enotty = true;
760e82
+				error_msg("NS_* ioctl commands are not "
760e82
+					  "supported by the kernel");
760e82
+				break;
760e82
+
760e82
+			default:
760e82
+				perror_func_msg("ioctl(NS_GET_PARENT)");
760e82
+				break;
760e82
+			}
760e82
+
760e82
+			break;
760e82
+		}
760e82
+
760e82
+		close(fd);
760e82
+		fd = parent_fd;
760e82
+	}
760e82
+
760e82
+	close(fd);
760e82
+
760e82
+	return n;
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Get list of IDs present in NS* proc status record. IDs are placed as they are
760e82
+ * stored in /proc (from top to bottom of NS hierarchy).
760e82
+ *
760e82
+ * @param proc_pid    PID (as present in /proc) to get information for.
760e82
+ * @param id_buf      Pointer to buffer that is able to contain at least
760e82
+ *                    MAX_NS_DEPTH items. Can be NULL.
760e82
+ * @param type        Type of ID requested.
760e82
+ * @return            Number of items stored in id_list. 0 indicates error.
760e82
+ */
760e82
+static size_t
760e82
+get_id_list(int proc_pid, int *id_buf, enum pid_type type)
760e82
+{
760e82
+	const char *ns_str = id_strs[type].str;
760e82
+	size_t ns_str_size = id_strs[type].size;
760e82
+
760e82
+	size_t n = 0;
760e82
+
760e82
+	char status_path[PATH_MAX + 1];
760e82
+	xsprintf(status_path, "/proc/%s/status", pid_to_str(proc_pid));
760e82
+	FILE *f = fopen_stream(status_path, "r");
760e82
+	if (!f)
760e82
+		return 0;
760e82
+
760e82
+	char *line = NULL;
760e82
+	size_t linesize = 0;
760e82
+	char *p = NULL;
760e82
+
760e82
+	while (getline(&line, &linesize, f) > 0) {
760e82
+		if (strncmp(line, ns_str, ns_str_size) == 0) {
760e82
+			p = line + ns_str_size;
760e82
+			break;
760e82
+		}
760e82
+	}
760e82
+
760e82
+	while (p) {
760e82
+		errno = 0;
760e82
+		long id = strtol(p, NULL, 10);
760e82
+
760e82
+		if (id < 0 || id > INT_MAX || errno) {
760e82
+			perror_func_msg("converting pid (%ld) to int", id);
760e82
+			break;
760e82
+		}
760e82
+
760e82
+		if (id_buf)
760e82
+			id_buf[n] = (int) id;
760e82
+
760e82
+		n++;
760e82
+		strsep(&p, "\t");
760e82
+	}
760e82
+
760e82
+	free(line);
760e82
+	fclose(f);
760e82
+
760e82
+	return n;
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Returns whether the /proc filesystem's PID namespace is the same as strace's.
760e82
+ */
760e82
+static bool
760e82
+is_proc_ours(void)
760e82
+{
760e82
+	static int cached_val = -1;
760e82
+
760e82
+	if (cached_val < 0)
760e82
+		cached_val = get_id_list(0, NULL, PT_TID) <= 1;
760e82
+
760e82
+	return cached_val;
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Returns the PID namespace of the tracee
760e82
+ */
760e82
+static unsigned int
760e82
+get_ns(struct tcb *tcp)
760e82
+{
760e82
+	if (!tcp->pid_ns) {
760e82
+		int proc_pid = 0;
760e82
+		translate_pid(NULL, tcp->pid, PT_TID, &proc_pid);
760e82
+
760e82
+		if (proc_pid)
760e82
+			get_ns_hierarchy(proc_pid, &tcp->pid_ns, 1);
760e82
+	}
760e82
+
760e82
+	return tcp->pid_ns;
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Returns the PID namespace of strace
760e82
+ */
760e82
+static unsigned int
760e82
+get_our_ns(void)
760e82
+{
760e82
+	static unsigned int our_ns = 0;
760e82
+	static bool our_ns_initialised = false;
760e82
+
760e82
+	if (!our_ns_initialised) {
760e82
+		get_ns_hierarchy(0, &our_ns, 1);
760e82
+		our_ns_initialised = true;
760e82
+	}
760e82
+
760e82
+	return our_ns;
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Returns the cached proc_data struct associated with proc_pid.
760e82
+ * If none found, allocates a new proc_data.
760e82
+ */
760e82
+static struct proc_data *
760e82
+get_or_create_proc_data(int proc_pid)
760e82
+{
760e82
+	struct proc_data *pd = (struct proc_data *) (uintptr_t)
760e82
+		trie_get(proc_data_cache, proc_pid);
760e82
+
760e82
+	if (!pd) {
760e82
+		pd = calloc(1, sizeof(*pd));
760e82
+		if (!pd)
760e82
+			return NULL;
760e82
+
760e82
+		pd->proc_pid = proc_pid;
760e82
+		trie_set(proc_data_cache, proc_pid, (uint64_t) (uintptr_t) pd);
760e82
+	}
760e82
+
760e82
+	return pd;
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Updates the proc_data from /proc
760e82
+ * If the process does not exists, returns false, and frees the proc_data
760e82
+ */
760e82
+static bool
760e82
+update_proc_data(struct proc_data *pd, enum pid_type type)
760e82
+{
760e82
+	pd->ns_count = get_ns_hierarchy(pd->proc_pid,
760e82
+		pd->ns_hierarchy, MAX_NS_DEPTH);
760e82
+	if (!pd->ns_count)
760e82
+		goto fail;
760e82
+
760e82
+	pd->id_count[type] = get_id_list(pd->proc_pid,
760e82
+		pd->id_hierarchy[type], type);
760e82
+	if (!pd->id_count[type])
760e82
+		goto fail;
760e82
+
760e82
+	return true;
760e82
+
760e82
+fail:
760e82
+	trie_set(proc_data_cache, pd->proc_pid, (uint64_t) (uintptr_t) NULL);
760e82
+	free(pd);
760e82
+	return false;
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Paramters for id translation
760e82
+ */
760e82
+struct translate_id_params {
760e82
+	/* The result (output) */
760e82
+	int result_id;
760e82
+	/* The proc data of the process (output) */
760e82
+	struct proc_data *pd;
760e82
+
760e82
+	/* The namespace to be translated from */
760e82
+	unsigned int from_ns;
760e82
+	/* The id to be translated */
760e82
+	int from_id;
760e82
+	/* The type of the id */
760e82
+	enum pid_type type;
760e82
+};
760e82
+
760e82
+/**
760e82
+ * Translates an id to our namespace, given the proc_pid of the process,
760e82
+ * by reading files in /proc.
760e82
+ *
760e82
+ * @param tip      The parameters
760e82
+ * @param proc_pid The proc pid of the process.
760e82
+ *                 If 0, use the cached values in tip->pd.
760e82
+ */
760e82
+static void
760e82
+translate_id_proc_pid(struct translate_id_params *tip, int proc_pid)
760e82
+{
760e82
+	struct proc_data *pd = proc_pid ?
760e82
+		get_or_create_proc_data(proc_pid) :
760e82
+		tip->pd;
760e82
+
760e82
+	tip->result_id = 0;
760e82
+	tip->pd = NULL;
760e82
+
760e82
+	if (!pd)
760e82
+		return;
760e82
+
760e82
+	if (proc_pid && !update_proc_data(pd, tip->type))
760e82
+		return;
760e82
+
760e82
+	if (!pd->ns_count || pd->id_count[tip->type] < pd->ns_count)
760e82
+		return;
760e82
+
760e82
+	int *id_hierarchy = pd->id_hierarchy[tip->type];
760e82
+	int id_count = pd->id_count[tip->type];
760e82
+
760e82
+	for (int i = 0; i < pd->ns_count; i++) {
760e82
+		unsigned int ns = pd->ns_hierarchy[i];
760e82
+		int ns_id = id_hierarchy[id_count - i - 1];
760e82
+		int our_id = id_hierarchy[id_count - pd->ns_count];
760e82
+
760e82
+		if (ns != tip->from_ns)
760e82
+			continue;
760e82
+
760e82
+		if (ns_id != tip->from_id)
760e82
+			return;
760e82
+
760e82
+		tip->result_id = our_id;
760e82
+		tip->pd = pd;
760e82
+		return;
760e82
+	}
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Translates an id to our namespace by reading all proc entries in a directory.
760e82
+ * The directory is either /proc or /proc/<pid>/task.
760e82
+ *
760e82
+ *
760e82
+ * @param tip            The parameters
760e82
+ * @param path           The path of the directory to be read.
760e82
+ * @param read_task_dir  Whether recurse to "task" subdirectory.
760e82
+ */
760e82
+static void
760e82
+translate_id_dir(struct translate_id_params *tip, const char *path,
760e82
+                 bool read_task_dir)
760e82
+{
760e82
+	DIR *dir = opendir(path);
760e82
+	if (!dir) {
760e82
+		debug_func_perror_msg("opening dir: %s", path);
760e82
+		return;
760e82
+	}
760e82
+
760e82
+	while (!tip->result_id) {
760e82
+		errno = 0;
760e82
+		struct_dirent *entry = read_dir(dir);
760e82
+		if (!entry) {
760e82
+			if (errno)
760e82
+				perror_func_msg("readdir");
760e82
+
760e82
+			break;
760e82
+		}
760e82
+
760e82
+		if (entry->d_type != DT_DIR)
760e82
+			continue;
760e82
+
760e82
+		errno = 0;
760e82
+		long proc_pid = strtol(entry->d_name, NULL, 10);
760e82
+		if (proc_pid < 1 || proc_pid > INT_MAX || errno)
760e82
+			continue;
760e82
+
760e82
+		if (read_task_dir) {
760e82
+			char task_dir_path[PATH_MAX + 1];
760e82
+			xsprintf(task_dir_path, "/proc/%ld/task", proc_pid);
760e82
+			translate_id_dir(tip, task_dir_path, false);
760e82
+		}
760e82
+
760e82
+		if (tip->result_id)
760e82
+			break;
760e82
+
760e82
+		translate_id_proc_pid(tip, proc_pid);
760e82
+	}
760e82
+
760e82
+	closedir(dir);
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Iterator function of the proc_data_cache for id translation.
760e82
+ * If the cache contains the id we are looking for, reads the corresponding
760e82
+ * directory in /proc, and if cache is valid, saves the result.
760e82
+ */
760e82
+static void
760e82
+proc_data_cache_iterator_fn(void* fn_data, uint64_t key, uint64_t val)
760e82
+{
760e82
+	struct translate_id_params *tip = (struct translate_id_params *)fn_data;
760e82
+	struct proc_data *pd = (struct proc_data *) (uintptr_t) val;
760e82
+
760e82
+	if (!pd)
760e82
+		return;
760e82
+
760e82
+	/* Result already found in an earlier iteration */
760e82
+	if (tip->result_id)
760e82
+		return;
760e82
+
760e82
+	/* Translate from cache */
760e82
+	tip->pd = pd;
760e82
+	translate_id_proc_pid(tip, 0);
760e82
+	if (!tip->result_id)
760e82
+		return;
760e82
+
760e82
+	/* Now translate from actual data in /proc, to check cache validity */
760e82
+	translate_id_proc_pid(tip, pd->proc_pid);
760e82
+}
760e82
+
760e82
+int
760e82
+translate_pid(struct tcb *tcp, int from_id, enum pid_type type,
760e82
+              int *proc_pid_ptr)
760e82
+{
760e82
+	if (from_id <= 0 || type < 0 || type >= PT_COUNT)
760e82
+		return 0;
760e82
+
760e82
+	/* If translation is trivial */
760e82
+	if ((!tcp || get_ns(tcp) == get_our_ns()) &&
760e82
+	    (!proc_pid_ptr || is_proc_ours())) {
760e82
+		if (proc_pid_ptr)
760e82
+			*proc_pid_ptr = from_id;
760e82
+
760e82
+		return from_id;
760e82
+	}
760e82
+
760e82
+	struct translate_id_params tip = {
760e82
+		.result_id = 0,
760e82
+		.pd = NULL,
760e82
+		.from_ns = tcp ? get_ns(tcp) : get_our_ns(),
760e82
+		.from_id = from_id,
760e82
+		.type = type,
760e82
+	};
760e82
+
760e82
+	if (!tip.from_ns)
760e82
+		return 0;
760e82
+
760e82
+	if (ns_get_parent_enotty)
760e82
+		return 0;
760e82
+
760e82
+	/* Look for a cached proc_pid for this (from_ns, from_id) pair */
760e82
+	int cached_proc_pid = get_cached_proc_pid(tip.from_ns, tip.from_id,
760e82
+		tip.type);
760e82
+	if (cached_proc_pid) {
760e82
+		translate_id_proc_pid(&tip, cached_proc_pid);
760e82
+		if (tip.result_id)
760e82
+			goto exit;
760e82
+	}
760e82
+
760e82
+	/* Iterate through the cache, find potential proc_data */
760e82
+	trie_iterate_keys(proc_data_cache, 0, pid_max - 1,
760e82
+		proc_data_cache_iterator_fn, &tip;;
760e82
+	/* (proc_data_cache_iterator_fn takes care about updating proc_data) */
760e82
+	if (tip.result_id)
760e82
+		goto exit;
760e82
+
760e82
+	/* No cache helped, read all entries in /proc */
760e82
+	translate_id_dir(&tip, "/proc", true);
760e82
+
760e82
+exit:
760e82
+	if (tip.pd) {
760e82
+		if (tip.pd->proc_pid)
760e82
+			put_proc_pid(tip.from_ns, tip.from_id, tip.type,
760e82
+				tip.pd->proc_pid);
760e82
+
760e82
+		if (proc_pid_ptr)
760e82
+			*proc_pid_ptr = tip.pd->proc_pid;
760e82
+	}
760e82
+
760e82
+	return tip.result_id;
760e82
+}
760e82
+
760e82
+int
760e82
+get_proc_pid(struct tcb *tcp)
760e82
+{
760e82
+	int proc_pid = 0;
760e82
+	translate_pid(NULL, tcp->pid, PT_TID, &proc_pid);
760e82
+	return proc_pid;
760e82
+}
760e82
+
760e82
+static void
760e82
+printpid_translation(struct tcb *tcp, int pid, enum pid_type type)
760e82
+{
760e82
+	if (!pidns_translation)
760e82
+		return;
760e82
+
760e82
+	int strace_pid = translate_pid(tcp, pid, type, NULL);
760e82
+	if (strace_pid && strace_pid != pid)
760e82
+		tprintf_comment("%d in strace's PID NS", strace_pid);
760e82
+}
760e82
+
760e82
+void
760e82
+printpid(struct tcb *tcp, int pid, enum pid_type type)
760e82
+{
760e82
+	tprintf("%d", pid);
760e82
+	printpid_translation(tcp, pid, type);
760e82
+}
760e82
+
760e82
+void
760e82
+printpid_tgid_pgid(struct tcb *tcp, int pid)
760e82
+{
760e82
+	tprintf("%d", pid);
760e82
+	if (pid > 0)
760e82
+		printpid_translation(tcp,  pid, PT_TGID);
760e82
+	else if (pid < -1)
760e82
+		printpid_translation(tcp, -pid, PT_PGID);
760e82
+}
760e82
Index: strace-5.7/strace.1.in
760e82
===================================================================
760e82
--- strace-5.7.orig/strace.1.in	2020-09-09 15:50:13.475900513 +0200
760e82
+++ strace-5.7/strace.1.in	2020-09-09 15:50:18.018903762 +0200
760e82
@@ -1075,6 +1075,10 @@
760e82
 protocol-specific information associated with socket file descriptors,
760e82
 block/character device number associated with device file descriptors,
760e82
 and PIDs asociated with pidfd file descriptors.
760e82
+.TP
760e82
+.B \-\-pidns\-translation
760e82
+If strace and tracee are in different PID namespaces, print PIDs in
760e82
+strace's namespace, too.
760e82
 .SS Statistics
760e82
 .TP 12
760e82
 .B \-c
760e82
Index: strace-5.7/strace.c
760e82
===================================================================
760e82
--- strace-5.7.orig/strace.c	2020-09-09 15:50:13.476900514 +0200
760e82
+++ strace-5.7/strace.c	2020-09-09 15:52:08.646982890 +0200
760e82
@@ -133,6 +133,8 @@
760e82
 static int post_attach_sigstop = TCB_IGNORE_ONE_SIGSTOP;
760e82
 #define use_seize (post_attach_sigstop == 0)
760e82
 
760e82
+unsigned int pidns_translation;
760e82
+
760e82
 static bool detach_on_execve;
760e82
 
760e82
 static int exit_code;
760e82
@@ -1998,6 +2000,8 @@
760e82
 
760e82
 	os_release = get_os_release();
760e82
 
760e82
+	pidns_init();
760e82
+
760e82
 	shared_log = stderr;
760e82
 	set_sortby(DEFAULT_SORTBY);
760e82
 	set_personality(DEFAULT_PERSONALITY);
760e82
@@ -2022,6 +2026,7 @@
760e82
 		GETOPT_FOLLOWFORKS,
760e82
 		GETOPT_OUTPUT_SEPARATELY,
760e82
 		GETOPT_TS,
760e82
+		GETOPT_PIDNS_TRANSLATION,
760e82
 
760e82
 		GETOPT_QUAL_TRACE,
760e82
 		GETOPT_QUAL_ABBREV,
760e82
@@ -2072,6 +2077,7 @@
760e82
 		{ "summary-wall-clock", no_argument,	   0, 'w' },
760e82
 		{ "strings-in-hex",	optional_argument, 0, GETOPT_HEX_STR },
760e82
 		{ "const-print-style",	required_argument, 0, 'X' },
760e82
+		{ "pidns-translation",	no_argument      , 0, GETOPT_PIDNS_TRANSLATION },
760e82
 		{ "successful-only",	no_argument,	   0, 'z' },
760e82
 		{ "failed-only",	no_argument,	   0, 'Z' },
760e82
 		{ "failing-only",	no_argument,	   0, 'Z' },
760e82
@@ -2285,6 +2291,9 @@
760e82
 		case 'y':
760e82
 			yflag_short++;
760e82
 			break;
760e82
+		case GETOPT_PIDNS_TRANSLATION:
760e82
+			pidns_translation++;
760e82
+			break;
760e82
 		case 'z':
760e82
 			clear_number_set_array(status_set, 1);
760e82
 			add_number_to_set(STATUS_SUCCESSFUL, status_set);
760e82
Index: strace-5.7/syscall.c
760e82
===================================================================
760e82
--- strace-5.7.orig/syscall.c	2020-09-09 15:50:13.477900514 +0200
760e82
+++ strace-5.7/syscall.c	2020-09-09 15:50:18.019903763 +0200
760e82
@@ -930,6 +930,21 @@
760e82
 					tprintf("= %" PRI_kld, tcp->u_rval);
760e82
 				}
760e82
 				break;
760e82
+			case RVAL_TID:
760e82
+			case RVAL_SID:
760e82
+			case RVAL_TGID:
760e82
+			case RVAL_PGID: {
760e82
+				#define _(_t) [RVAL_##_t - RVAL_TID] = PT_##_t
760e82
+				static const enum pid_type types[] = {
760e82
+					_(TID), _(SID), _(TGID), _(PGID),
760e82
+				};
760e82
+				#undef _
760e82
+
760e82
+				tprints("= ");
760e82
+				printpid(tcp, tcp->u_rval,
760e82
+					 types[(sys_res & RVAL_MASK) - RVAL_TID]);
760e82
+				break;
760e82
+			}
760e82
 			default:
760e82
 				error_msg("invalid rval format");
760e82
 				break;
760e82
Index: strace-5.7/trie.c
760e82
===================================================================
760e82
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
760e82
+++ strace-5.7/trie.c	2020-09-09 15:50:18.019903763 +0200
760e82
@@ -0,0 +1,290 @@
760e82
+/*
760e82
+ * Simple trie implementation for key-value mapping storage
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
+#ifdef HAVE_CONFIG_H
760e82
+# include "config.h"
760e82
+#endif
760e82
+
760e82
+#include <stdlib.h>
760e82
+#include <stdio.h>
760e82
+
760e82
+#include "trie.h"
760e82
+#include "xmalloc.h"
760e82
+
760e82
+static const uint8_t ptr_sz_lg = (sizeof(void *) == 8 ? 6 : 5);
760e82
+
760e82
+/**
760e82
+ * Returns lg2 of node size in bits for the specific level of the trie.
760e82
+ */
760e82
+static uint8_t
760e82
+trie_get_node_size(struct trie *t, uint8_t depth)
760e82
+{
760e82
+	/* Last level contains data and we allow it having a different size */
760e82
+	if (depth == t->max_depth)
760e82
+		return t->data_block_key_bits + t->item_size_lg;
760e82
+	/* Last level of the tree can be smaller */
760e82
+	if (depth == t->max_depth - 1)
760e82
+		return (t->key_size - t->data_block_key_bits - 1) %
760e82
+		t->node_key_bits + 1 + ptr_sz_lg;
760e82
+
760e82
+	return t->node_key_bits + ptr_sz_lg;
760e82
+}
760e82
+
760e82
+/**
760e82
+ * Provides starting offset of bits in key corresponding to the node index
760e82
+ * at the specific level.
760e82
+ */
760e82
+static uint8_t
760e82
+trie_get_node_bit_offs(struct trie *t, uint8_t depth)
760e82
+{
760e82
+	uint8_t offs;
760e82
+
760e82
+	if (depth == t->max_depth)
760e82
+		return 0;
760e82
+
760e82
+	offs = t->data_block_key_bits;
760e82
+
760e82
+	if (depth == t->max_depth - 1)
760e82
+		return offs;
760e82
+
760e82
+	/* data_block_size + remainder */
760e82
+	offs += trie_get_node_size(t, t->max_depth - 1) - ptr_sz_lg;
760e82
+	offs += (t->max_depth - depth - 2) * t->node_key_bits;
760e82
+
760e82
+	return offs;
760e82
+}
760e82
+
760e82
+struct trie *
760e82
+trie_create(uint8_t key_size, uint8_t item_size_lg, uint8_t node_key_bits,
760e82
+            uint8_t data_block_key_bits, uint64_t empty_value)
760e82
+{
760e82
+	if (item_size_lg > 6)
760e82
+		return NULL;
760e82
+	if (key_size > 64)
760e82
+		return NULL;
760e82
+	if (node_key_bits < 1)
760e82
+		return NULL;
760e82
+	if (data_block_key_bits < 1 || data_block_key_bits > key_size)
760e82
+		return NULL;
760e82
+
760e82
+	struct trie *t = malloc(sizeof(*t));
760e82
+	if (!t)
760e82
+		return NULL;
760e82
+
760e82
+	t->empty_value = empty_value;
760e82
+	t->data = NULL;
760e82
+	t->item_size_lg = item_size_lg;
760e82
+	t->node_key_bits = node_key_bits;
760e82
+	t->data_block_key_bits = data_block_key_bits;
760e82
+	t->key_size = key_size;
760e82
+	t->max_depth = (key_size - data_block_key_bits + node_key_bits - 1)
760e82
+		/ t->node_key_bits;
760e82
+
760e82
+	if (item_size_lg != 6)
760e82
+		t->empty_value &= (((uint64_t) 1 << (1 << t->item_size_lg)) - 1);
760e82
+
760e82
+	return t;
760e82
+}
760e82
+
760e82
+static void *
760e82
+trie_create_data_block(struct trie *t)
760e82
+{
760e82
+	uint64_t fill_value = t->empty_value;
760e82
+	for (int i = 1; i < 1 << (6 - t->item_size_lg); i++) {
760e82
+		fill_value <<= (1 << t->item_size_lg);
760e82
+		fill_value |= t->empty_value;
760e82
+	}
760e82
+
760e82
+	uint8_t sz = t->data_block_key_bits + t->item_size_lg;
760e82
+	if (sz < 6)
760e82
+		sz = 6;
760e82
+
760e82
+	size_t count = 1 << (sz - 6);
760e82
+	uint64_t *data_block = xcalloc(count, 8);
760e82
+
760e82
+	for (size_t i = 0; i < count; i++)
760e82
+		data_block[i] = fill_value;
760e82
+
760e82
+	return data_block;
760e82
+}
760e82
+
760e82
+static uint64_t *
760e82
+trie_get_node(struct trie *t, uint64_t key, bool auto_create)
760e82
+{
760e82
+	void **cur_node = &(t->data);
760e82
+
760e82
+	if (t->key_size < 64 && key > (uint64_t) 1 << t->key_size)
760e82
+		return NULL;
760e82
+
760e82
+	for (uint8_t cur_depth = 0; cur_depth <= t->max_depth; cur_depth++) {
760e82
+		uint8_t offs = trie_get_node_bit_offs(t, cur_depth);
760e82
+		uint8_t sz = trie_get_node_size(t, cur_depth);
760e82
+
760e82
+		if (!*cur_node) {
760e82
+			if (!auto_create)
760e82
+				return NULL;
760e82
+
760e82
+			if (cur_depth == t->max_depth)
760e82
+				*cur_node = trie_create_data_block(t);
760e82
+			else
760e82
+				*cur_node = xcalloc(1 << sz, 1);
760e82
+		}
760e82
+
760e82
+		if (cur_depth == t->max_depth)
760e82
+			break;
760e82
+
760e82
+		size_t pos = (key >> offs) & ((1 << (sz - ptr_sz_lg)) - 1);
760e82
+		cur_node = (((void **) (*cur_node)) + pos);
760e82
+	}
760e82
+
760e82
+	return (uint64_t *) (*cur_node);
760e82
+}
760e82
+
760e82
+static void
760e82
+trie_data_block_calc_pos(struct trie *t, uint64_t key,
760e82
+                         uint64_t *pos, uint64_t *mask, uint64_t *offs)
760e82
+{
760e82
+	uint64_t key_mask;
760e82
+
760e82
+	key_mask = (1 << t->data_block_key_bits) - 1;
760e82
+	*pos = (key & key_mask) >> (6 - t->item_size_lg);
760e82
+
760e82
+	if (t->item_size_lg == 6) {
760e82
+		*offs = 0;
760e82
+		*mask = -1;
760e82
+		return;
760e82
+	}
760e82
+
760e82
+	key_mask = (1 << (6 - t->item_size_lg)) - 1;
760e82
+	*offs = (key & key_mask) * (1 << t->item_size_lg);
760e82
+
760e82
+	*mask = (((uint64_t) 1 << (1 << t->item_size_lg)) - 1) << *offs;
760e82
+}
760e82
+
760e82
+bool
760e82
+trie_set(struct trie *t, uint64_t key, uint64_t val)
760e82
+{
760e82
+	uint64_t *data = trie_get_node(t, key, true);
760e82
+	if (!data)
760e82
+		return false;
760e82
+
760e82
+	uint64_t pos, mask, offs;
760e82
+	trie_data_block_calc_pos(t, key, &pos, &mask, &offs);
760e82
+
760e82
+	data[pos] &= ~mask;
760e82
+	data[pos] |= (val << offs) & mask;
760e82
+
760e82
+	return true;
760e82
+}
760e82
+
760e82
+static uint64_t
760e82
+trie_data_block_get(struct trie *t, uint64_t *data, uint64_t key)
760e82
+{
760e82
+	if (!data)
760e82
+		return t->empty_value;
760e82
+
760e82
+	uint64_t pos, mask, offs;
760e82
+	trie_data_block_calc_pos(t, key, &pos, &mask, &offs);
760e82
+
760e82
+	return (data[pos] & mask) >> offs;
760e82
+}
760e82
+
760e82
+uint64_t
760e82
+trie_get(struct trie *b, uint64_t key)
760e82
+{
760e82
+	return trie_data_block_get(b, trie_get_node(b, key, false), key);
760e82
+}
760e82
+
760e82
+static uint64_t
760e82
+trie_iterate_keys_node(struct trie *t,
760e82
+                       trie_iterate_fn fn, void *fn_data,
760e82
+                       void *node, uint64_t start, uint64_t end,
760e82
+                       uint8_t depth)
760e82
+{
760e82
+	if (start > end || !node)
760e82
+		return 0;
760e82
+
760e82
+	if (t->key_size < 64) {
760e82
+		uint64_t key_max = ((uint64_t) 1 << t->key_size) - 1;
760e82
+		if (end > key_max)
760e82
+			end = key_max;
760e82
+	}
760e82
+
760e82
+	if (depth == t->max_depth) {
760e82
+		for (uint64_t i = start; i <= end; i++)
760e82
+			fn(fn_data, i, trie_data_block_get(t,
760e82
+				(uint64_t *) node, i));
760e82
+
760e82
+		return end - start + 1;
760e82
+	}
760e82
+
760e82
+	uint8_t parent_node_bit_off = depth == 0 ?
760e82
+		t->key_size :
760e82
+		trie_get_node_bit_offs(t, depth - 1);
760e82
+
760e82
+	uint64_t first_key_in_node = start &
760e82
+		(uint64_t) -1 << parent_node_bit_off;
760e82
+
760e82
+	uint8_t node_bit_off = trie_get_node_bit_offs(t, depth);
760e82
+	uint8_t node_key_bits = parent_node_bit_off - node_bit_off;
760e82
+	uint64_t mask = ((uint64_t) 1 << (node_key_bits)) - 1;
760e82
+	uint64_t start_index = (start >> node_bit_off) & mask;
760e82
+	uint64_t end_index = (end >> node_bit_off) & mask;
760e82
+	uint64_t child_key_count = (uint64_t) 1 << node_bit_off;
760e82
+
760e82
+	uint64_t count = 0;
760e82
+
760e82
+	for (uint64_t i = start_index; i <= end_index; i++) {
760e82
+		uint64_t child_start = first_key_in_node + i * child_key_count;
760e82
+		uint64_t child_end = first_key_in_node +
760e82
+			(i + 1) * child_key_count - 1;
760e82
+
760e82
+		if (child_start < start)
760e82
+			child_start = start;
760e82
+		if (child_end > end)
760e82
+			child_end = end;
760e82
+
760e82
+		count += trie_iterate_keys_node(t, fn, fn_data,
760e82
+			((void **) node)[i], child_start, child_end,
760e82
+			depth + 1);
760e82
+	}
760e82
+
760e82
+	return count;
760e82
+}
760e82
+
760e82
+uint64_t trie_iterate_keys(struct trie *t, uint64_t start, uint64_t end,
760e82
+                           trie_iterate_fn fn, void *fn_data)
760e82
+{
760e82
+	return trie_iterate_keys_node(t, fn, fn_data, t->data,
760e82
+		start, end, 0);
760e82
+}
760e82
+
760e82
+static void
760e82
+trie_free_node(struct trie *t, void *node, uint8_t depth)
760e82
+{
760e82
+	if (!node)
760e82
+		return;
760e82
+
760e82
+	if (depth >= t->max_depth)
760e82
+		goto free_node;
760e82
+
760e82
+	size_t sz = 1 << (trie_get_node_size(t, depth) - ptr_sz_lg);
760e82
+	for (size_t i = 0; i < sz; i++)
760e82
+		trie_free_node(t, ((void **) node)[i], depth + 1);
760e82
+
760e82
+free_node:
760e82
+	free(node);
760e82
+}
760e82
+
760e82
+void
760e82
+trie_free(struct trie *t)
760e82
+{
760e82
+	trie_free_node(t, t->data, 0);
760e82
+	free(t);
760e82
+}
760e82
Index: strace-5.7/trie.h
760e82
===================================================================
760e82
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
760e82
+++ strace-5.7/trie.h	2020-09-09 15:50:18.019903763 +0200
760e82
@@ -0,0 +1,92 @@
760e82
+/*
760e82
+ * Simple trie interface
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
+#ifndef STRACE_TRIE_H
760e82
+#define STRACE_TRIE_H
760e82
+
760e82
+#include <stdbool.h>
760e82
+#include <stdint.h>
760e82
+
760e82
+/**
760e82
+ * Trie control structure.
760e82
+ * Trie implemented here has the following properties:
760e82
+ *  * It allows storing values of the same size, the size can vary from 1 bit to
760e82
+ *    64 bit values (only power of 2 sizes are allowed).
760e82
+ *  * The key can be up to 64 bits in size.
760e82
+ *  * It has separate configuration for node size and data block size.
760e82
+ *
760e82
+ * How bits of key are used for different node levels:
760e82
+ *
760e82
+ *   highest bits                                                  lowest bits
760e82
+ *  | node_key_bits | node_key_bits | ... | <remainder> | data_block_key_bits |
760e82
+ *  \_________________________________________________________________________/
760e82
+ *                                 key_size
760e82
+ *
760e82
+ * So, the remainder is used on the lowest non-data node level.
760e82
+ *
760e82
+ * As of now, it doesn't implement any mechanisms for resizing/changing key
760e82
+ * size.  De-fragmentation is also unsupported currently.
760e82
+ */
760e82
+struct trie {
760e82
+	/** Return value of trie_get if key is not found */
760e82
+	uint64_t empty_value;
760e82
+
760e82
+	/** Pointer to root node */
760e82
+	void *data;
760e82
+
760e82
+	/** Key size in bits (0..64). */
760e82
+	uint8_t key_size;
760e82
+
760e82
+	/**
760e82
+	 * Size of the stored values in log2 bits (0..6).
760e82
+	 * (6: 64 bit values, 5: 32 bit values, ...)
760e82
+	 */
760e82
+	uint8_t item_size_lg;
760e82
+
760e82
+	/**
760e82
+	 * Number of bits in the key that make a symbol for a node.
760e82
+	 * (equals to log2 of the child count of the node)
760e82
+	 */
760e82
+	uint8_t node_key_bits;
760e82
+
760e82
+	/**
760e82
+	 * Number of bits in the key that make a symbol for the data block (leaf).
760e82
+	 * (equals to log2 of the value count stored in a data block)
760e82
+	 */
760e82
+	uint8_t data_block_key_bits;
760e82
+
760e82
+	/** The depth of the data block. Calculated from the values above */
760e82
+	uint8_t max_depth;
760e82
+};
760e82
+
760e82
+struct trie* trie_create(uint8_t key_size, uint8_t item_size_lg,
760e82
+			uint8_t node_key_bits, uint8_t data_block_key_bits,
760e82
+			uint64_t empty_value);
760e82
+
760e82
+bool trie_set(struct trie *t, uint64_t key, uint64_t val);
760e82
+uint64_t trie_get(struct trie *t, uint64_t key);
760e82
+
760e82
+typedef void (*trie_iterate_fn)(void *data, uint64_t key, uint64_t val);
760e82
+
760e82
+/**
760e82
+ * Calls trie_iterate_fn for each key-value pair where
760e82
+ * key is inside the [start, end] interval (inclusive).
760e82
+ *
760e82
+ * @param t        The trie.
760e82
+ * @param start    The start of the key interval (inclusive).
760e82
+ * @param end      The end of the key interval (inclusive).
760e82
+ * @param fn       The function to be called.
760e82
+ * @param fn_data  The value to be passed to fn.
760e82
+ */
760e82
+uint64_t trie_iterate_keys(struct trie *t, uint64_t start, uint64_t end,
760e82
+			    trie_iterate_fn fn, void *fn_data);
760e82
+
760e82
+void trie_free(struct trie *t);
760e82
+
760e82
+#endif /* !STRACE_TRIE_H */
760e82
Index: strace-5.7/Makefile.in
760e82
===================================================================
760e82
--- strace-5.7.orig/Makefile.in	2020-09-09 15:50:13.484900519 +0200
760e82
+++ strace-5.7/Makefile.in	2020-09-09 15:54:59.569105143 +0200
760e82
@@ -344,8 +344,8 @@
760e82
 	nlattr.c nlattr.h nsfs.c nsfs.h nsig.h numa.c number_set.c \
760e82
 	number_set.h oldstat.c open.c open_tree.c or1k_atomic.c \
760e82
 	pathtrace.c perf.c perf_event_struct.h perf_ioctl.c \
760e82
-	personality.c pidfd_getfd.c pidfd_open.c pkeys.c poll.c \
760e82
-	prctl.c print_aio_sigset.c print_dev_t.c print_fields.h \
760e82
+	personality.c pidfd_getfd.c pidfd_open.c pidns.c pkeys.c \
760e82
+	poll.c prctl.c print_aio_sigset.c print_dev_t.c print_fields.h \
760e82
 	print_group_req.c print_ifindex.c print_instruction_pointer.c \
760e82
 	print_kernel_version.c print_mac.c print_mq_attr.c \
760e82
 	print_msgbuf.c print_sg_req_info.c print_sigevent.c \
760e82
@@ -369,10 +369,10 @@
760e82
 	string_to_uint.h swapon.c sync_file_range.c sync_file_range2.c \
760e82
 	syscall.c sysctl.c sysent.h sysent_shorthand_defs.h \
760e82
 	sysent_shorthand_undefs.h sysinfo.c syslog.c sysmips.c term.c \
760e82
-	time.c times.c trace_event.h truncate.c ubi.c ucopy.c uid.c \
760e82
-	uid16.c umask.c umount.c uname.c upeek.c upoke.c userfaultfd.c \
760e82
-	ustat.c util.c utime.c utimes.c v4l2.c wait.c wait.h \
760e82
-	watchdog_ioctl.c xattr.c xfs_quota_stat.h xgetdents.c \
760e82
+	time.c times.c trace_event.h trie.c trie.h truncate.c ubi.c \
760e82
+	ucopy.c uid.c uid16.c umask.c umount.c uname.c upeek.c upoke.c \
760e82
+	userfaultfd.c ustat.c util.c utime.c utimes.c v4l2.c wait.c \
760e82
+	wait.h watchdog_ioctl.c xattr.c xfs_quota_stat.h xgetdents.c \
760e82
 	xgetdents.h xlat.c xlat.h xmalloc.c xmalloc.h xstring.h \
760e82
 	types/cryptouser.h types/evdev.h types/io_uring.h \
760e82
 	types/openat2.h types/rtnl_link.h types/rtnl_mdb.h \
760e82
@@ -487,8 +487,9 @@
760e82
 	libstrace_a-perf_ioctl.$(OBJEXT) \
760e82
 	libstrace_a-personality.$(OBJEXT) \
760e82
 	libstrace_a-pidfd_getfd.$(OBJEXT) \
760e82
-	libstrace_a-pidfd_open.$(OBJEXT) libstrace_a-pkeys.$(OBJEXT) \
760e82
-	libstrace_a-poll.$(OBJEXT) libstrace_a-prctl.$(OBJEXT) \
760e82
+	libstrace_a-pidfd_open.$(OBJEXT) libstrace_a-pidns.$(OBJEXT) \
760e82
+	libstrace_a-pkeys.$(OBJEXT) libstrace_a-poll.$(OBJEXT) \
760e82
+	libstrace_a-prctl.$(OBJEXT) \
760e82
 	libstrace_a-print_aio_sigset.$(OBJEXT) \
760e82
 	libstrace_a-print_dev_t.$(OBJEXT) \
760e82
 	libstrace_a-print_group_req.$(OBJEXT) \
760e82
@@ -553,15 +554,15 @@
760e82
 	libstrace_a-sysinfo.$(OBJEXT) libstrace_a-syslog.$(OBJEXT) \
760e82
 	libstrace_a-sysmips.$(OBJEXT) libstrace_a-term.$(OBJEXT) \
760e82
 	libstrace_a-time.$(OBJEXT) libstrace_a-times.$(OBJEXT) \
760e82
-	libstrace_a-truncate.$(OBJEXT) libstrace_a-ubi.$(OBJEXT) \
760e82
-	libstrace_a-ucopy.$(OBJEXT) libstrace_a-uid.$(OBJEXT) \
760e82
-	libstrace_a-uid16.$(OBJEXT) libstrace_a-umask.$(OBJEXT) \
760e82
-	libstrace_a-umount.$(OBJEXT) libstrace_a-uname.$(OBJEXT) \
760e82
-	libstrace_a-upeek.$(OBJEXT) libstrace_a-upoke.$(OBJEXT) \
760e82
-	libstrace_a-userfaultfd.$(OBJEXT) libstrace_a-ustat.$(OBJEXT) \
760e82
-	libstrace_a-util.$(OBJEXT) libstrace_a-utime.$(OBJEXT) \
760e82
-	libstrace_a-utimes.$(OBJEXT) libstrace_a-v4l2.$(OBJEXT) \
760e82
-	libstrace_a-wait.$(OBJEXT) \
760e82
+	libstrace_a-trie.$(OBJEXT) libstrace_a-truncate.$(OBJEXT) \
760e82
+	libstrace_a-ubi.$(OBJEXT) libstrace_a-ucopy.$(OBJEXT) \
760e82
+	libstrace_a-uid.$(OBJEXT) libstrace_a-uid16.$(OBJEXT) \
760e82
+	libstrace_a-umask.$(OBJEXT) libstrace_a-umount.$(OBJEXT) \
760e82
+	libstrace_a-uname.$(OBJEXT) libstrace_a-upeek.$(OBJEXT) \
760e82
+	libstrace_a-upoke.$(OBJEXT) libstrace_a-userfaultfd.$(OBJEXT) \
760e82
+	libstrace_a-ustat.$(OBJEXT) libstrace_a-util.$(OBJEXT) \
760e82
+	libstrace_a-utime.$(OBJEXT) libstrace_a-utimes.$(OBJEXT) \
760e82
+	libstrace_a-v4l2.$(OBJEXT) libstrace_a-wait.$(OBJEXT) \
760e82
 	libstrace_a-watchdog_ioctl.$(OBJEXT) \
760e82
 	libstrace_a-xattr.$(OBJEXT) libstrace_a-xgetdents.$(OBJEXT) \
760e82
 	libstrace_a-xlat.$(OBJEXT) libstrace_a-xmalloc.$(OBJEXT) \
760e82
@@ -834,6 +835,7 @@
760e82
 	./$(DEPDIR)/libstrace_a-personality.Po \
760e82
 	./$(DEPDIR)/libstrace_a-pidfd_getfd.Po \
760e82
 	./$(DEPDIR)/libstrace_a-pidfd_open.Po \
760e82
+	./$(DEPDIR)/libstrace_a-pidns.Po \
760e82
 	./$(DEPDIR)/libstrace_a-pkeys.Po \
760e82
 	./$(DEPDIR)/libstrace_a-poll.Po \
760e82
 	./$(DEPDIR)/libstrace_a-prctl.Po \
760e82
@@ -924,6 +926,7 @@
760e82
 	./$(DEPDIR)/libstrace_a-term.Po \
760e82
 	./$(DEPDIR)/libstrace_a-time.Po \
760e82
 	./$(DEPDIR)/libstrace_a-times.Po \
760e82
+	./$(DEPDIR)/libstrace_a-trie.Po \
760e82
 	./$(DEPDIR)/libstrace_a-truncate.Po \
760e82
 	./$(DEPDIR)/libstrace_a-ubi.Po \
760e82
 	./$(DEPDIR)/libstrace_a-ucopy.Po \
760e82
@@ -1829,8 +1832,8 @@
760e82
 	nlattr.c nlattr.h nsfs.c nsfs.h nsig.h numa.c number_set.c \
760e82
 	number_set.h oldstat.c open.c open_tree.c or1k_atomic.c \
760e82
 	pathtrace.c perf.c perf_event_struct.h perf_ioctl.c \
760e82
-	personality.c pidfd_getfd.c pidfd_open.c pkeys.c poll.c \
760e82
-	prctl.c print_aio_sigset.c print_dev_t.c print_fields.h \
760e82
+	personality.c pidfd_getfd.c pidfd_open.c pidns.c pkeys.c \
760e82
+	poll.c prctl.c print_aio_sigset.c print_dev_t.c print_fields.h \
760e82
 	print_group_req.c print_ifindex.c print_instruction_pointer.c \
760e82
 	print_kernel_version.c print_mac.c print_mq_attr.c \
760e82
 	print_msgbuf.c print_sg_req_info.c print_sigevent.c \
760e82
@@ -1854,10 +1857,10 @@
760e82
 	string_to_uint.h swapon.c sync_file_range.c sync_file_range2.c \
760e82
 	syscall.c sysctl.c sysent.h sysent_shorthand_defs.h \
760e82
 	sysent_shorthand_undefs.h sysinfo.c syslog.c sysmips.c term.c \
760e82
-	time.c times.c trace_event.h truncate.c ubi.c ucopy.c uid.c \
760e82
-	uid16.c umask.c umount.c uname.c upeek.c upoke.c userfaultfd.c \
760e82
-	ustat.c util.c utime.c utimes.c v4l2.c wait.c wait.h \
760e82
-	watchdog_ioctl.c xattr.c xfs_quota_stat.h xgetdents.c \
760e82
+	time.c times.c trace_event.h trie.c trie.h truncate.c ubi.c \
760e82
+	ucopy.c uid.c uid16.c umask.c umount.c uname.c upeek.c upoke.c \
760e82
+	userfaultfd.c ustat.c util.c utime.c utimes.c v4l2.c wait.c \
760e82
+	wait.h watchdog_ioctl.c xattr.c xfs_quota_stat.h xgetdents.c \
760e82
 	xgetdents.h xlat.c xlat.h xmalloc.c xmalloc.h xstring.h \
760e82
 	$(TYPES_HEADER_FILES) $(strace_SOURCES_check) $(am__append_1) \
760e82
 	$(am__append_2) $(am__append_7)
760e82
@@ -2899,6 +2902,7 @@
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-personality.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-pidfd_getfd.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-pidfd_open.Po@am__quote@ # am--include-marker
760e82
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-pidns.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-pkeys.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-poll.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-prctl.Po@am__quote@ # am--include-marker
760e82
@@ -2989,6 +2993,7 @@
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-term.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-time.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-times.Po@am__quote@ # am--include-marker
760e82
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-trie.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-truncate.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-ubi.Po@am__quote@ # am--include-marker
760e82
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstrace_a-ucopy.Po@am__quote@ # am--include-marker
760e82
@@ -6015,6 +6020,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-pidfd_open.obj `if test -f 'pidfd_open.c'; then $(CYGPATH_W) 'pidfd_open.c'; else $(CYGPATH_W) '$(srcdir)/pidfd_open.c'; fi`
760e82
 
760e82
+libstrace_a-pidns.o: pidns.c
760e82
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -MT libstrace_a-pidns.o -MD -MP -MF $(DEPDIR)/libstrace_a-pidns.Tpo -c -o libstrace_a-pidns.o `test -f 'pidns.c' || echo '$(srcdir)/'`pidns.c
760e82
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstrace_a-pidns.Tpo $(DEPDIR)/libstrace_a-pidns.Po
760e82
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pidns.c' object='libstrace_a-pidns.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-pidns.o `test -f 'pidns.c' || echo '$(srcdir)/'`pidns.c
760e82
+
760e82
+libstrace_a-pidns.obj: pidns.c
760e82
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -MT libstrace_a-pidns.obj -MD -MP -MF $(DEPDIR)/libstrace_a-pidns.Tpo -c -o libstrace_a-pidns.obj `if test -f 'pidns.c'; then $(CYGPATH_W) 'pidns.c'; else $(CYGPATH_W) '$(srcdir)/pidns.c'; fi`
760e82
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstrace_a-pidns.Tpo $(DEPDIR)/libstrace_a-pidns.Po
760e82
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pidns.c' object='libstrace_a-pidns.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-pidns.obj `if test -f 'pidns.c'; then $(CYGPATH_W) 'pidns.c'; else $(CYGPATH_W) '$(srcdir)/pidns.c'; fi`
760e82
+
760e82
 libstrace_a-pkeys.o: pkeys.c
760e82
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -MT libstrace_a-pkeys.o -MD -MP -MF $(DEPDIR)/libstrace_a-pkeys.Tpo -c -o libstrace_a-pkeys.o `test -f 'pkeys.c' || echo '$(srcdir)/'`pkeys.c
760e82
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstrace_a-pkeys.Tpo $(DEPDIR)/libstrace_a-pkeys.Po
760e82
@@ -7275,6 +7294,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-times.obj `if test -f 'times.c'; then $(CYGPATH_W) 'times.c'; else $(CYGPATH_W) '$(srcdir)/times.c'; fi`
760e82
 
760e82
+libstrace_a-trie.o: trie.c
760e82
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -MT libstrace_a-trie.o -MD -MP -MF $(DEPDIR)/libstrace_a-trie.Tpo -c -o libstrace_a-trie.o `test -f 'trie.c' || echo '$(srcdir)/'`trie.c
760e82
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstrace_a-trie.Tpo $(DEPDIR)/libstrace_a-trie.Po
760e82
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='trie.c' object='libstrace_a-trie.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-trie.o `test -f 'trie.c' || echo '$(srcdir)/'`trie.c
760e82
+
760e82
+libstrace_a-trie.obj: trie.c
760e82
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -MT libstrace_a-trie.obj -MD -MP -MF $(DEPDIR)/libstrace_a-trie.Tpo -c -o libstrace_a-trie.obj `if test -f 'trie.c'; then $(CYGPATH_W) 'trie.c'; else $(CYGPATH_W) '$(srcdir)/trie.c'; fi`
760e82
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstrace_a-trie.Tpo $(DEPDIR)/libstrace_a-trie.Po
760e82
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='trie.c' object='libstrace_a-trie.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-trie.obj `if test -f 'trie.c'; then $(CYGPATH_W) 'trie.c'; else $(CYGPATH_W) '$(srcdir)/trie.c'; fi`
760e82
+
760e82
 libstrace_a-truncate.o: truncate.c
760e82
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstrace_a_CPPFLAGS) $(CPPFLAGS) $(libstrace_a_CFLAGS) $(CFLAGS) -MT libstrace_a-truncate.o -MD -MP -MF $(DEPDIR)/libstrace_a-truncate.Tpo -c -o libstrace_a-truncate.o `test -f 'truncate.c' || echo '$(srcdir)/'`truncate.c
760e82
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libstrace_a-truncate.Tpo $(DEPDIR)/libstrace_a-truncate.Po
760e82
@@ -8411,6 +8444,7 @@
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-personality.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-pidfd_getfd.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-pidfd_open.Po
760e82
+	-rm -f ./$(DEPDIR)/libstrace_a-pidns.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-pkeys.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-poll.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-prctl.Po
760e82
@@ -8501,6 +8535,7 @@
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-term.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-time.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-times.Po
760e82
+	-rm -f ./$(DEPDIR)/libstrace_a-trie.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-truncate.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-ubi.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-ucopy.Po
760e82
@@ -8796,6 +8831,7 @@
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-personality.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-pidfd_getfd.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-pidfd_open.Po
760e82
+	-rm -f ./$(DEPDIR)/libstrace_a-pidns.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-pkeys.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-poll.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-prctl.Po
760e82
@@ -8886,6 +8922,7 @@
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-term.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-time.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-times.Po
760e82
+	-rm -f ./$(DEPDIR)/libstrace_a-trie.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-truncate.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-ubi.Po
760e82
 	-rm -f ./$(DEPDIR)/libstrace_a-ucopy.Po