]> granicus.if.org Git - strace/commitdiff
poll.c: introduce do_ppoll
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 4 May 2019 23:15:52 +0000 (23:15 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 4 May 2019 23:15:52 +0000 (23:15 +0000)
This is going to be used to implement a parser of ppoll_time64 syscall.

* poll.c (decode_poll_exiting): Add sprint_ts argument.
(SYS_FUNC(poll)): Pass sprint_timespec to decode_poll_exiting.
(do_ppoll): New function.
(SYS_FUNC(ppoll)): Turn into a thin wrapper around do_ppoll.

poll.c

diff --git a/poll.c b/poll.c
index c6790d7c03f2711285f331edaec29cf37b9ce6a1..5ad16da26b8ccd97b36578e2a9e58480861ecd37 100644 (file)
--- a/poll.c
+++ b/poll.c
@@ -42,7 +42,8 @@ decode_poll_entering(struct tcb *tcp)
 }
 
 static int
-decode_poll_exiting(struct tcb *const tcp, const kernel_ulong_t pts)
+decode_poll_exiting(struct tcb *const tcp, const sprint_obj_by_addr_fn sprint_ts,
+                   const kernel_ulong_t pts)
 {
        struct pollfd fds;
        const unsigned int nfds = tcp->u_arg[1];
@@ -114,7 +115,7 @@ decode_poll_exiting(struct tcb *const tcp, const kernel_ulong_t pts)
 
        *outptr = '\0';
        if (pts) {
-               const char *str = sprint_timespec(tcp, pts);
+               const char *str = sprint_ts(tcp, pts);
 
                if (outptr + sizeof(", left ") + strlen(str) < end_outstr) {
                        outptr = stpcpy(outptr, outptr == outstr ? "left " : ", left ");
@@ -140,16 +141,18 @@ SYS_FUNC(poll)
 
                return 0;
        } else {
-               return decode_poll_exiting(tcp, 0);
+               return decode_poll_exiting(tcp, sprint_timespec, 0);
        }
 }
 
-SYS_FUNC(ppoll)
+static int
+do_ppoll(struct tcb *const tcp, const print_obj_by_addr_fn print_ts,
+        const sprint_obj_by_addr_fn sprint_ts)
 {
        if (entering(tcp)) {
                decode_poll_entering(tcp);
 
-               print_timespec(tcp, tcp->u_arg[2]);
+               print_ts(tcp, tcp->u_arg[2]);
                tprints(", ");
                /* NB: kernel requires arg[4] == NSIG_BYTES */
                print_sigset_addr_len(tcp, tcp->u_arg[3], tcp->u_arg[4]);
@@ -157,6 +160,11 @@ SYS_FUNC(ppoll)
 
                return 0;
        } else {
-               return decode_poll_exiting(tcp, tcp->u_arg[2]);
+               return decode_poll_exiting(tcp, sprint_ts, tcp->u_arg[2]);
        }
 }
+
+SYS_FUNC(ppoll)
+{
+       return do_ppoll(tcp, print_timespec, sprint_timespec);
+}