From 322be803420d5ebc312cf26e1a2c2eb7ac21c0e0 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 17 Sep 2015 20:23:31 +0000 Subject: [PATCH] Convert parser of struct itimerval to new mpers infrastructure * defs.h [ALPHA] (print_itimerval32): New prototype. * print_time.c (print_itimerval): New mpers printer. [ALPHA] (timeval32_t): New typedef. [ALPHA] (print_timeval32_t, print_itimerval32): New functions. * time.c (sys_getitimer, sys_setitimer): Use print_itimerval instead of printitv. [ALPHA] (sys_osf_getitimer, sys_osf_setitimer): Use print_itimerval32 instead of printitv_bitness. (tprint_timeval32, tprint_timeval, printitv_bitness, printitv): Remove. --- defs.h | 1 + print_time.c | 43 ++++++++++++++++++++++++++++++++++++++++ time.c | 55 ++++++---------------------------------------------- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/defs.h b/defs.h index 7fd619d8..1f0900b1 100644 --- a/defs.h +++ b/defs.h @@ -660,6 +660,7 @@ extern void printsock(struct tcb *, long, int); extern void print_sock_optmgmt(struct tcb *, long, int); #ifdef ALPHA extern void printrusage32(struct tcb *, long); +extern void print_itimerval32(struct tcb *tcp, long); #endif extern void printuid(const char *, const unsigned int); extern void print_sigset_addr_len(struct tcb *, long, long); diff --git a/print_time.c b/print_time.c index a1aed605..147e018e 100644 --- a/print_time.c +++ b/print_time.c @@ -88,6 +88,20 @@ MPERS_PRINTER_DECL(void, print_timeval_pair)(struct tcb *tcp, const long addr) tprints("]"); } +MPERS_PRINTER_DECL(void, print_itimerval)(struct tcb *tcp, const long addr) +{ + timeval_t t[2]; + + if (umove_or_printaddr(tcp, addr, &t)) + return; + + tprints("{it_interval="); + print_timeval_t(&t[0]); + tprints(", it_value="); + print_timeval_t(&t[1]); + tprints("}"); +} + SYS_FUNC(time) { if (exiting(tcp)) { @@ -99,3 +113,32 @@ SYS_FUNC(time) return 0; } + +#ifdef ALPHA + +typedef struct { + int tv_sec, tv_usec; +} timeval32_t; + +static void +print_timeval32_t(const timeval32_t *t) +{ + tprintf(time_fmt, (intmax_t) t->tv_sec, (intmax_t) t->tv_usec); +} + +void +print_itimerval32(struct tcb *tcp, const long addr) +{ + timeval32_t t[2]; + + if (umove_or_printaddr(tcp, addr, &t)) + return; + + tprints("{it_interval="); + print_timeval32_t(&t[0]); + tprints(", it_value="); + print_timeval32_t(&t[1]); + tprints("}"); +} + +#endif /* ALPHA */ diff --git a/time.c b/time.c index c1f06716..e37f26e0 100644 --- a/time.c +++ b/time.c @@ -54,18 +54,6 @@ struct timeval32 u_int32_t tv_sec, tv_usec; }; -static void -tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv) -{ - tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec); -} - -static void -tprint_timeval(struct tcb *tcp, const struct timeval *tv) -{ - tprintf("{%ju, %ju}", (uintmax_t) tv->tv_sec, (uintmax_t) tv->tv_usec); -} - void printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special) { @@ -238,44 +226,13 @@ SYS_FUNC(nanosleep) #include "xlat/itimer_which.h" -static void -printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness) -{ - if (bitness == BITNESS_32 || current_time_t_is_compat) { - struct { - struct timeval32 it_interval, it_value; - } itv; - - if (!umove_or_printaddr(tcp, addr, &itv)) { - tprints("{it_interval="); - tprint_timeval32(tcp, &itv.it_interval); - tprints(", it_value="); - tprint_timeval32(tcp, &itv.it_value); - tprints("}"); - } - } else { - struct itimerval itv; - - if (!umove_or_printaddr(tcp, addr, &itv)) { - tprints("{it_interval="); - tprint_timeval(tcp, &itv.it_interval); - tprints(", it_value="); - tprint_timeval(tcp, &itv.it_value); - tprints("}"); - } - } -} - -#define printitv(tcp, addr) \ - printitv_bitness((tcp), (addr), BITNESS_CURRENT) - SYS_FUNC(getitimer) { if (entering(tcp)) { printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); tprints(", "); } else { - printitv(tcp, tcp->u_arg[1]); + print_itimerval(tcp, tcp->u_arg[1]); } return 0; } @@ -287,7 +244,7 @@ SYS_FUNC(osf_getitimer) printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); tprints(", "); } else { - printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); + print_itimerval32(tcp, tcp->u_arg[1]); } return 0; } @@ -298,10 +255,10 @@ SYS_FUNC(setitimer) if (entering(tcp)) { printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); tprints(", "); - printitv(tcp, tcp->u_arg[1]); + print_itimerval(tcp, tcp->u_arg[1]); tprints(", "); } else { - printitv(tcp, tcp->u_arg[2]); + print_itimerval(tcp, tcp->u_arg[2]); } return 0; } @@ -312,10 +269,10 @@ SYS_FUNC(osf_setitimer) if (entering(tcp)) { printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); tprints(", "); - printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); + print_itimerval32(tcp, tcp->u_arg[1]); tprints(", "); } else { - printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32); + print_itimerval32(tcp, tcp->u_arg[2]); } return 0; } -- 2.40.0