Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/regress/lib/libc/siginfo simple tests to verify new signal t...
details: https://anonhg.NetBSD.org/src/rev/32b6d1cc45e2
branches: trunk
changeset: 551455:32b6d1cc45e2
user: christos <christos%NetBSD.org@localhost>
date: Sat Sep 06 22:27:22 2003 +0000
description:
simple tests to verify new signal trampoline works.
diffstat:
regress/lib/libc/siginfo/sigalrm/sigalrm.c | 48 ++++++++++++++++++++++++++++++
regress/lib/libc/siginfo/sigsegv/sigsegv.c | 45 ++++++++++++++++++++++++++++
2 files changed, 93 insertions(+), 0 deletions(-)
diffs (101 lines):
diff -r 2e8e97179552 -r 32b6d1cc45e2 regress/lib/libc/siginfo/sigalrm/sigalrm.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/siginfo/sigalrm/sigalrm.c Sat Sep 06 22:27:22 2003 +0000
@@ -0,0 +1,48 @@
+#include <signal.h>
+#include <stdio.h>
+#include <sys/ucontext.h>
+
+void
+sigalrm(int signo, siginfo_t *info, void *ptr)
+{
+ printf("%d %p %p\n", signo, info, ptr);
+ if (info != NULL) {
+ printf("si_signo=%d\n", info->si_signo);
+ printf("si_errno=%d\n", info->si_errno);
+ printf("si_code=%d\n", info->si_code);
+ printf("si_trap=%d\n", info->si_trap);
+ printf("si_addr=%p\n", info->si_addr);
+ }
+ if (ptr != NULL) {
+ ucontext_t *ctx = ptr;
+ int i;
+ mcontext_t *mc = &ctx->uc_mcontext;
+ printf("uc_flags 0x%x\n", ctx->uc_flags);
+ printf("uc_link %p\n", ctx->uc_link);
+ for (i = 0; i < sizeof(ctx->uc_sigmask.__bits) /
+ sizeof(ctx->uc_sigmask.__bits[0]); i++)
+ printf("uc_sigmask[%d] 0x%x\n", i,
+ ctx->uc_sigmask.__bits[i]);
+ printf("uc_stack %p %lu 0x%x\n", ctx->uc_stack.ss_sp,
+ (unsigned long)ctx->uc_stack.ss_size,
+ ctx->uc_stack.ss_flags);
+ for (i = 0; i < sizeof(mc->__gregs)/sizeof(mc->__gregs[0]); i++)
+ printf("uc_mcontext.greg[%d] 0x%x\n", i,
+ mc->__gregs[i]);
+ }
+}
+
+int
+main(void)
+{
+ struct sigaction sa;
+ sa.sa_flags = SA_SIGINFO;
+ sa.sa_sigaction = sigalrm;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGALRM, &sa, NULL);
+ for (;;) {
+ alarm(1);
+ sleep(1);
+ }
+ return 0;
+}
diff -r 2e8e97179552 -r 32b6d1cc45e2 regress/lib/libc/siginfo/sigsegv/sigsegv.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/siginfo/sigsegv/sigsegv.c Sat Sep 06 22:27:22 2003 +0000
@@ -0,0 +1,45 @@
+#include <signal.h>
+#include <stdio.h>
+#include <sys/ucontext.h>
+
+void
+sigsegv(int signo, siginfo_t *info, void *ptr)
+{
+ printf("%d %p %p\n", signo, info, ptr);
+ if (info != NULL) {
+ printf("si_signo=%d\n", info->si_signo);
+ printf("si_errno=%d\n", info->si_errno);
+ printf("si_code=%d\n", info->si_code);
+ printf("si_trap=%d\n", info->si_trap);
+ printf("si_addr=%p\n", info->si_addr);
+ }
+ if (ptr != NULL) {
+ ucontext_t *ctx = ptr;
+ int i;
+ mcontext_t *mc = &ctx->uc_mcontext;
+ printf("uc_flags 0x%x\n", ctx->uc_flags);
+ printf("uc_link %p\n", ctx->uc_link);
+ for (i = 0; i < sizeof(ctx->uc_sigmask.__bits) /
+ sizeof(ctx->uc_sigmask.__bits[0]); i++)
+ printf("uc_sigmask[%d] 0x%x\n", i,
+ ctx->uc_sigmask.__bits[i]);
+ printf("uc_stack %p %lu 0x%x\n", ctx->uc_stack.ss_sp,
+ (unsigned long)ctx->uc_stack.ss_size,
+ ctx->uc_stack.ss_flags);
+ for (i = 0; i < sizeof(mc->__gregs)/sizeof(mc->__gregs[0]); i++)
+ printf("uc_mcontext.greg[%d] 0x%x\n", i,
+ mc->__gregs[i]);
+ }
+}
+
+int
+main(void)
+{
+ struct sigaction sa;
+ sa.sa_flags = SA_SIGINFO;
+ sa.sa_sigaction = sigsegv;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGSEGV, &sa, NULL);
+ *(long *)0x5a5a5a5a = 0;
+ return 0;
+}
Home |
Main Index |
Thread Index |
Old Index