Date: Mon, 20 Jan 1997 12:04:47 +0100 (MET) From: Robert Hoehne To: DJGPP workers Subject: Patch for bdgcom.c Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Here is now my final patch for dbgcom.c. Because there was no inegative response to my previous patch I think every think is OK. The difference to my first mail is, that I have added some comments. *** dbgcom.c~ Fri Jan 10 14:21:34 1997 --- dbgcom.c Sat Jan 18 19:19:56 1997 *************** *** 144,149 **** --- 144,151 ---- } static __dpmi_paddr old_i31,old_i21; + static int user_int_set = 0; + static __dpmi_paddr my_i9,user_i9,my_i8,user_i8; static void hook_dpmi(void) { *************** *** 152,163 **** --- 154,176 ---- __dpmi_get_protected_mode_interrupt_vector(0x21, &old_i21); __dpmi_get_protected_mode_interrupt_vector(0x31, &old_i31); + /* Save our current interrupt vectors for the keyboard and the timer */ + __dpmi_get_protected_mode_interrupt_vector(0x09, &my_i9); + __dpmi_get_protected_mode_interrupt_vector(0x08, &my_i8); asm("mov %%cs,%0" : "=g" (new_int.selector) ); new_int.offset32 = (unsigned long)i21_hook; __dpmi_set_protected_mode_interrupt_vector(0x21, &new_int); new_int.offset32 = (unsigned long)i31_hook; __dpmi_set_protected_mode_interrupt_vector(0x31, &new_int); + + /* If we have called already unhook_dpmi, the user interrupt + vectors for the keyboard and the timer are valid. */ + if (user_int_set) + { + __dpmi_set_protected_mode_interrupt_vector(0x09, &user_i9); + __dpmi_set_protected_mode_interrupt_vector(0x08, &user_i8); + } } /* Change a handle in the list: EAX is the old handle, EDX is the new */ *************** *** 280,290 **** ); /* BUGS: We ignore the exception handlers for the child process, so signals ! do not work. We also disable the hooking of HW interrupts that might ! cause the HW-interrupt-to-limit exceptions, since they can never be fixed. ! Byproduct: You can't debug code which hooks int 9, since it's keyboard ! routine never gets called. Eventually, we should save the exception and ! interrupt hooks and then chain to them on the next execution. Someday. */ /* Watch set selector base, if it is __djgpp_app_DS then reset breakpoints */ --- 293,300 ---- ); /* BUGS: We ignore the exception handlers for the child process, so signals ! do not work. We also disable the hooking of the numeric coprocessor ! HW interrupt. */ /* Watch set selector base, if it is __djgpp_app_DS then reset breakpoints */ *************** *** 349,357 **** pushl (%eax) \n\ pushl %eax \n\ call _longjmp \n\ ! Lc31d: cmpb $9,%bl \n\ ! je Lc31a \n\ ! cmpb $0x75,%bl \n\ je Lc31a \n\ jmp Lc31c \n\ Lc31_alloc_mem: \n\ --- 359,365 ---- pushl (%eax) \n\ pushl %eax \n\ call _longjmp \n\ ! Lc31d: cmpb $0x75,%bl \n\ je Lc31a \n\ jmp Lc31c \n\ Lc31_alloc_mem: \n\ *************** *** 489,494 **** --- 497,514 ---- { __dpmi_set_protected_mode_interrupt_vector(0x31, &old_i31); __dpmi_set_protected_mode_interrupt_vector(0x21, &old_i21); + + /* Save the interrupt vectors for the keyboard and the the + time, because the debuggee may have changed it. */ + __dpmi_get_protected_mode_interrupt_vector(0x09, &user_i9); + __dpmi_get_protected_mode_interrupt_vector(0x08, &user_i8); + + /* And remember it for hook_dpmi */ + user_int_set = 1; + + /* Now restore our interrupt vectors */ + __dpmi_set_protected_mode_interrupt_vector(0x09, &my_i9); + __dpmi_set_protected_mode_interrupt_vector(0x08, &my_i8); } static void dbgsig(int sig) *************** *** 630,635 **** --- 650,659 ---- void cleanup_client(void) { int i; + + /* Set the flag, that the user interrupt vectors are no longer valid */ + user_int_set = 0; + /* Close all handles, which may be left open */ close_handles(); for (i=0;i