/*
* Copyright (c) 2015-2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include MPERS_DEFS
+#include "xstring.h"
+
static const char timeval_fmt[] = "{tv_sec=%lld, tv_usec=%llu}";
static void
zero_extend_signed_to_ull(t->tv_usec));
}
+static void
+print_timeval_t_utime(const timeval_t *t)
+{
+ print_timeval_t(t);
+ tprints_comment(sprinttime_usec(t->tv_sec,
+ zero_extend_signed_to_ull(t->tv_usec)));
+}
+
MPERS_PRINTER_DECL(void, print_struct_timeval, const void *arg)
{
print_timeval_t(arg);
}
+MPERS_PRINTER_DECL(bool, print_struct_timeval_data_size,
+ const void *arg, const size_t size)
+{
+ if (size < sizeof(timeval_t)) {
+ tprints("?");
+ return false;
+ }
+
+ print_timeval_t(arg);
+ return true;
+}
+
MPERS_PRINTER_DECL(void, print_timeval,
struct tcb *const tcp, const kernel_ulong_t addr)
{
return;
tprints("[");
- print_timeval_t(&t[0]);
+ print_timeval_t_utime(&t[0]);
tprints(", ");
- print_timeval_t(&t[1]);
+ print_timeval_t_utime(&t[1]);
tprints("]");
}
strcpy(buf, "NULL");
} else if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
umove(tcp, addr, &t)) {
- snprintf(buf, sizeof(buf), "%#" PRI_klx, addr);
+ xsprintf(buf, "%#" PRI_klx, addr);
} else {
- snprintf(buf, sizeof(buf), timeval_fmt,
+ xsprintf(buf, timeval_fmt,
(long long) t.tv_sec,
zero_extend_signed_to_ull(t.tv_usec));
}
zero_extend_signed_to_ull(t->tv_usec));
}
+static void
+print_timeval32_t_utime(const timeval32_t *t)
+{
+ print_timeval32_t(t);
+ tprints_comment(sprinttime_usec(t->tv_sec,
+ zero_extend_signed_to_ull(t->tv_usec)));
+}
+
void
print_timeval32(struct tcb *const tcp, const kernel_ulong_t addr)
{
return;
tprints("[");
- print_timeval32_t(&t[0]);
+ print_timeval32_t_utime(&t[0]);
tprints(", ");
- print_timeval32_t(&t[1]);
+ print_timeval32_t_utime(&t[1]);
tprints("]");
}
strcpy(buf, "NULL");
} else if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
umove(tcp, addr, &t)) {
- snprintf(buf, sizeof(buf), "%#" PRI_klx, addr);
+ xsprintf(buf, "%#" PRI_klx, addr);
} else {
- snprintf(buf, sizeof(buf), timeval_fmt,
+ xsprintf(buf, timeval_fmt,
(long long) t.tv_sec,
zero_extend_signed_to_ull(t.tv_usec));
}