2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
11 #include <sys/ptrace.h>
14 #include <asm/unistd.h>
15 #include <asm/ptrace.h>
17 #include "sysdep/ptrace.h"
18 #include "sigcontext.h"
19 #include "sysdep/sigcontext.h"
21 #include "frame_user.h"
22 #include "signal_user.h"
23 #include "time_user.h"
26 #include "choose-mode.h"
27 #include "kern_util.h"
28 #include "user_util.h"
31 void kill_child_dead(int pid)
37 CATCH_EINTR(n = waitpid(pid, NULL, 0));
45 /* Unlocked - don't care if this is a bit off */
49 unsigned long address;
54 } segfault_record[1024];
56 void segv_handler(int sig, union uml_pt_regs *regs)
60 if(UPT_IS_USER(regs) && !UPT_SEGV_IS_FIXABLE(regs)){
61 bad_segv(UPT_FAULT_ADDR(regs), UPT_IP(regs),
62 UPT_FAULT_WRITE(regs));
65 max = sizeof(segfault_record)/sizeof(segfault_record[0]);
66 index = next_trap_index(max);
69 segfault_record[index].address = UPT_FAULT_ADDR(regs);
70 segfault_record[index].pid = os_getpid();
71 segfault_record[index].is_write = UPT_FAULT_WRITE(regs);
72 segfault_record[index].sp = UPT_SP(regs);
73 segfault_record[index].is_user = UPT_IS_USER(regs);
74 segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), UPT_FAULT_WRITE(regs),
75 UPT_IS_USER(regs), regs);
78 void usr2_handler(int sig, union uml_pt_regs *regs)
80 CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
83 struct signal_info sig_info[] = {
84 [ SIGTRAP ] { .handler = relay_signal,
86 [ SIGFPE ] { .handler = relay_signal,
88 [ SIGILL ] { .handler = relay_signal,
90 [ SIGWINCH ] { .handler = winch,
92 [ SIGBUS ] { .handler = bus_handler,
94 [ SIGSEGV] { .handler = segv_handler,
96 [ SIGIO ] { .handler = sigio_handler,
98 [ SIGVTALRM ] { .handler = timer_handler,
100 [ SIGALRM ] { .handler = timer_handler,
102 [ SIGUSR2 ] { .handler = usr2_handler,
106 void sig_handler(int sig, struct sigcontext sc)
108 CHOOSE_MODE_PROC(sig_handler_common_tt, sig_handler_common_skas,
112 extern int timer_irq_inited;
114 void alarm_handler(int sig, struct sigcontext sc)
116 if(!timer_irq_inited) return;
121 CHOOSE_MODE_PROC(sig_handler_common_tt, sig_handler_common_skas,
128 void do_longjmp(void *b, int val)
132 siglongjmp(*buf, val);
136 * Overrides for Emacs so that we follow Linus's tabbing style.
137 * Emacs will notice this stuff at the end of the file and automatically
138 * adjust the settings for this buffer only. This must remain at the end
140 * ---------------------------------------------------------------------------
142 * c-file-style: "linux"