Mpersify parsers of utimes, futimesat, and utimensat syscalls

Fix multiple personalities support in parsers of utimes, futimesat,
and utimensat syscalls by introducing two mpersified printers:
print_timeval_pair and print_timespec_utime_pair.

* print_time.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* utimes.c (decode_utimes): Remove.
(sys_utimes, sys_futimesat): Use print_timeval_pair instead
of decode_utimes.
(sys_utimensat): Use print_timespec_utime_pair instead of decode_utimes.
This commit is contained in:
Дмитрий Левин 2015-08-04 01:52:40 +03:00
parent 092942206c
commit b5a23ed381
3 changed files with 78 additions and 23 deletions

View File

@ -99,6 +99,7 @@ strace_SOURCES = \
prctl.c \
print_mq_attr.c \
print_msgbuf.c \
print_time.c \
printmode.c \
printrusage.c \
printsiginfo.c \

67
print_time.c Normal file
View File

@ -0,0 +1,67 @@
#include "defs.h"
#include DEF_MPERS_TYPE(timespec_t)
#include DEF_MPERS_TYPE(timeval_t)
typedef struct timespec timespec_t;
typedef struct timeval timeval_t;
#include MPERS_DEFS
#ifndef UTIME_NOW
# define UTIME_NOW ((1l << 30) - 1l)
#endif
#ifndef UTIME_OMIT
# define UTIME_OMIT ((1l << 30) - 2l)
#endif
static void
print_timespec_t_utime(struct tcb *tcp, const timespec_t *t)
{
switch (t->tv_nsec) {
case UTIME_NOW:
tprints("UTIME_NOW");
break;
case UTIME_OMIT:
tprints("UTIME_OMIT");
break;
default:
tprintf("{%jd, %jd}",
(intmax_t) t->tv_sec, (intmax_t) t->tv_nsec);
break;
}
}
static void
print_timeval_t(struct tcb *tcp, const timeval_t *t)
{
tprintf("{%jd, %jd}", (intmax_t) t->tv_sec, (intmax_t) t->tv_usec);
}
MPERS_PRINTER_DECL(void, print_timespec_utime_pair)(struct tcb *tcp, const long addr)
{
timespec_t t[2];
if (umove_or_printaddr(tcp, addr, &t))
return;
tprints("[");
print_timespec_t_utime(tcp, &t[0]);
tprints(", ");
print_timespec_t_utime(tcp, &t[1]);
tprints("]");
}
MPERS_PRINTER_DECL(void, print_timeval_pair)(struct tcb *tcp, const long addr)
{
timeval_t t[2];
if (umove_or_printaddr(tcp, addr, &t))
return;
tprints("[");
print_timeval_t(tcp, &t[0]);
tprints(", ");
print_timeval_t(tcp, &t[1]);
tprints("]");
}

View File

@ -1,27 +1,10 @@
#include "defs.h"
static void
decode_utimes(struct tcb *tcp, int offset, int special)
{
printpath(tcp, tcp->u_arg[offset]);
tprints(", ");
if (tcp->u_arg[offset + 1] == 0)
tprints("NULL");
else {
tprints("[");
printtv_bitness(tcp, tcp->u_arg[offset + 1],
BITNESS_CURRENT, special);
tprints(", ");
printtv_bitness(tcp, tcp->u_arg[offset + 1]
+ sizeof(struct timeval),
BITNESS_CURRENT, special);
tprints("]");
}
}
SYS_FUNC(utimes)
{
decode_utimes(tcp, 0, 0);
printpath(tcp, tcp->u_arg[0]);
tprints(", ");
MPERS_PRINTER_NAME(print_timeval_pair)(tcp, tcp->u_arg[1]);
return RVAL_DECODED;
}
@ -29,7 +12,9 @@ SYS_FUNC(utimes)
SYS_FUNC(futimesat)
{
print_dirfd(tcp, tcp->u_arg[0]);
decode_utimes(tcp, 1, 0);
printpath(tcp, tcp->u_arg[1]);
tprints(", ");
MPERS_PRINTER_NAME(print_timeval_pair)(tcp, tcp->u_arg[2]);
return RVAL_DECODED;
}
@ -37,7 +22,9 @@ SYS_FUNC(futimesat)
SYS_FUNC(utimensat)
{
print_dirfd(tcp, tcp->u_arg[0]);
decode_utimes(tcp, 1, 1);
printpath(tcp, tcp->u_arg[1]);
tprints(", ");
MPERS_PRINTER_NAME(print_timespec_utime_pair)(tcp, tcp->u_arg[2]);
tprints(", ");
printflags(at_flags, tcp->u_arg[3], "AT_???");
@ -49,7 +36,7 @@ SYS_FUNC(osf_utimes)
{
printpath(tcp, tcp->u_arg[0]);
tprints(", ");
printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
return RVAL_DECODED;
}