]> granicus.if.org Git - strace/commitdiff
Implement printer for kernel_timex32_t
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 10 May 2019 22:27:59 +0000 (22:27 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 10 May 2019 22:27:59 +0000 (22:27 +0000)
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
defs.h
print_timex.c
print_timex.h [new file with mode: 0644]

index 5b671625eed42136fc31d0175282af72ecdcbea2..e8687f2dcf8aa05e33b3faaec80b2adc6d5cf8e4 100644 (file)
@@ -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 e7969ccce061e12360ab15a515132f6ac12d4085..24838c734e28709536fca11958452e25a0f23cb9 100644 (file)
--- 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);
index d60b69ba17597990733ec99e9fc2672e835ed433..ddd2d67dfd958f48ba91de7044d240dacda3960c 100644 (file)
@@ -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 (file)
index 0000000..3cc8306
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
+ * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
+ * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
+ * Copyright (c) 2006-2015 Dmitry V. Levin <ldv@altlinux.org>
+ * 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;
+}