This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Committed: sim/cris: support ENOSYS instead of halt for unknown syscalls
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 2 Oct 2006 05:30:07 +0200
- Subject: Committed: sim/cris: support ENOSYS instead of halt for unknown syscalls
Unknown and incompletely implemented syscalls used to cause the simulator
to abort with a message. This patch makes it optional through
--cris-unknown-syscall=stop|enosys|enosys-quiet to continue, indicating
ENOSYS, with or without a message. The default is still to stop with a
message. There was also a bug and an incorrect comment regarding the
error message for --cris-cycles=basic that I did not bother to send
separately.
sim:
2006-10-02 Edgar E. Iglesias <edgar@axis.com>
Hans-Peter Nilsson <hp@axis.com>
* cris/cris-sim.h (enum cris_unknown_syscall_action_type)
(cris_unknown_syscall_action): Declare.
* cris/sim-if.c (cris_unknown_syscall_action): Define.
(cris_options): Add cris-unknown-syscall option.
(cris_option_handler): Correct comment about and error message for
invalid --cris-cycles argument. Handle --cris-unknown-syscall.
* cris/traps.c: Include stdarg.h
(cris_unknown_syscall): New function.
(cris_break_13_handler): Instead of sim_io_eprintf and
sim_engine_halt, call cris_unknown_syscall to handle more or less
unknown syscalls. Adjust code as necessary to handle return
value.
sim/testsuite:
2006-10-02 Hans-Peter Nilsson <hp@axis.com>
Edgar E. Iglesias <edgar@axis.com>
* sim/cris/c/clone5.c, sim/cris/c/mprotect1.c,
sim/cris/c/rtsigprocmask1.c, sim/cris/c/rtsigsuspend1.c,
sim/cris/c/sig7.c, sim/cris/c/sigreturn1.c,
sim/cris/c/sigreturn2.c, sim/cris/c/syscall1.c,
sim/cris/c/syscall2.c, sim/cris/c/sysctl2.c, sim/cris/c/fcntl1.c,
sim/cris/c/readlink2.c: Add code to print ENOSYS if syscall being
tested returns ENOSYS. Add early exit where needed. Change any
existing code to print "xyzzy", not "pass".
* sim/cris/asm/option3.ms, sim/cris/asm/option4.ms,
sim/cris/c/clone6.c, sim/cris/c/fcntl2.c,
sim/cris/c/mprotect2.c, sim/cris/c/readlink11.c,
sim/cris/c/rtsigprocmask2.c, sim/cris/c/rtsigsuspend2.c,
sim/cris/c/sig13.c, sim/cris/c/sigreturn3.c,
sim/cris/c/sigreturn4.c, sim/cris/c/syscall3.c,
sim/cris/c/syscall4.c, sim/cris/c/syscall5.c,
sim/cris/c/syscall6.c, sim/cris/c/syscall7.c,
sim/cris/c/syscall8.c, sim/cris/c/sysctl3.c: New tests.
Index: cris/cris-sim.h
===================================================================
RCS file: /cvs/src/src/sim/cris/cris-sim.h,v
retrieving revision 1.2
diff -p -u -u -p -r1.2 cris-sim.h
--- cris/cris-sim.h 3 Apr 2006 03:01:45 -0000 1.2
+++ cris/cris-sim.h 2 Oct 2006 02:49:32 -0000
@@ -87,6 +87,9 @@ extern USI crisv32f_break_handler (SIM_C
extern USI cris_break_13_handler (SIM_CPU *, USI, USI, USI, USI, USI, USI,
USI, USI);
extern char cris_have_900000xxif;
+enum cris_unknown_syscall_action_type
+ { CRIS_USYSC_MSG_STOP, CRIS_USYSC_MSG_ENOSYS, CRIS_USYSC_QUIET_ENOSYS };
+extern enum cris_unknown_syscall_action_type cris_unknown_syscall_action;
enum cris_interrupt_type { CRIS_INT_NMI, CRIS_INT_RESET, CRIS_INT_INT };
extern int crisv10deliver_interrupt (SIM_CPU *,
enum cris_interrupt_type,
Index: cris/sim-if.c
===================================================================
RCS file: /cvs/src/src/sim/cris/sim-if.c,v
retrieving revision 1.2
diff -p -u -u -p -r1.2 sim-if.c
--- cris/sim-if.c 3 Apr 2006 03:01:45 -0000 1.2
+++ cris/sim-if.c 2 Oct 2006 02:49:33 -0000
@@ -80,6 +80,10 @@ static char cris_bare_iron = 0;
/* Whether 0x9000000xx have simulator-specific meanings. */
char cris_have_900000xxif = 0;
+/* What to do when we face a more or less unknown syscall. */
+enum cris_unknown_syscall_action_type cris_unknown_syscall_action
+ = CRIS_USYSC_MSG_STOP;
+
/* Records simulator descriptor so utilities like cris_dump_regs can be
called from gdb. */
SIM_DESC current_state;
@@ -90,6 +94,7 @@ typedef enum {
OPTION_CRIS_TRACE,
OPTION_CRIS_NAKED,
OPTION_CRIS_900000XXIF,
+ OPTION_CRIS_UNKNOWN_SYSCALL
} CRIS_OPTIONS;
static const OPTION cris_options[] =
@@ -108,6 +113,10 @@ static const OPTION cris_options[] =
{ {"cris-900000xx", no_argument, NULL, OPTION_CRIS_900000XXIF},
'\0', NULL, "Define addresses at 0x900000xx with simulator semantics",
cris_option_handler, NULL },
+ { {"cris-unknown-syscall", required_argument, NULL,
+ OPTION_CRIS_UNKNOWN_SYSCALL},
+ '\0', "stop|enosys|enosys-quiet", "Action at an unknown system call",
+ cris_option_handler, NULL },
{ {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL, NULL }
};
@@ -152,9 +161,9 @@ cris_option_handler (SIM_DESC sd, sim_cp
*tracefp = FLAG_CRIS_MISC_PROFILE_ALL;
else
{
- /* We'll actually never get here; the caller handles the
- error case. */
- sim_io_eprintf (sd, "Unknown option `--cris-stats=%s'\n", arg);
+ /* Beware; the framework does not handle the error case;
+ we have to do it ourselves. */
+ sim_io_eprintf (sd, "Unknown option `--cris-cycles=%s'\n", arg);
return SIM_RC_FAIL;
}
break;
@@ -177,6 +186,21 @@ cris_option_handler (SIM_DESC sd, sim_cp
cris_have_900000xxif = 1;
break;
+ case OPTION_CRIS_UNKNOWN_SYSCALL:
+ if (strcmp (arg, "enosys") == 0)
+ cris_unknown_syscall_action = CRIS_USYSC_MSG_ENOSYS;
+ else if (strcmp (arg, "enosys-quiet") == 0)
+ cris_unknown_syscall_action = CRIS_USYSC_QUIET_ENOSYS;
+ else if (strcmp (arg, "stop") == 0)
+ cris_unknown_syscall_action = CRIS_USYSC_MSG_STOP;
+ else
+ {
+ sim_io_eprintf (sd, "Unknown option `--cris-unknown-syscall=%s'\n",
+ arg);
+ return SIM_RC_FAIL;
+ }
+ break;
+
default:
/* We'll actually never get here; the caller handles the error
case. */
Index: cris/traps.c
===================================================================
RCS file: /cvs/src/src/sim/cris/traps.c,v
retrieving revision 1.9
diff -p -u -u -p -r1.9 traps.c
--- cris/traps.c 30 Sep 2006 02:38:06 -0000 1.9
+++ cris/traps.c 2 Oct 2006 02:49:35 -0000
@@ -23,6 +23,7 @@ with this program; if not, write to the
#include "bfd.h"
/* FIXME: get rid of targ-vals.h usage everywhere else. */
+#include <stdarg.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
@@ -1349,6 +1350,31 @@ make_first_thread (SIM_CPU *current_cpu)
abort ();
}
+/* Handle unknown system calls. Returns (if it does) the syscall
+ return value. */
+
+static USI
+cris_unknown_syscall (SIM_CPU *current_cpu, USI pc, char *s, ...)
+{
+ SIM_DESC sd = CPU_STATE (current_cpu);
+ host_callback *cb = STATE_CALLBACK (sd);
+
+ if (cris_unknown_syscall_action == CRIS_USYSC_MSG_STOP
+ || cris_unknown_syscall_action == CRIS_USYSC_MSG_ENOSYS)
+ {
+ va_list ap;
+
+ va_start (ap, s);
+ sim_io_evprintf (sd, s, ap);
+ va_end (ap);
+
+ if (cris_unknown_syscall_action == CRIS_USYSC_MSG_STOP)
+ sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped, SIM_SIGILL);
+ }
+
+ return -cb_host_to_target_errno (cb, ENOSYS);
+}
+
/* Main function: the handler of the "break 13" syscall insn. */
USI
@@ -1467,16 +1493,17 @@ cris_break_13_handler (SIM_CPU *current_
}
/* FALLTHROUGH */
default:
- /* Abort for all other cases. */
- sim_io_eprintf (sd, "Unimplemented %s syscall "
- "(fd: 0x%lx: cmd: 0x%lx arg: 0x%lx)\n",
- callnum == TARGET_SYS_fcntl
- ? "fcntl" : "fcntl64",
- (unsigned long) (USI) arg1,
- (unsigned long) (USI) arg2,
- (unsigned long) (USI) arg3);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ /* Nothing else is implemented. */
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented %s syscall "
+ "(fd: 0x%lx: cmd: 0x%lx arg: "
+ "0x%lx)\n",
+ callnum == TARGET_SYS_fcntl
+ ? "fcntl" : "fcntl64",
+ (unsigned long) (USI) arg1,
+ (unsigned long) (USI) arg2,
+ (unsigned long) (USI) arg3);
break;
}
break;
@@ -1598,16 +1625,17 @@ cris_break_13_handler (SIM_CPU *current_
|| (fd != (USI) -1 && prot != TARGET_PROT_READ)
|| pgoff != 0)
{
- sim_io_eprintf (sd, "Unimplemented mmap2 call "
- "(0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
- (unsigned long) arg1,
- (unsigned long) arg2,
- (unsigned long) arg3,
- (unsigned long) arg4,
- (unsigned long) arg5,
- (unsigned long) arg6);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented mmap2 call "
+ "(0x%lx, 0x%lx, 0x%lx, "
+ "0x%lx, 0x%lx, 0x%lx)\n",
+ (unsigned long) arg1,
+ (unsigned long) arg2,
+ (unsigned long) arg3,
+ (unsigned long) arg4,
+ (unsigned long) arg5,
+ (unsigned long) arg6);
break;
}
else if (fd != (USI) -1)
@@ -1701,13 +1729,13 @@ cris_break_13_handler (SIM_CPU *current_
|| !is_mapped (sd, ¤t_cpu->highest_mmapped_page, addr,
len))
{
- sim_io_eprintf (sd, "Unimplemented mprotect call "
- "(0x%lx, 0x%lx, 0x%lx)\n",
- (unsigned long) arg1,
- (unsigned long) arg2,
- (unsigned long) arg3);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented mprotect call "
+ "(0x%lx, 0x%lx, 0x%lx)\n",
+ (unsigned long) arg1,
+ (unsigned long) arg2,
+ (unsigned long) arg3);
break;
}
@@ -1766,14 +1794,14 @@ cris_break_13_handler (SIM_CPU *current_
|| rusagep != 0
|| current_cpu->thread_data == NULL)
{
- sim_io_eprintf (sd, "Unimplemented wait4 call "
- "(0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
- (unsigned long) arg1,
- (unsigned long) arg2,
- (unsigned long) arg3,
- (unsigned long) arg4);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented wait4 call "
+ "(0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
+ (unsigned long) arg1,
+ (unsigned long) arg2,
+ (unsigned long) arg3,
+ (unsigned long) arg4);
break;
}
@@ -1879,19 +1907,22 @@ cris_break_13_handler (SIM_CPU *current_
&& target_sa_flags != (TARGET_SA_RESTART|TARGET_SA_SIGINFO))
|| target_sa_handler == 0)
{
- sim_io_eprintf (sd, "Unimplemented rt_sigaction "
- "syscall (0x%lx, "
- "0x%lx: [0x%x, 0x%x, 0x%x, "
- "{0x%x, 0x%x}], "
- "0x%lx)\n",
- (unsigned long) arg1,
- (unsigned long) arg2,
- target_sa_handler, target_sa_flags,
- target_sa_restorer,
- target_sa_mask_low, target_sa_mask_high,
- (unsigned long) arg3);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented rt_sigaction "
+ "syscall "
+ "(0x%lx, 0x%lx: "
+ "[0x%x, 0x%x, 0x%x, "
+ "{0x%x, 0x%x}], 0x%lx)\n",
+ (unsigned long) arg1,
+ (unsigned long) arg2,
+ target_sa_handler,
+ target_sa_flags,
+ target_sa_restorer,
+ target_sa_mask_low,
+ target_sa_mask_high,
+ (unsigned long) arg3);
+ break;
}
current_cpu->sighandler[signum] = target_sa_handler;
@@ -2012,11 +2043,14 @@ cris_break_13_handler (SIM_CPU *current_
|| (buf.st_mode & S_IFIFO) == 0)
|| current_cpu->thread_data == NULL)
{
- sim_io_eprintf (sd, "Unimplemented poll syscall "
- "(0x%lx: [0x%x, 0x%x, x], 0x%lx, 0x%lx)\n",
- (unsigned long) arg1, fd, events,
- (unsigned long) arg2, (unsigned long) arg3);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped, SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented poll syscall "
+ "(0x%lx: [0x%x, 0x%x, x], "
+ "0x%lx, 0x%lx)\n",
+ (unsigned long) arg1, fd, events,
+ (unsigned long) arg2,
+ (unsigned long) arg3);
break;
}
@@ -2108,12 +2142,13 @@ cris_break_13_handler (SIM_CPU *current_
if (!((offs_hi == 0 && offs_lo >= 0)
|| (offs_hi == -1 && offs_lo < 0)))
{
- sim_io_eprintf (sd,
- "Unimplemented llseek offset,"
- " fd %d: 0x%x:0x%x\n",
- fd, (unsigned) arg2, (unsigned) arg3);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented llseek offset,"
+ " fd %d: 0x%x:0x%x\n",
+ fd, (unsigned) arg2,
+ (unsigned) arg3);
+ break;
}
s.func = TARGET_SYS_lseek;
@@ -2191,11 +2226,11 @@ cris_break_13_handler (SIM_CPU *current_
&& how != TARGET_SIG_SETMASK
&& how != TARGET_SIG_UNBLOCK)
{
- sim_io_eprintf (sd, "Unimplemented rt_sigprocmask syscall "
- "(0x%x, 0x%x, 0x%x)\n", arg1, arg2, arg3);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
- retval = 0;
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented rt_sigprocmask "
+ "syscall (0x%x, 0x%x, 0x%x)\n",
+ arg1, arg2, arg3);
break;
}
@@ -2266,17 +2301,19 @@ cris_break_13_handler (SIM_CPU *current_
|| (current_cpu->thread_data[threadno].cpu_context_atsignal
== NULL))
{
- sim_io_eprintf (sd, "Invalid sigreturn syscall: no signal"
- " handler active "
- "(0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
- (unsigned long) arg1,
- (unsigned long) arg2,
- (unsigned long) arg3,
- (unsigned long) arg4,
- (unsigned long) arg5,
- (unsigned long) arg6);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Invalid sigreturn syscall: "
+ "no signal handler active "
+ "(0x%lx, 0x%lx, 0x%lx, 0x%lx, "
+ "0x%lx, 0x%lx)\n",
+ (unsigned long) arg1,
+ (unsigned long) arg2,
+ (unsigned long) arg3,
+ (unsigned long) arg4,
+ (unsigned long) arg5,
+ (unsigned long) arg6);
+ break;
}
was_sigsuspended
@@ -2342,11 +2379,13 @@ cris_break_13_handler (SIM_CPU *current_
if (setsize != 8)
{
- sim_io_eprintf (sd, "Unimplemented rt_sigsuspend syscall"
- " arguments (0x%lx, 0x%lx)\n",
- (unsigned long) arg1, (unsigned long) arg2);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented rt_sigsuspend syscall"
+ " arguments (0x%lx, 0x%lx)\n",
+ (unsigned long) arg1,
+ (unsigned long) arg2);
+ break;
}
/* Don't change the signal mask if we're already in
@@ -2496,12 +2535,12 @@ cris_break_13_handler (SIM_CPU *current_
if (argv0 == NULL || *argv0 == '.')
{
- sim_io_eprintf (sd, "Unimplemented readlink syscall "
- "(0x%lx: [\"%s\"], 0x%lx)\n",
- (unsigned long) arg1, pbuf,
- (unsigned long) arg2);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented readlink syscall "
+ "(0x%lx: [\"%s\"], 0x%lx)\n",
+ (unsigned long) arg1, pbuf,
+ (unsigned long) arg2);
break;
}
else if (*argv0 == '/')
@@ -2734,19 +2773,19 @@ cris_break_13_handler (SIM_CPU *current_
break;
}
- sim_io_eprintf (sd, "Unimplemented _sysctl syscall "
- "(0x%lx: [0x%lx, 0x%lx],"
- " 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
- (unsigned long) name,
- (unsigned long) name0,
- (unsigned long) name1,
- (unsigned long) nlen,
- (unsigned long) oldval,
- (unsigned long) oldlenp,
- (unsigned long) newval,
- (unsigned long) newlen);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented _sysctl syscall "
+ "(0x%lx: [0x%lx, 0x%lx],"
+ " 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx)\n",
+ (unsigned long) name,
+ (unsigned long) name0,
+ (unsigned long) name1,
+ (unsigned long) nlen,
+ (unsigned long) oldval,
+ (unsigned long) oldlenp,
+ (unsigned long) newval,
+ (unsigned long) newlen);
break;
}
@@ -2819,11 +2858,13 @@ cris_break_13_handler (SIM_CPU *current_
| TARGET_CLONE_SIGHAND)
|| newsp == 0)
{
- sim_io_eprintf (sd,
- "Unimplemented clone syscall (0x%lx, 0x%lx)\n",
- (unsigned long) arg1, (unsigned long) arg2);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented clone syscall "
+ "(0x%lx, 0x%lx)\n",
+ (unsigned long) arg1,
+ (unsigned long) arg2);
+ break;
}
if (current_cpu->thread_data == NULL)
@@ -2886,11 +2927,12 @@ cris_break_13_handler (SIM_CPU *current_
unimplemented_syscall:
default:
- sim_io_eprintf (sd, "Unimplemented syscall: %d "
- "(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\n", callnum,
- arg1, arg2, arg3, arg4, arg5, arg6);
- sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped,
- SIM_SIGILL);
+ retval
+ = cris_unknown_syscall (current_cpu, pc,
+ "Unimplemented syscall: %d "
+ "(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\n",
+ callnum, arg1, arg2, arg3, arg4, arg5,
+ arg6);
}
}
@@ -2900,6 +2942,7 @@ cris_break_13_handler (SIM_CPU *current_
current_cpu->last_open_fd = retval;
current_cpu->last_open_flags = arg2;
}
+
current_cpu->last_syscall = callnum;
/* A system call is a rescheduling point. For the time being, we don't
Index: sim/cris/c/clone5.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/clone5.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 clone5.c
--- sim/cris/c/clone5.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/clone5.c 2 Oct 2006 01:39:33 -0000
@@ -11,6 +11,7 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <errno.h>
int pip[2];
@@ -26,7 +27,9 @@ main (void)
int retcode;
long stack[16384];
- clone (process, (char *) stack + sizeof (stack) - 64, 0, "cba");
+ retcode = clone (process, (char *) stack + sizeof (stack) - 64, 0, "cba");
+ if (retcode == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
printf ("xyzzy\n");
return 0;
}
Index: sim/cris/c/fcntl1.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/fcntl1.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 fcntl1.c
--- sim/cris/c/fcntl1.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/fcntl1.c 2 Oct 2006 01:39:33 -0000
@@ -7,10 +7,13 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
int main (void)
{
- fcntl (1, 42);
- printf ("pass\n");
+ int err = fcntl (1, 42);
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
+ printf ("xyzzy\n");
exit (0);
}
Index: sim/cris/c/mprotect1.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/mprotect1.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 mprotect1.c
--- sim/cris/c/mprotect1.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/mprotect1.c 2 Oct 2006 01:39:33 -0000
@@ -7,10 +7,13 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>
+#include <errno.h>
int main (int argc, char *argv[])
{
- mprotect (0, 8193, PROT_EXEC);
+ int err = mprotect (0, 8193, PROT_EXEC);
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
printf ("xyzzy\n");
exit (0);
}
Index: sim/cris/c/readlink2.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/readlink2.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 readlink2.c
--- sim/cris/c/readlink2.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/readlink2.c 2 Oct 2006 01:39:33 -0000
@@ -12,11 +12,18 @@ int main (int argc, char *argv[])
{
char buf[1024];
char buf2[1024];
+ int err;
/* This is a special feature handled in the simulator. The "42"
should be formed from getpid () if this was a real program. */
- if (readlink ("/proc/42/exe", buf, sizeof (buf)) < 0)
- abort ();
+ err = readlink ("/proc/42/exe", buf, sizeof (buf));
+ if (err < 0)
+ {
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
+ printf ("xyzzy\n");
+ exit (0);
+ }
/* Don't use an abort in the following; it might cause the printf to
not make it all the way to output and make debugging more
Index: sim/cris/c/rtsigprocmask1.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/rtsigprocmask1.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 rtsigprocmask1.c
--- sim/cris/c/rtsigprocmask1.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/rtsigprocmask1.c 2 Oct 2006 01:39:33 -0000
@@ -13,6 +13,7 @@
#include <unistd.h>
#include <signal.h>
#include <pthread.h>
+#include <errno.h>
static void *
process (void *arg)
@@ -38,8 +39,13 @@ main (void)
abort ();
/* An invalid parameter 1 should cause this to halt the simulator. */
- pthread_sigmask (SIG_BLOCK + SIG_UNBLOCK + SIG_SETMASK,
- NULL, &sigs);
+ retcode
+ = pthread_sigmask (SIG_BLOCK + SIG_UNBLOCK + SIG_SETMASK, NULL, &sigs);
+ /* Direct return of the error number; i.e. not using -1 and errno,
+ is the actual documented behavior. */
+ if (retcode == ENOSYS)
+ printf ("ENOSYS\n");
+
printf ("xyzzy\n");
return 0;
}
Index: sim/cris/c/rtsigsuspend1.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/rtsigsuspend1.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 rtsigsuspend1.c
--- sim/cris/c/rtsigsuspend1.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/rtsigsuspend1.c 2 Oct 2006 01:39:33 -0000
@@ -9,10 +9,13 @@
#include <sys/syscall.h>
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
int main (void)
{
- syscall (SYS_rt_sigsuspend, 1, 2);
+ int err = syscall (SYS_rt_sigsuspend, 1, 2);
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
printf ("xyzzy\n");
exit (0);
}
Index: sim/cris/c/sig7.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/sig7.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 sig7.c
--- sim/cris/c/sig7.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/sig7.c 2 Oct 2006 01:39:33 -0000
@@ -7,17 +7,20 @@
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
+#include <errno.h>
int
main (void)
{
struct sigaction sa;
+ int err;
sa.sa_sigaction = NULL;
sa.sa_flags = SA_RESTART | SA_SIGINFO;
sigemptyset (&sa.sa_mask);
- if (sigaction (SIGFPE, &sa, NULL) != 0)
- abort ();
+ err = sigaction (SIGFPE, &sa, NULL);
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
printf ("xyzzy\n");
exit (0);
Index: sim/cris/c/sigreturn1.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/sigreturn1.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 sigreturn1.c
--- sim/cris/c/sigreturn1.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/sigreturn1.c 2 Oct 2006 01:39:33 -0000
@@ -9,10 +9,13 @@
#include <sys/syscall.h>
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
int main (void)
{
- syscall (SYS_sigreturn, 1, 2, 3, 4, 5, 6);
+ int err = syscall (SYS_sigreturn, 1, 2, 3, 4, 5, 6);
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
printf ("xyzzy\n");
exit (0);
}
Index: sim/cris/c/sigreturn2.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/sigreturn2.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 sigreturn2.c
--- sim/cris/c/sigreturn2.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/sigreturn2.c 2 Oct 2006 01:39:33 -0000
@@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <signal.h>
+#include <errno.h>
static void *
process (void *arg)
@@ -27,7 +28,11 @@ int main (void)
{
pthread_t th_a;
if (pthread_create (&th_a, NULL, process, (void *) "a") == 0)
- syscall (SYS_sigreturn, 1, 2, 3, 4, 5, 6);
+ {
+ int err = syscall (SYS_sigreturn, 1, 2, 3, 4, 5, 6);
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
+ }
printf ("xyzzy\n");
exit (0);
}
Index: sim/cris/c/syscall1.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/syscall1.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 syscall1.c
--- sim/cris/c/syscall1.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/syscall1.c 2 Oct 2006 01:39:33 -0000
@@ -8,12 +8,15 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
int main (void)
{
/* The number 166 is chosen because there's a gap for that number in
the CRIS asm/unistd.h. */
- syscall (166, 1, 2, 3, 4, 5, 6);
+ int err = syscall (166, 1, 2, 3, 4, 5, 6);
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
printf ("xyzzy\n");
exit (0);
}
Index: sim/cris/c/syscall2.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/syscall2.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 syscall2.c
--- sim/cris/c/syscall2.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/syscall2.c 2 Oct 2006 01:39:33 -0000
@@ -8,11 +8,16 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
int main (void)
{
+ int err;
+
/* Check special case of number 0 syscall. */
- syscall (0, 3, 2, 1, 4, 6, 5);
+ err = syscall (0, 3, 2, 1, 4, 6, 5);
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
printf ("xyzzy\n");
exit (0);
}
Index: sim/cris/c/sysctl2.c
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/cris/c/sysctl2.c,v
retrieving revision 1.1
diff -p -u -u -p -r1.1 sysctl2.c
--- sim/cris/c/sysctl2.c 21 Nov 2005 04:48:19 -0000 1.1
+++ sim/cris/c/sysctl2.c 2 Oct 2006 01:39:33 -0000
@@ -10,6 +10,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
int main (void)
{
@@ -32,7 +33,9 @@ int main (void)
(void *) -1, &x, NULL, 0
};
- syscall (SYS__sysctl, &scargs);
+ int err = syscall (SYS__sysctl, &scargs);
+ if (err == -1 && errno == ENOSYS)
+ printf ("ENOSYS\n");
printf ("xyzzy\n");
exit (0);
}
Index: testsuite/sim/cris/asm/option3.ms
===================================================================
RCS file: testsuite/sim/cris/asm/option3.ms
diff -N testsuite/sim/cris/asm/option3.ms
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/sim/cris/asm/option3.ms 2 Oct 2006 02:34:40 -0000
@@ -0,0 +1,7 @@
+#mach: crisv0 crisv3 crisv8 crisv10 crisv32
+#sim: --cris-cycles=foo
+#xerror:
+#output: Unknown option `--cris-cycles=foo'\n
+ .include "testutils.inc"
+ start
+ fail
Index: testsuite/sim/cris/asm/option4.ms
===================================================================
RCS file: testsuite/sim/cris/asm/option4.ms
diff -N testsuite/sim/cris/asm/option4.ms
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/sim/cris/asm/option4.ms 2 Oct 2006 02:34:40 -0000
@@ -0,0 +1,7 @@
+#mach: crisv0 crisv3 crisv8 crisv10 crisv32
+#sim: --cris-unknown-syscall=foo
+#xerror:
+#output: Unknown option `--cris-unknown-syscall=foo'\n
+ .include "testutils.inc"
+ start
+ fail
Index: sim/cris/c/clone6.c
===================================================================
RCS file: sim/cris/c/clone6.c
diff -N sim/cris/c/clone6.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/clone6.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,8 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "clone5.c"
Index: sim/cris/c/fcntl2.c
===================================================================
RCS file: sim/cris/c/fcntl2.c
diff -N sim/cris/c/fcntl2.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/fcntl2.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,8 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "fcntl1.c"
Index: sim/cris/c/mprotect2.c
===================================================================
RCS file: sim/cris/c/mprotect2.c
diff -N sim/cris/c/mprotect2.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/mprotect2.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,8 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "mprotect1.c"
Index: sim/cris/c/readlink11.c
===================================================================
RCS file: sim/cris/c/readlink11.c
diff -N sim/cris/c/readlink11.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/readlink11.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,9 @@
+/* As readlink5.c (sic), but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#dest: ./readlink11.c.x
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "readlink2.c"
Index: sim/cris/c/rtsigprocmask2.c
===================================================================
RCS file: sim/cris/c/rtsigprocmask2.c
diff -N sim/cris/c/rtsigprocmask2.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/rtsigprocmask2.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,9 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#cc: additional_flags=-pthread
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "rtsigprocmask1.c"
Index: sim/cris/c/rtsigsuspend2.c
===================================================================
RCS file: sim/cris/c/rtsigsuspend2.c
diff -N sim/cris/c/rtsigsuspend2.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/rtsigsuspend2.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,8 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "rtsigsuspend1.c"
Index: sim/cris/c/sig13.c
===================================================================
RCS file: sim/cris/c/sig13.c
diff -N sim/cris/c/sig13.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/sig13.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,8 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "sig7.c"
Index: sim/cris/c/sigreturn3.c
===================================================================
RCS file: sim/cris/c/sigreturn3.c
diff -N sim/cris/c/sigreturn3.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/sigreturn3.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,8 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "sigreturn1.c"
Index: sim/cris/c/sigreturn4.c
===================================================================
RCS file: sim/cris/c/sigreturn4.c
diff -N sim/cris/c/sigreturn4.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/sigreturn4.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,9 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#cc: additional_flags=-pthread
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "sigreturn2.c"
Index: sim/cris/c/syscall3.c
===================================================================
RCS file: sim/cris/c/syscall3.c
diff -N sim/cris/c/syscall3.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/syscall3.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,9 @@
+/* As the included file, just actually specifying the default.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=stop
+#xerror:
+#output: Unimplemented syscall: 166 (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n
+#output: program stopped with signal 4.\n
+*/
+
+#include "syscall1.c"
Index: sim/cris/c/syscall4.c
===================================================================
RCS file: sim/cris/c/syscall4.c
diff -N sim/cris/c/syscall4.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/syscall4.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,9 @@
+/* As the included file, just actually specifying the default.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=stop
+#xerror:
+#output: Unimplemented syscall: 0 (0x3, 0x2, 0x1, 0x4, 0x6, 0x5)\n
+#output: program stopped with signal 4.\n
+*/
+
+#include "syscall2.c"
Index: sim/cris/c/syscall5.c
===================================================================
RCS file: sim/cris/c/syscall5.c
diff -N sim/cris/c/syscall5.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/syscall5.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,9 @@
+/* As the included file, but specifying ENOSYS with message.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys
+#output: Unimplemented syscall: 166 (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "syscall1.c"
Index: sim/cris/c/syscall6.c
===================================================================
RCS file: sim/cris/c/syscall6.c
diff -N sim/cris/c/syscall6.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/syscall6.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,9 @@
+/* As the included file, but specifying ENOSYS with message.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys
+#output: Unimplemented syscall: 0 (0x3, 0x2, 0x1, 0x4, 0x6, 0x5)\n
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "syscall2.c"
Index: sim/cris/c/syscall7.c
===================================================================
RCS file: sim/cris/c/syscall7.c
diff -N sim/cris/c/syscall7.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/syscall7.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,8 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "syscall1.c"
Index: sim/cris/c/syscall8.c
===================================================================
RCS file: sim/cris/c/syscall8.c
diff -N sim/cris/c/syscall8.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/syscall8.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,8 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "syscall2.c"
Index: sim/cris/c/sysctl3.c
===================================================================
RCS file: sim/cris/c/sysctl3.c
diff -N sim/cris/c/sysctl3.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/sysctl3.c 2 Oct 2006 01:39:33 -0000
@@ -0,0 +1,8 @@
+/* As the included file, but specifying silent ENOSYS.
+#notarget: cris*-*-elf
+#sim: --cris-unknown-syscall=enosys-quiet
+#output: ENOSYS\n
+#output: xyzzy\n
+*/
+
+#include "sysctl2.c"
brgds, H-P