From a8e4aa6b58e3890127f82b60b83155680fe8665d Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 10 May 2019 22:27:59 +0000 Subject: [PATCH] Implement printer for kernel_timex32_t This is going to be used to re-implement parsers of syscalls that deal with 32-bit struct timex. * print_timex.h: New file. * Makefile.am (strace_SOURCES): Add it. * defs.h (print_timex32): New prototype. * print_timex.c: Include "kernel_timex.h". [HAVE_ARCH_TIME32_SYSCALLS] (print_timex32): New function. --- Makefile.am | 1 + defs.h | 1 + print_timex.c | 16 ++++++++++++++++ print_timex.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 print_timex.h diff --git a/Makefile.am b/Makefile.am index 5b671625..e8687f2d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -249,6 +249,7 @@ strace_SOURCES = \ print_timespec64.c \ print_timeval.c \ print_timex.c \ + print_timex.h \ print_utils.h \ printmode.c \ printrusage.c \ diff --git a/defs.h b/defs.h index e7969ccc..24838c73 100644 --- a/defs.h +++ b/defs.h @@ -1118,6 +1118,7 @@ extern int print_timespec32(struct tcb *, kernel_ulong_t); extern const char *sprint_timespec32(struct tcb *, kernel_ulong_t); extern int print_timespec32_utime_pair(struct tcb *, kernel_ulong_t); extern int print_itimerspec32(struct tcb *, kernel_ulong_t); +extern int print_timex32(struct tcb *, kernel_ulong_t); # endif /* HAVE_ARCH_TIME32_SYSCALLS */ extern bool print_timespec64_data_size(const void *arg, size_t size); diff --git a/print_timex.c b/print_timex.c index d60b69ba..ddd2d67d 100644 --- a/print_timex.c +++ b/print_timex.c @@ -51,3 +51,19 @@ MPERS_PRINTER_DECL(int, print_timex, tprints("}"); return 0; } + +#ifndef IN_MPERS + +# include "kernel_timex.h" + +# if HAVE_ARCH_TIME32_SYSCALLS + +# define PRINT_TIMEX print_timex32 +# define TIMEX_T kernel_timex32_t +# include "print_timex.h" +# undef TIMEX_T +# undef PRINT_TIMEX + +# endif /* HAVE_ARCH_TIME32_SYSCALLS */ + +#endif /* !IN_MPERS */ diff --git a/print_timex.h b/print_timex.h new file mode 100644 index 00000000..3cc83062 --- /dev/null +++ b/print_timex.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 1991, 1992 Paul Kranenburg + * Copyright (c) 1993 Branko Lankester + * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey + * Copyright (c) 2006-2015 Dmitry V. Levin + * Copyright (c) 2015-2019 The strace developers. + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "print_fields.h" + +int +PRINT_TIMEX(struct tcb *const tcp, const kernel_ulong_t addr) +{ + TIMEX_T tx; + + if (umove_or_printaddr(tcp, addr, &tx)) + return -1; + + PRINT_FIELD_FLAGS("{", tx, modes, adjtimex_modes, "ADJ_???"); + PRINT_FIELD_D(", ", tx, offset); + PRINT_FIELD_D(", ", tx, freq); + PRINT_FIELD_D(", ", tx, maxerror); + PRINT_FIELD_D(", ", tx, esterror); + PRINT_FIELD_FLAGS(", ", tx, status, adjtimex_status, "STA_???"); + PRINT_FIELD_D(", ", tx, constant); + PRINT_FIELD_D(", ", tx, precision); + PRINT_FIELD_D(", ", tx, tolerance); + PRINT_FIELD_D(", time={", tx.time, tv_sec); + PRINT_FIELD_U(", ", tx.time, tv_usec); + PRINT_FIELD_D("}, ", tx, tick); + PRINT_FIELD_D(", ", tx, ppsfreq); + PRINT_FIELD_D(", ", tx, jitter); + PRINT_FIELD_D(", ", tx, shift); + PRINT_FIELD_D(", ", tx, stabil); + PRINT_FIELD_D(", ", tx, jitcnt); + PRINT_FIELD_D(", ", tx, calcnt); + PRINT_FIELD_D(", ", tx, errcnt); + PRINT_FIELD_D(", ", tx, stbcnt); + PRINT_FIELD_D(", ", tx, tai); + tprints("}"); + return 0; +} -- 2.40.0