*/
#include "defs.h"
+#include "print_fields.h"
#include "xlat/kcmp_types.h"
+static void
+printpidfd(struct tcb *tcp, pid_t pid, int fd)
+{
+ /*
+ * XXX We want to use printfd here, but we should figure out which
+ * process in strace's PID NS is referred to first.
+ */
+ tprintf("%d", fd);
+}
+
+#define PRINT_FIELD_PIDFD(prefix_, where_, field_, tcp_, pid_) \
+ do { \
+ STRACE_PRINTF("%s%s=", (prefix_), #field_); \
+ printpidfd((tcp_), (pid_), (where_).field_); \
+ } while (0)
+
SYS_FUNC(kcmp)
{
pid_t pid1 = tcp->u_arg[0];
switch (type) {
case KCMP_FILE:
- tprintf(", %u, %u", (unsigned) idx1, (unsigned) idx2);
+ tprints(", ");
+ printpidfd(tcp, pid1, idx1);
+ tprints(", ");
+ printpidfd(tcp, pid1, idx2);
+
break;
case KCMP_FILES:
case KCMP_FS:
# define KCMP_SYSVSEM 6
# endif
+static void
+printpidfd(const char *prefix, pid_t pid, unsigned fd)
+{
+ printf("%s%d", prefix, fd);
+}
+
static void
do_kcmp(kernel_ulong_t pid1, kernel_ulong_t pid2, kernel_ulong_t type,
const char *type_str, kernel_ulong_t idx1, kernel_ulong_t idx2)
else
printf("%#x /* KCMP_??? */", (int) type);
- if (type == KCMP_FILE)
- printf(", %u, %u", (unsigned) idx1, (unsigned) idx2);
- else if (type > KCMP_SYSVSEM)
+ if (type == KCMP_FILE) {
+ printpidfd(", ", pid1, idx1);
+ printpidfd(", ", pid2, idx2);
+ } else if (type > KCMP_SYSVSEM) {
printf(", %#llx, %#llx",
(unsigned long long) idx1, (unsigned long long) idx2);
+ }
printf(") = %s\n", errstr);
}