Implement membarrier syscall decoding

* membarrier.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/membarrier_cmds.in: New file.
* linux/dummy.h (membarrier): Remove.
* tests/membarrier.c: New file.
* tests/membarrier.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add membarrier.
(TESTS): Add membarrier.test.
* tests/.gitignore: Add membarrier.
This commit is contained in:
Дмитрий Левин 2015-11-15 02:29:29 +00:00
parent a6ebdb149e
commit 2aec1e67df
8 changed files with 71 additions and 1 deletions

View File

@ -86,6 +86,7 @@ strace_SOURCES = \
loop.c \
lseek.c \
mem.c \
membarrier.c \
memfd_create.c \
mknod.c \
mount.c \

View File

@ -37,7 +37,6 @@
#define sys_kcmp printargs
#define sys_kexec_file_load printargs
#define sys_lookup_dcookie printargs
#define sys_membarrier printargs
#define sys_mlock2 printargs
#define sys_name_to_handle_at printargs
#define sys_open_by_handle_at printargs

21
membarrier.c Normal file
View File

@ -0,0 +1,21 @@
#include "defs.h"
#include "xlat/membarrier_cmds.h"
SYS_FUNC(membarrier)
{
if (entering(tcp)) {
int cmd = tcp->u_arg[0], flags = tcp->u_arg[1];
printxval(membarrier_cmds, cmd, "MEMBARRIER_CMD_???");
tprintf(", %d", flags);
return cmd ? RVAL_DECODED : 0;
}
if (syserror(tcp) || !tcp->u_rval)
return 0;
tcp->auxstr = sprintflags("", membarrier_cmds, tcp->u_rval);
return RVAL_HEX | RVAL_STR;
}

1
tests/.gitignore vendored
View File

@ -18,6 +18,7 @@ ipc_msg
ipc_msgbuf
ipc_sem
ipc_shm
membarrier
memfd_create
mmap
mmap64

View File

@ -31,6 +31,7 @@ check_PROGRAMS = \
ipc_msgbuf \
ipc_sem \
ipc_shm \
membarrier \
memfd_create \
mmap \
mmap64 \
@ -145,6 +146,7 @@ TESTS = \
stat64-v.test \
statfs.test \
sysinfo.test \
membarrier.test \
memfd_create.test \
mmap.test \
mmap64.test \

31
tests/membarrier.c Normal file
View File

@ -0,0 +1,31 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/syscall.h>
int
main(void)
{
#ifdef __NR_membarrier
if (syscall(__NR_membarrier, 3, 255) != -1)
return 77;
printf("membarrier(0x3 /* MEMBARRIER_CMD_??? */, 255) = -1 %s\n",
errno == ENOSYS ?
"ENOSYS (Function not implemented)" :
"EINVAL (Invalid argument)");
if (errno != ENOSYS) {
if (syscall(__NR_membarrier, 0, 0) != 1)
return 1; /* the test needs to be updated? */
puts("membarrier(MEMBARRIER_CMD_QUERY, 0)"
" = 0x1 (MEMBARRIER_CMD_SHARED)");
}
puts("+++ exited with 0 +++");
return 0;
#else
return 77;
#endif
}

13
tests/membarrier.test Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# Check membarrier syscall decoding.
. "${srcdir=.}/init.sh"
run_prog > /dev/null
OUT="$LOG.out"
run_strace -a36 -emembarrier $args > "$OUT"
match_diff "$OUT" "$LOG"
rm -f "$OUT"
exit 0

2
xlat/membarrier_cmds.in Normal file
View File

@ -0,0 +1,2 @@
MEMBARRIER_CMD_QUERY 0
MEMBARRIER_CMD_SHARED 1