67 |
int main(int argc, char **argv) |
int main(int argc, char **argv) |
68 |
{ |
{ |
69 |
struct sigaction act; |
struct sigaction act; |
70 |
int val; |
volatile int val; |
71 |
|
|
72 |
act.sa_sigaction = sig_handler; |
act.sa_sigaction = sig_handler; |
73 |
sigemptyset(&act.sa_mask); |
sigemptyset(&act.sa_mask); |
75 |
sigaction(SIGFPE, &act, NULL); |
sigaction(SIGFPE, &act, NULL); |
76 |
sigaction(SIGILL, &act, NULL); |
sigaction(SIGILL, &act, NULL); |
77 |
sigaction(SIGSEGV, &act, NULL); |
sigaction(SIGSEGV, &act, NULL); |
78 |
|
sigaction(SIGTRAP, &act, NULL); |
79 |
|
|
80 |
/* test division by zero reporting */ |
/* test division by zero reporting */ |
81 |
if (setjmp(jmp_env) == 0) { |
if (setjmp(jmp_env) == 0) { |
113 |
asm volatile ("int $0xfd"); |
asm volatile ("int $0xfd"); |
114 |
} |
} |
115 |
|
|
116 |
|
printf("INT3 exception:\n"); |
117 |
|
if (setjmp(jmp_env) == 0) { |
118 |
|
asm volatile ("int3"); |
119 |
|
} |
120 |
|
|
121 |
printf("CLI exception:\n"); |
printf("CLI exception:\n"); |
122 |
if (setjmp(jmp_env) == 0) { |
if (setjmp(jmp_env) == 0) { |
123 |
asm volatile ("cli"); |
asm volatile ("cli"); |
164 |
|
|
165 |
printf("HLT exception:\n"); |
printf("HLT exception:\n"); |
166 |
if (setjmp(jmp_env) == 0) { |
if (setjmp(jmp_env) == 0) { |
167 |
asm volatile ("hlt" : : "d" (0x4321), "D" (tab), "c" (1)); |
asm volatile ("hlt"); |
168 |
} |
} |
169 |
|
|
170 |
#if 0 |
printf("single step exception:\n"); |
171 |
|
val = 0; |
172 |
|
if (setjmp(jmp_env) == 0) { |
173 |
|
asm volatile ("pushf\n" |
174 |
|
"orl $0x00100, (%%esp)\n" |
175 |
|
"popf\n" |
176 |
|
"movl $0xabcd, %0\n" : "=m" (val) : : "cc", "memory"); |
177 |
|
} |
178 |
|
printf("val=0x%x\n", val); |
179 |
|
|
180 |
|
#if 1 |
181 |
{ |
{ |
182 |
int i; |
int i; |
183 |
act.sa_handler = alarm_handler; |
act.sa_handler = alarm_handler; |