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)
35 while(waitpid(pid, NULL, 0) > 0) kill(pid, SIGCONT);
38 /* Unlocked - don't care if this is a bit off */
42 unsigned long address;
47 } segfault_record[1024];
49 void segv_handler(int sig, union uml_pt_regs *regs)
53 if(UPT_IS_USER(regs) && !UPT_SEGV_IS_FIXABLE(regs)){
54 bad_segv(UPT_FAULT_ADDR(regs), UPT_IP(regs),
55 UPT_FAULT_WRITE(regs));
58 max = sizeof(segfault_record)/sizeof(segfault_record[0]);
59 index = next_trap_index(max);
62 segfault_record[index].address = UPT_FAULT_ADDR(regs);
63 segfault_record[index].pid = os_getpid();
64 segfault_record[index].is_write = UPT_FAULT_WRITE(regs);
65 segfault_record[index].sp = UPT_SP(regs);
66 segfault_record[index].is_user = UPT_IS_USER(regs);
67 segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), UPT_FAULT_WRITE(regs),
68 UPT_IS_USER(regs), regs);
71 void usr2_handler(int sig, union uml_pt_regs *regs)
73 CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
76 struct signal_info sig_info[] = {
77 [ SIGTRAP ] { .handler = relay_signal,
79 [ SIGFPE ] { .handler = relay_signal,
81 [ SIGILL ] { .handler = relay_signal,
83 [ SIGWINCH ] { .handler = winch,
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;
107 void alarm_handler(int sig, struct sigcontext sc)
109 if(!timer_irq_inited) return;
114 CHOOSE_MODE_PROC(sig_handler_common_tt, sig_handler_common_skas,
121 void do_longjmp(void *b, int val)
125 siglongjmp(*buf, val);
129 * Overrides for Emacs so that we follow Linus's tabbing style.
130 * Emacs will notice this stuff at the end of the file and automatically
131 * adjust the settings for this buffer only. This must remain at the end
133 * ---------------------------------------------------------------------------
135 * c-file-style: "linux"