summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2020-03-30 17:35:22 +0200
committerEugene Syromyatnikov <evgsyr@gmail.com>2020-03-30 23:14:24 +0200
commit9d35c2d75f61fd5c05126e5ba310c2f3bd18f75e (patch)
tree93cbbd2a249e7cd69e3176bf9b4418fbc9c40f8e
parenta63e941e55bdac59bf579c809d56369ed7c5c202 (diff)
downloadstrace-9d35c2d75f61fd5c05126e5ba310c2f3bd18f75e.tar.gz
Move printpidfd from kcmp.c to util.c
And rename it to print_pid_fd in an attempt to minimise confusion with the kernel's pidfd concept. * kcmp (PRINT_FIELD_PIDFD, SYS_FUNC(kcmp)): Change printpidfd calls to print_pid_fd. (printpidfd): Move it... * util.c (print_pid_fd): ...here. Drop the static qualifier, update the comment describing why this is a stub. * defs.h (print_pid_fd): New declaration.
-rw-r--r--defs.h5
-rw-r--r--kcmp.c18
-rw-r--r--util.c11
3 files changed, 20 insertions, 14 deletions
diff --git a/defs.h b/defs.h
index 6e2d0f261..be1f0254e 100644
--- a/defs.h
+++ b/defs.h
@@ -1028,6 +1028,11 @@ printpath(struct tcb *, kernel_ulong_t addr);
# define TIMESPEC_TEXT_BUFSIZE \
(sizeof(long long) * 3 * 2 + sizeof("{tv_sec=-, tv_nsec=}"))
extern void printfd(struct tcb *, int);
+/**
+ * Print file descriptor fd owned by process with ID pid (from the PID NS
+ * of the tracee the descriptor tcp). This is a stub.
+ */
+extern void print_pid_fd(struct tcb *tcp, pid_t pid, int fd);
extern void print_sockaddr(const void *sa, int len);
extern bool
print_inet_addr(int af, const void *addr, unsigned int len, const char *var_name);
diff --git a/kcmp.c b/kcmp.c
index 6722d7742..2fc81dc63 100644
--- a/kcmp.c
+++ b/kcmp.c
@@ -16,20 +16,10 @@ struct strace_kcmp_epoll_slot {
uint32_t toff;
};
-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_); \
+ print_pid_fd((tcp_), (pid_), (where_).field_); \
} while (0)
SYS_FUNC(kcmp)
@@ -46,9 +36,9 @@ SYS_FUNC(kcmp)
switch (type) {
case KCMP_FILE:
tprints(", ");
- printpidfd(tcp, pid1, idx1);
+ print_pid_fd(tcp, pid1, idx1);
tprints(", ");
- printpidfd(tcp, pid1, idx2);
+ print_pid_fd(tcp, pid1, idx2);
break;
@@ -56,7 +46,7 @@ SYS_FUNC(kcmp)
struct strace_kcmp_epoll_slot slot;
tprints(", ");
- printpidfd(tcp, pid1, idx1);
+ print_pid_fd(tcp, pid1, idx1);
tprints(", ");
if (umove_or_printaddr(tcp, idx2, &slot))
diff --git a/util.c b/util.c
index 1cb767d05..a76865304 100644
--- a/util.c
+++ b/util.c
@@ -590,6 +590,17 @@ printed:
}
}
+void
+print_pid_fd(struct tcb *tcp, pid_t pid, int fd)
+{
+ /*
+ * TODO: We want to have the same formatting as printfd here,
+ * but we should figure out first which process in strace's
+ * PID NS is referred to by pid in tracee's PID NS.
+ */
+ tprintf("%d", fd);
+}
+
/*
* Quote string `instr' of length `size'
* Write up to (3 + `size' * 4) bytes to `outstr' buffer.