Browse Source

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.
Dmitry V. Levin 7 months ago
parent
commit
a8e4aa6b58
4 changed files with 63 additions and 0 deletions
  1. 1
    0
      Makefile.am
  2. 1
    0
      defs.h
  3. 16
    0
      print_timex.c
  4. 45
    0
      print_timex.h

+ 1
- 0
Makefile.am View File

@@ -249,6 +249,7 @@ strace_SOURCES =	\
249 249
 	print_timespec64.c \
250 250
 	print_timeval.c	\
251 251
 	print_timex.c	\
252
+	print_timex.h	\
252 253
 	print_utils.h	\
253 254
 	printmode.c	\
254 255
 	printrusage.c	\

+ 1
- 0
defs.h View File

@@ -1118,6 +1118,7 @@ extern int print_timespec32(struct tcb *, kernel_ulong_t);
1118 1118
 extern const char *sprint_timespec32(struct tcb *, kernel_ulong_t);
1119 1119
 extern int print_timespec32_utime_pair(struct tcb *, kernel_ulong_t);
1120 1120
 extern int print_itimerspec32(struct tcb *, kernel_ulong_t);
1121
+extern int print_timex32(struct tcb *, kernel_ulong_t);
1121 1122
 # endif /* HAVE_ARCH_TIME32_SYSCALLS */
1122 1123
 
1123 1124
 extern bool print_timespec64_data_size(const void *arg, size_t size);

+ 16
- 0
print_timex.c View File

@@ -51,3 +51,19 @@ MPERS_PRINTER_DECL(int, print_timex,
51 51
 	tprints("}");
52 52
 	return 0;
53 53
 }
54
+
55
+#ifndef IN_MPERS
56
+
57
+# include "kernel_timex.h"
58
+
59
+# if HAVE_ARCH_TIME32_SYSCALLS
60
+
61
+#  define PRINT_TIMEX print_timex32
62
+#  define TIMEX_T kernel_timex32_t
63
+#  include "print_timex.h"
64
+#  undef TIMEX_T
65
+#  undef PRINT_TIMEX
66
+
67
+# endif /* HAVE_ARCH_TIME32_SYSCALLS */
68
+
69
+#endif /* !IN_MPERS */

+ 45
- 0
print_timex.h View File

@@ -0,0 +1,45 @@
1
+/*
2
+ * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3
+ * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4
+ * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5
+ * Copyright (c) 2006-2015 Dmitry V. Levin <ldv@altlinux.org>
6
+ * Copyright (c) 2015-2019 The strace developers.
7
+ * All rights reserved.
8
+ *
9
+ * SPDX-License-Identifier: LGPL-2.1-or-later
10
+ */
11
+
12
+#include "print_fields.h"
13
+
14
+int
15
+PRINT_TIMEX(struct tcb *const tcp, const kernel_ulong_t addr)
16
+{
17
+	TIMEX_T tx;
18
+
19
+	if (umove_or_printaddr(tcp, addr, &tx))
20
+		return -1;
21
+
22
+	PRINT_FIELD_FLAGS("{", tx, modes, adjtimex_modes, "ADJ_???");
23
+	PRINT_FIELD_D(", ", tx, offset);
24
+	PRINT_FIELD_D(", ", tx, freq);
25
+	PRINT_FIELD_D(", ", tx, maxerror);
26
+	PRINT_FIELD_D(", ", tx, esterror);
27
+	PRINT_FIELD_FLAGS(", ", tx, status, adjtimex_status, "STA_???");
28
+	PRINT_FIELD_D(", ", tx, constant);
29
+	PRINT_FIELD_D(", ", tx, precision);
30
+	PRINT_FIELD_D(", ", tx, tolerance);
31
+	PRINT_FIELD_D(", time={", tx.time, tv_sec);
32
+	PRINT_FIELD_U(", ", tx.time, tv_usec);
33
+	PRINT_FIELD_D("}, ", tx, tick);
34
+	PRINT_FIELD_D(", ", tx, ppsfreq);
35
+	PRINT_FIELD_D(", ", tx, jitter);
36
+	PRINT_FIELD_D(", ", tx, shift);
37
+	PRINT_FIELD_D(", ", tx, stabil);
38
+	PRINT_FIELD_D(", ", tx, jitcnt);
39
+	PRINT_FIELD_D(", ", tx, calcnt);
40
+	PRINT_FIELD_D(", ", tx, errcnt);
41
+	PRINT_FIELD_D(", ", tx, stbcnt);
42
+	PRINT_FIELD_D(", ", tx, tai);
43
+	tprints("}");
44
+	return 0;
45
+}

Loading…
Cancel
Save