From 2d83684f179d2b652d990035c5ae6ed43b3e7955 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 20 Jun 2019 09:49:27 +0000 Subject: [PATCH] Introduce printnum_fd 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 | 3 +++ util.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/defs.h b/defs.h index 512ad51f..a9c36d15 100644 --- 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 fa384c59..42253ebb 100644 --- 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, -- 2.40.0