]> granicus.if.org Git - strace/commitdiff
Introduce printnum_fd
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 20 Jun 2019 09:49:27 +0000 (09:49 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 20 Jun 2019 09:49:27 +0000 (09:49 +0000)
This is going to be used to implement decoding of CLONE_PIDFD flag
of clone syscall.

* defs.h (printnum_fd): New prototype.
* util.c (printnum_fd): New function.

defs.h
util.c

diff --git a/defs.h b/defs.h
index 512ad51f513ccfbd9649e1ac52b2ad78bb76e590..a9c36d152e27d53919ed95de4bfef8d0f0bae6e7 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -1280,6 +1280,9 @@ DECL_PRINTNUM_ADDR(int);
 DECL_PRINTNUM_ADDR(int64);
 # undef DECL_PRINTNUM_ADDR
 
+extern bool
+printnum_fd(struct tcb *, kernel_ulong_t addr);
+
 # ifndef current_wordsize
 extern bool
 printnum_long_int(struct tcb *, kernel_ulong_t addr,
diff --git a/util.c b/util.c
index fa384c59784f171b058b0dde734ffc6f24894ac9..42253ebb05dcedc3a625f051d9745d8b4488a2f0 100644 (file)
--- a/util.c
+++ b/util.c
@@ -270,6 +270,18 @@ DEF_PRINTNUM(int64, uint64_t)
 DEF_PRINTNUM_ADDR(int64, uint64_t)
 DEF_PRINTPAIR(int64, uint64_t)
 
+bool
+printnum_fd(struct tcb *const tcp, const kernel_ulong_t addr)
+{
+       int fd;
+       if (umove_or_printaddr(tcp, addr, &fd))
+               return false;
+       tprints("[");
+       printfd(tcp, fd);
+       tprints("]");
+       return true;
+}
+
 #ifndef current_wordsize
 bool
 printnum_long_int(struct tcb *const tcp, const kernel_ulong_t addr,