2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
12 #include <sys/ioctl.h>
13 #include <sys/ptrace.h>
16 #include <asm/unistd.h>
17 #include <asm/ptrace.h>
19 #include "sysdep/ptrace.h"
20 #include "sigcontext.h"
21 #include "sysdep/sigcontext.h"
23 #include "frame_user.h"
24 #include "signal_user.h"
25 #include "time_user.h"
28 #include "choose-mode.h"
29 #include "kern_util.h"
30 #include "user_util.h"
33 void kill_child_dead(int pid)
37 while(waitpid(pid, NULL, 0) > 0) kill(pid, SIGCONT);
40 /* Unlocked - don't care if this is a bit off */
44 unsigned long address;
49 } segfault_record[1024];
51 void segv_handler(int sig, union uml_pt_regs *regs)
55 if(UPT_IS_USER(regs) && !UPT_SEGV_IS_FIXABLE(regs)){
56 bad_segv(UPT_FAULT_ADDR(regs), UPT_IP(regs),
57 UPT_FAULT_WRITE(regs));
60 max = sizeof(segfault_record)/sizeof(segfault_record[0]);
61 index = next_trap_index(max);
64 segfault_record[index].address = UPT_FAULT_ADDR(regs);
65 segfault_record[index].pid = os_getpid();
66 segfault_record[index].is_write = UPT_FAULT_WRITE(regs);
67 segfault_record[index].sp = UPT_SP(regs);
68 segfault_record[index].is_user = UPT_IS_USER(regs);
69 segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), UPT_FAULT_WRITE(regs),
70 UPT_IS_USER(regs), regs);
73 void usr2_handler(int sig, union uml_pt_regs *regs)
75 CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
78 struct signal_info sig_info[] = {
79 [ SIGTRAP ] { .handler = relay_signal,
81 [ SIGFPE ] { .handler = relay_signal,
83 [ SIGILL ] { .handler = relay_signal,
85 [ SIGBUS ] { .handler = bus_handler,
87 [ SIGSEGV] { .handler = segv_handler,
89 [ SIGIO ] { .handler = sigio_handler,
91 [ SIGVTALRM ] { .handler = timer_handler,
93 [ SIGALRM ] { .handler = timer_handler,
95 [ SIGUSR2 ] { .handler = usr2_handler,
99 void sig_handler(int sig, struct sigcontext sc)
101 CHOOSE_MODE_PROC(sig_handler_common_tt, sig_handler_common_skas,
105 extern int timer_irq_inited, missed_ticks[];
107 void alarm_handler(int sig, struct sigcontext sc)
109 if(!timer_irq_inited) return;
110 missed_ticks[cpu()]++;
115 CHOOSE_MODE_PROC(sig_handler_common_tt, sig_handler_common_skas,
122 void do_longjmp(void *b, int val)
130 * Overrides for Emacs so that we follow Linus's tabbing style.
131 * Emacs will notice this stuff at the end of the file and automatically
132 * adjust the settings for this buffer only. This must remain at the end
134 * ---------------------------------------------------------------------------
136 * c-file-style: "linux"