--- /dev/null
+#!/bin/sh
+
+# Check decoding of out-of-range syscalls along with debug ouput
+
+. "${srcdir=.}/init.sh"
+
+: ${debug_flag=-d}
+NAME=nsyscalls-d
+
+if [ "$MIPS_ABI" = "o32" ]; then
+ syscall=syscall
+else
+ syscall=none
+fi
+
+run_strace $debug_flag -e trace=$syscall ../$NAME "$STRACE_EXE" 9 \
+ 2> "$LOG-err-all" > "$EXP" 9> "$EXP-err"
+
+[ -n "$debug_flag" ] || > "$EXP-err"
+
+grep "invalid syscall" "$LOG-err-all" > "$LOG-err"
+
+match_diff "$EXP" "$LOG"
+match_diff "$EXP-err" "$LOG-err"
#include "sysent.h"
#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <asm/unistd.h>
#include "sysent_shorthand_undefs.h"
+#ifndef DEBUG_PRINT
+# define DEBUG_PRINT 0
+#endif
+
#if defined __X32_SYSCALL_BIT && defined __NR_read \
&& (__X32_SYSCALL_BIT & __NR_read) != 0
# define SYSCALL_BIT __X32_SYSCALL_BIT
# define SYSCALL_BIT 0
#endif
+#if DEBUG_PRINT
+static const char *strace_name;
+static FILE *debug_out;
+#endif
+
static void
test_syscall(const unsigned long nr)
{
long rc = syscall(nr | SYSCALL_BIT,
a[0], a[1], a[2], a[3], a[4], a[5]);
+
+#if DEBUG_PRINT
+ fprintf(debug_out, "%s: pid %d invalid syscall %ld\n",
+ strace_name, getpid(), nr);
+#endif
+
#ifdef LINUX_MIPSO32
printf("syscall(%#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx)"
" = %ld ENOSYS (%m)\n", nr | SYSCALL_BIT,
}
int
-main(void)
+main(int argc, char *argv[])
{
+#if DEBUG_PRINT
+ if (argc < 3)
+ error_msg_and_fail("Not enough arguments. "
+ "Usage: %s STRACE_NAME DEBUG_OUT_FD",
+ argv[0]);
+
+ strace_name = argv[1];
+
+ errno = 0;
+ int debug_out_fd = strtol(argv[2], NULL, 0);
+ if (errno)
+ error_msg_and_fail("Not a number: %s", argv[2]);
+
+ debug_out = fdopen(debug_out_fd, "a");
+ if (!debug_out)
+ perror_msg_and_fail("fdopen: %d", debug_out_fd);
+#endif
+
test_syscall(ARRAY_SIZE(syscallent));
#ifdef SYS_socket_subcall