... |
... |
@@ -23,7 +23,12 @@ |
23
|
23
|
|
24
|
24
|
#define BREAKPOINT_INST 0xcc /* INT3 */
|
25
|
25
|
|
26
|
|
-unsigned long fast_random_state = 1;
|
|
26
|
+/*
|
|
27
|
+ * The first two bytes of the UD1 instruction. The mod r/m byte isn't
|
|
28
|
+ * included here.
|
|
29
|
+ */
|
|
30
|
+static const unsigned char ud1[] = {0x0f, 0xb9};
|
|
31
|
+
|
27
|
32
|
|
28
|
33
|
/*
|
29
|
34
|
* Set to positive value to enabled debug prints related to the sigill
|
... |
... |
@@ -153,8 +158,10 @@ arch_skip_instruction(os_context_t * context) |
153
|
158
|
/* Get and skip the lisp error code. */
|
154
|
159
|
char* pc = (char *) SC_PC(context);
|
155
|
160
|
|
156
|
|
- /* Skip over the UD2 inst (0x0f, 0x0b) */
|
157
|
|
- pc += 2;
|
|
161
|
+ /*
|
|
162
|
+ * Skip over the part of the UD1 inst (0x0f, 0xb9) so we can get to the mod r/m byte
|
|
163
|
+ */
|
|
164
|
+ pc += sizeof(ud1);
|
158
|
165
|
|
159
|
166
|
code = *pc++;
|
160
|
167
|
SC_PC(context) = (unsigned long) pc;
|
... |
... |
@@ -167,10 +174,7 @@ arch_skip_instruction(os_context_t * context) |
167
|
174
|
SC_PC(context) = (unsigned long) pc;
|
168
|
175
|
|
169
|
176
|
/* Skip lisp error arg data bytes */
|
170
|
|
- while (vlen-- > 0) {
|
171
|
|
- pc++;
|
172
|
|
- SC_PC(context) = (unsigned long) pc;
|
173
|
|
- }
|
|
177
|
+ SC_PC(context) = (unsigned long) (pc + vlen);
|
174
|
178
|
break;
|
175
|
179
|
|
176
|
180
|
case trap_Breakpoint:
|
... |
... |
@@ -382,75 +386,75 @@ sigill_handler(HANDLER_ARGS) |
382
|
386
|
* should call interrupt_handle_now, as we do below for an unknown
|
383
|
387
|
* trap code?
|
384
|
388
|
*/
|
385
|
|
- if (*(unsigned short *) SC_PC(context) == 0xb90f) {
|
386
|
|
- /*
|
387
|
|
- * This must match what the lisp code is doing. The trap
|
388
|
|
- * number is placed in the low 6-bits of the 3rd byte of the
|
389
|
|
- * instruction.
|
390
|
|
- */
|
391
|
|
- trap = *(((char *)SC_PC(context)) + 2) & 63;
|
392
|
|
- } else {
|
393
|
|
- abort();
|
394
|
|
- }
|
|
389
|
+ if (memcmp((void *)SC_PC(context), ud1, sizeof(ud1)) == 0) {
|
|
390
|
+ /*
|
|
391
|
+ * This must match what the lisp code is doing. The trap
|
|
392
|
+ * number is placed in the low 6-bits of the 3rd byte of the
|
|
393
|
+ * instruction.
|
|
394
|
+ */
|
|
395
|
+ trap = *(((char *)SC_PC(context)) + 2) & 63;
|
395
|
396
|
|
396
|
|
- DPRINTF(debug_handlers, (stderr, "code = %x\n", trap));
|
|
397
|
+ DPRINTF(debug_handlers, (stderr, "code = %x\n", trap));
|
397
|
398
|
|
398
|
|
- switch (trap) {
|
|
399
|
+ switch (trap) {
|
399
|
400
|
case trap_PendingInterrupt:
|
400
|
|
- DPRINTF(debug_handlers, (stderr, "<trap Pending Interrupt.>\n"));
|
401
|
|
- arch_skip_instruction(os_context);
|
402
|
|
- interrupt_handle_pending(os_context);
|
403
|
|
- break;
|
|
401
|
+ DPRINTF(debug_handlers, (stderr, "<trap Pending Interrupt.>\n"));
|
|
402
|
+ arch_skip_instruction(os_context);
|
|
403
|
+ interrupt_handle_pending(os_context);
|
|
404
|
+ break;
|
404
|
405
|
|
405
|
406
|
case trap_Halt:
|
406
|
|
- {
|
407
|
|
- FPU_STATE(fpu_state);
|
408
|
|
- save_fpu_state(fpu_state);
|
|
407
|
+ {
|
|
408
|
+ FPU_STATE(fpu_state);
|
|
409
|
+ save_fpu_state(fpu_state);
|
409
|
410
|
|
410
|
|
- fake_foreign_function_call(os_context);
|
411
|
|
- lose("%%primitive halt called; the party is over.\n");
|
412
|
|
- undo_fake_foreign_function_call(os_context);
|
|
411
|
+ fake_foreign_function_call(os_context);
|
|
412
|
+ lose("%%primitive halt called; the party is over.\n");
|
|
413
|
+ undo_fake_foreign_function_call(os_context);
|
413
|
414
|
|
414
|
|
- restore_fpu_state(fpu_state);
|
415
|
|
- arch_skip_instruction(os_context);
|
416
|
|
- break;
|
417
|
|
- }
|
|
415
|
+ restore_fpu_state(fpu_state);
|
|
416
|
+ arch_skip_instruction(os_context);
|
|
417
|
+ break;
|
|
418
|
+ }
|
418
|
419
|
|
419
|
420
|
case trap_Error:
|
420
|
421
|
case trap_Cerror:
|
421
|
|
- DPRINTF(debug_handlers, (stderr, "<trap Error %x>\n", CODE(code)));
|
422
|
|
- interrupt_internal_error(signal, code, os_context, CODE(code) == trap_Cerror);
|
423
|
|
- break;
|
|
422
|
+ DPRINTF(debug_handlers, (stderr, "<trap Error %x>\n", CODE(code)));
|
|
423
|
+ interrupt_internal_error(signal, code, os_context, CODE(code) == trap_Cerror);
|
|
424
|
+ break;
|
424
|
425
|
|
425
|
426
|
case trap_Breakpoint:
|
426
|
|
- lose("Unexpected breakpoint trap in sigill-hander.\n");
|
427
|
|
- break;
|
|
427
|
+ lose("Unexpected breakpoint trap in sigill-hander.\n");
|
|
428
|
+ break;
|
428
|
429
|
|
429
|
430
|
case trap_FunctionEndBreakpoint:
|
430
|
|
- SC_PC(os_context) =
|
431
|
|
- (int) handle_function_end_breakpoint(signal, CODE(code), os_context);
|
432
|
|
- break;
|
|
431
|
+ SC_PC(os_context) =
|
|
432
|
+ (int) handle_function_end_breakpoint(signal, CODE(code), os_context);
|
|
433
|
+ break;
|
433
|
434
|
|
434
|
435
|
#ifdef trap_DynamicSpaceOverflowWarning
|
435
|
436
|
case trap_DynamicSpaceOverflowWarning:
|
436
|
|
- interrupt_handle_space_overflow(SymbolFunction
|
437
|
|
- (DYNAMIC_SPACE_OVERFLOW_WARNING_HIT),
|
438
|
|
- os_context);
|
439
|
|
- break;
|
|
437
|
+ interrupt_handle_space_overflow(SymbolFunction
|
|
438
|
+ (DYNAMIC_SPACE_OVERFLOW_WARNING_HIT),
|
|
439
|
+ os_context);
|
|
440
|
+ break;
|
440
|
441
|
#endif
|
441
|
442
|
#ifdef trap_DynamicSpaceOverflowError
|
442
|
443
|
case trap_DynamicSpaceOverflowError:
|
443
|
|
- interrupt_handle_space_overflow(SymbolFunction
|
444
|
|
- (DYNAMIC_SPACE_OVERFLOW_ERROR_HIT),
|
445
|
|
- os_context);
|
446
|
|
- break;
|
|
444
|
+ interrupt_handle_space_overflow(SymbolFunction
|
|
445
|
+ (DYNAMIC_SPACE_OVERFLOW_ERROR_HIT),
|
|
446
|
+ os_context);
|
|
447
|
+ break;
|
447
|
448
|
#endif
|
448
|
449
|
default:
|
449
|
|
- DPRINTF(debug_handlers,
|
450
|
|
- (stderr, "[C--trap default %d %d %p]\n", signal, CODE(code),
|
451
|
|
- os_context));
|
452
|
|
- interrupt_handle_now(signal, code, os_context);
|
453
|
|
- break;
|
|
450
|
+ DPRINTF(debug_handlers,
|
|
451
|
+ (stderr, "[C--trap default %d %d %p]\n", signal, CODE(code),
|
|
452
|
+ os_context));
|
|
453
|
+ interrupt_handle_now(signal, code, os_context);
|
|
454
|
+ break;
|
|
455
|
+ }
|
|
456
|
+ } else {
|
|
457
|
+ interrupt_handle_now(signal, code, os_context);
|
454
|
458
|
}
|
455
|
459
|
}
|
456
|
460
|
|