www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/06/18/07:41:09

Message-Id: <4.2.0.58.20010618131819.01766f10@ics.u-strasbg.fr>
X-Sender: muller AT ics DOT u-strasbg DOT fr
X-Mailer: QUALCOMM Windows Eudora Pro Version 4.2.0.58
Date: Mon, 18 Jun 2001 13:34:50 +0200
To: djgpp-workers AT delorie DOT com
From: Pierre Muller <muller AT cerbere DOT u-strasbg DOT fr>
Subject: [PATCH] avoid problems with higher exception handlers
Cc: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

   The code in src/debug/common/dbgcom.c
has a bug regarding the exception handlers.

   Don't search who is to blame, its me...
(I wrote the most of the exception support  for
GDB because I once needed it to be able to debug
a Free Pascal program similar to Rhide ,
i.e. Integrated Editor and Debugger.)

   The assembler function change_exception_handler
write the value of the exception to an array app_handler
and calls the real int 0x31 interrupt (that it hooks) with
the values of its own handlers.

   But there is a missing check for the exception number.
This led to a bug when I added handlers for exception 18 and 19
(special new exceptions for higher CPUs)
in the Free Pascal analog of dpmiexcp.c (called dpmiexcp.pp).

  This means that any DJGPP program that was to set an exception handler for
exceptions above 17 cannot be debugged by the current DJGPP GDB
executable. GDB seems to be completely blocked by the
erroneous memory write that is done...

Below is a patch that both
increases the array size to 20 (19 is the highest exception I am aware of 
until now,
and adds a check to avoid writing if the exception number is greater.
You never know what will come later, and you can always imagine that someone
just tests by sending a wrong number ...

As I told you, I have added support for these two (18 and 19) exceptions
in my dpmiexcp.c equivalent, but I think that it is probably much safer to
postpone this integration to after next release, in order to avoid having 
people
using the old GDB with new executable that would crash the debugger.



  Index: dbgcom.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/debug/common/dbgcom.c,v
retrieving revision 1.18
diff -b -c -r1.18 dbgcom.c
*** dbgcom.c	2001/01/04 21:39:13	1.18
--- dbgcom.c	2001/06/18 11:23:21
***************
*** 38,50 ****
   #define MEM_HANDLE_COUNT	256
   #define DESCRIPTOR_COUNT	128
   #define DOS_DESCRIPTOR_COUNT	128
! #define DPMI_EXCEPTION_COUNT     18
   #define DS_SIZE_COUNT           128

   #define USE_FSEXT
   #define CLOSE_UNREGISTERED_FILES
   #define SAVE_FP

   /* debug splitted into 3 parts */
   /* #define DEBUG_ALL_DBGCOM  */

--- 38,54 ----
   #define MEM_HANDLE_COUNT	256
   #define DESCRIPTOR_COUNT	128
   #define DOS_DESCRIPTOR_COUNT	128
! #define DPMI_EXCEPTION_COUNT     20
   #define DS_SIZE_COUNT           128

   #define USE_FSEXT
   #define CLOSE_UNREGISTERED_FILES
   #define SAVE_FP

+ #ifdef DONT_CLOSE_FILES
+ #undef CLOSE_UNREGISTERED_FILES
+ #endif
+
   /* debug splitted into 3 parts */
   /* #define DEBUG_ALL_DBGCOM  */

***************
*** 404,410 ****

   /* Set an exception handler */
   /* stores it into app_handler if selector is app_cs  */
!
   asm("\n\
           .text                                                           \n\
           .balign  16,,7                                                  \n\
--- 408,418 ----

   /* Set an exception handler */
   /* stores it into app_handler if selector is app_cs  */
! /* There was no check for the exception number before setting
!    app_handler array was set, this led to writing past array size PM */
! /* FIXME: this still does not allow subprocesses of the
!    currently debugged process to handle the exceptions
!    even if they set exceptions handlers PM */
   asm("\n\
           .text                                                           \n\
           .balign  16,,7                                                  \n\
***************
*** 421,426 ****
--- 429,436 ----
           addl  $_app_handler,%eax  /* only retain handlers */            \n\
           cmpw   _app_cs,%cx /* for the main app     */                   \n\
           jne    _not_in_current_app                                      \n\
+         cmpb   $20,%bl                                                  \n\
+         jae    _transmit_unchanged_values                               \n\
           movl  %ecx,4(%eax)                                              \n\
           movl  %edx,(%eax)                                               \n\
           cmpb  $0x0d,%bl	                                                \n\
***************
*** 453,458 ****
--- 463,469 ----
           addl  $_our_handler,%eax                                        \n\
           movl  4(%eax),%ecx                                              \n\
           movl (%eax),%edx                                                \n\
+ _transmit_unchanged_values:                                             \n\
           pop   %ds                                                       \n\
           pop   %es                                                       \n\
           popl  %eax                                                      \n\





Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller AT ics DOT u-strasbg DOT fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019