Commit 2a29ca73c9101ae46e85077178d3fcd1b38cfa0c
1 parent
54936004
more exception tests
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@159 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
19 additions
and
3 deletions
tests/testsig.c
| @@ -67,7 +67,7 @@ int tab[2]; | @@ -67,7 +67,7 @@ int tab[2]; | ||
| 67 | int main(int argc, char **argv) | 67 | int main(int argc, char **argv) |
| 68 | { | 68 | { |
| 69 | struct sigaction act; | 69 | struct sigaction act; |
| 70 | - int val; | 70 | + volatile int val; |
| 71 | 71 | ||
| 72 | act.sa_sigaction = sig_handler; | 72 | act.sa_sigaction = sig_handler; |
| 73 | sigemptyset(&act.sa_mask); | 73 | sigemptyset(&act.sa_mask); |
| @@ -75,6 +75,7 @@ int main(int argc, char **argv) | @@ -75,6 +75,7 @@ int main(int argc, char **argv) | ||
| 75 | sigaction(SIGFPE, &act, NULL); | 75 | sigaction(SIGFPE, &act, NULL); |
| 76 | sigaction(SIGILL, &act, NULL); | 76 | sigaction(SIGILL, &act, NULL); |
| 77 | sigaction(SIGSEGV, &act, NULL); | 77 | sigaction(SIGSEGV, &act, NULL); |
| 78 | + sigaction(SIGTRAP, &act, NULL); | ||
| 78 | 79 | ||
| 79 | /* test division by zero reporting */ | 80 | /* test division by zero reporting */ |
| 80 | if (setjmp(jmp_env) == 0) { | 81 | if (setjmp(jmp_env) == 0) { |
| @@ -112,6 +113,11 @@ int main(int argc, char **argv) | @@ -112,6 +113,11 @@ int main(int argc, char **argv) | ||
| 112 | asm volatile ("int $0xfd"); | 113 | asm volatile ("int $0xfd"); |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 116 | + printf("INT3 exception:\n"); | ||
| 117 | + if (setjmp(jmp_env) == 0) { | ||
| 118 | + asm volatile ("int3"); | ||
| 119 | + } | ||
| 120 | + | ||
| 115 | printf("CLI exception:\n"); | 121 | printf("CLI exception:\n"); |
| 116 | if (setjmp(jmp_env) == 0) { | 122 | if (setjmp(jmp_env) == 0) { |
| 117 | asm volatile ("cli"); | 123 | asm volatile ("cli"); |
| @@ -158,10 +164,20 @@ int main(int argc, char **argv) | @@ -158,10 +164,20 @@ int main(int argc, char **argv) | ||
| 158 | 164 | ||
| 159 | printf("HLT exception:\n"); | 165 | printf("HLT exception:\n"); |
| 160 | if (setjmp(jmp_env) == 0) { | 166 | if (setjmp(jmp_env) == 0) { |
| 161 | - asm volatile ("hlt" : : "d" (0x4321), "D" (tab), "c" (1)); | 167 | + asm volatile ("hlt"); |
| 162 | } | 168 | } |
| 163 | 169 | ||
| 164 | -#if 0 | 170 | + 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 | ||
| 165 | { | 181 | { |
| 166 | int i; | 182 | int i; |
| 167 | act.sa_handler = alarm_handler; | 183 | act.sa_handler = alarm_handler; |