Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl

Commits:

3 changed files:

Changes:

  • src/code/x86-vm.lisp
    ... ... @@ -247,7 +247,7 @@
    247 247
     	     (vector (make-array length :element-type '(unsigned-byte 8))))
    
    248 248
     	(declare (type (unsigned-byte 8) length)
    
    249 249
     		 (type (simple-array (unsigned-byte 8) (*)) vector))
    
    250
    -	#+nil
    
    250
    +	#+t
    
    251 251
     	(format t "internal-error-args scp ~A: pc ~X len ~D~%" scp pc length)
    
    252 252
     	;; Grab the bytes after length byte, which 
    
    253 253
     	(copy-from-system-area pc (* vm:byte-bits 4)
    

  • src/lisp/x86-arch.c
    ... ... @@ -21,9 +21,7 @@
    21 21
     #include "interr.h"
    
    22 22
     #include "breakpoint.h"
    
    23 23
     
    
    24
    -#if 0
    
    25 24
     #define BREAKPOINT_INST 0xcc	/* INT3 */
    
    26
    -#endif
    
    27 25
     
    
    28 26
     unsigned long fast_random_state = 1;
    
    29 27
     
    
    ... ... @@ -212,9 +210,11 @@ arch_install_breakpoint(void *pc)
    212 210
         fprintf(stderr, "arch_install_breakpoint at %p, old code = 0x%lx\n",
    
    213 211
                 pc, result);
    
    214 212
         
    
    215
    -#if 0
    
    213
    +#if 1
    
    216 214
         *(char *) pc = BREAKPOINT_INST;	/* x86 INT3       */
    
    215
    +#if 0
    
    217 216
         *((char *) pc + 1) = trap_Breakpoint;	/* Lisp trap code */
    
    217
    +#endif
    
    218 218
     #else
    
    219 219
         *ptr++ = 0x0f;              /* UD2 */
    
    220 220
         *ptr++ = 0x0b;
    
    ... ... @@ -263,9 +263,11 @@ arch_do_displaced_inst(os_context_t * context, unsigned long orig_inst)
    263 263
          * Put the original instruction back.
    
    264 264
          */
    
    265 265
     
    
    266
    -#if 0
    
    266
    +#if 1
    
    267 267
         *((char *) pc) = orig_inst & 0xff;
    
    268
    +#if 0
    
    268 269
         *((char *) pc + 1) = (orig_inst & 0xff00) >> 8;
    
    270
    +#endif
    
    269 271
     #else
    
    270 272
         pc[0] = orig_inst & 0xff;
    
    271 273
         pc[1] = (orig_inst >> 8) & 0xff;
    
    ... ... @@ -333,7 +335,8 @@ sigill_handler(HANDLER_ARGS)
    333 335
         fprintf(stderr, "sigtrap(%d %d %p)\n", signal, CODE(code), os_context);
    
    334 336
     #endif
    
    335 337
     
    
    336
    -    if (single_stepping && (signal == SIGILL)) {
    
    338
    +#if 0
    
    339
    +    if (single_stepping && (signal == SIGTRAP)) {
    
    337 340
     #if 1
    
    338 341
     	fprintf(stderr, "* Single step trap %p\n", single_stepping);
    
    339 342
     #endif
    
    ... ... @@ -352,9 +355,10 @@ sigill_handler(HANDLER_ARGS)
    352 355
     	/*
    
    353 356
     	 * Re-install the breakpoint if possible.
    
    354 357
     	 */
    
    355
    -        fprintf(stderr, "* Reinstall breakpoint at single_stepping %p\n", single_stepping);
    
    358
    +        fprintf(stderr, "* Maybe reinstall breakpoint for pc %p with single_stepping %p\n",
    
    359
    +                (void*) SC_PC(os_context), single_stepping);
    
    356 360
             
    
    357
    -	if ((int) SC_PC(os_context) >= (int) single_stepping + 3)
    
    361
    +	if ((int) SC_PC(os_context) < (int) single_stepping + 3)
    
    358 362
     	    fprintf(stderr, "* Breakpoint not re-install\n");
    
    359 363
     	else {
    
    360 364
     	    char *ptr = (char *) single_stepping;
    
    ... ... @@ -372,7 +376,8 @@ sigill_handler(HANDLER_ARGS)
    372 376
     	single_stepping = NULL;
    
    373 377
     	return;
    
    374 378
         }
    
    375
    -
    
    379
    +#endif
    
    380
    +    
    
    376 381
         /* This is just for info in case monitor wants to print an approx */
    
    377 382
         current_control_stack_pointer = (unsigned long *) SC_SP(os_context);
    
    378 383
     
    
    ... ... @@ -406,7 +411,7 @@ sigill_handler(HANDLER_ARGS)
    406 411
     
    
    407 412
         switch (trap) {
    
    408 413
           case trap_PendingInterrupt:
    
    409
    -	  DPRINTF(0, (stderr, "<trap Pending Interrupt.>\n"));
    
    414
    +	  DPRINTF(1, (stderr, "<trap Pending Interrupt.>\n"));
    
    410 415
     	  arch_skip_instruction(os_context);
    
    411 416
     	  interrupt_handle_pending(os_context);
    
    412 417
     	  break;
    
    ... ... @@ -427,7 +432,7 @@ sigill_handler(HANDLER_ARGS)
    427 432
     
    
    428 433
           case trap_Error:
    
    429 434
           case trap_Cerror:
    
    430
    -	  DPRINTF(0, (stderr, "<trap Error %x>\n", CODE(code)));
    
    435
    +	  DPRINTF(1, (stderr, "<trap Error %x>\n", CODE(code)));
    
    431 436
     	  interrupt_internal_error(signal, code, os_context, CODE(code) == trap_Cerror);
    
    432 437
     	  break;
    
    433 438
     
    
    ... ... @@ -468,7 +473,7 @@ sigill_handler(HANDLER_ARGS)
    468 473
     	  break;
    
    469 474
     #endif
    
    470 475
           default:
    
    471
    -	  DPRINTF(0,
    
    476
    +	  DPRINTF(1,
    
    472 477
     		  (stderr, "[C--trap default %d %d %p]\n", signal, CODE(code),
    
    473 478
     		   os_context));
    
    474 479
     	  interrupt_handle_now(signal, code, os_context);
    
    ... ... @@ -514,7 +519,7 @@ sigtrap_handler(HANDLER_ARGS)
    514 519
             fprintf(stderr, "* Maybe reinstall breakpoint for pc %p with single_stepping %p\n",
    
    515 520
                     (void*) SC_PC(os_context), single_stepping);
    
    516 521
             
    
    517
    -	if ((unsigned long) SC_PC(os_context) <= (unsigned long) single_stepping + 3)
    
    522
    +	if ((unsigned long) SC_PC(os_context) <= (unsigned long) single_stepping)
    
    518 523
     	    fprintf(stderr, "* Breakpoint not re-install\n");
    
    519 524
     	else {
    
    520 525
     	    char *ptr = (char *) single_stepping;
    
    ... ... @@ -532,6 +537,17 @@ sigtrap_handler(HANDLER_ARGS)
    532 537
     	single_stepping = NULL;
    
    533 538
     	return;
    
    534 539
         }
    
    540
    +#if 1
    
    541
    +	  fprintf(stderr, "*C break\n");
    
    542
    +#endif
    
    543
    +#if 1
    
    544
    +	  SC_PC(os_context) -= 1;
    
    545
    +#endif          
    
    546
    +
    
    547
    +	  handle_breakpoint(signal, CODE(code), os_context);
    
    548
    +#if 1
    
    549
    +	  fprintf(stderr, "*C break return\n");
    
    550
    +#endif
    
    535 551
     }
    
    536 552
     
    
    537 553
     
    

  • src/lisp/x86-assem.S
    ... ... @@ -286,7 +286,7 @@ multiple_value_return:
    286 286
     	
    
    287 287
     	.globl GNAME(function_end_breakpoint_trap)
    
    288 288
     GNAME(function_end_breakpoint_trap):
    
    289
    -	INT3
    
    289
    +	UD2
    
    290 290
     	.byte 	trap_FunctionEndBreakpoint
    
    291 291
     	hlt			# Should never return here.
    
    292 292