delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/09/05/00:44:18

From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <10109050440.AA12292@clio.rice.edu>
Subject: Re: Win2K breakpoints
To: djgpp-workers AT delorie DOT com
Date: Tue, 4 Sep 2001 23:40:12 -0500 (CDT)
In-Reply-To: <10109050334.AA20161@clio.rice.edu> from "Charles Sandmann" at Sep 04, 2001 10:34:16 PM
X-Mailer: ELM [version 2.5 PL2]
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Enclosed is WIP diff on dbgcom.c.  This is diffed from last week's dbgcom.c,
not latest cvs updates with Eli's volatile fixes.  It contains debug printf
statements.  I removed the assembly block and replaced it with our libc
dpmi call to allocate a breakpoint (the dbgcom.c code pre-dates the dpmi
calls being written in standard form :-)

I've added the Win2K workaround code, and edebug seems to work on Win2K.
Theoretically if I rebuilt the other debuggers they would behave better
also, but no time.

For your comments and amusement, since I may not get back to it this week.

*** dbgcom.c_	Fri Jul 13 12:50:10 2001
--- dbgcom3.c	Tue Sep  4 23:32:02 2001
*************** void load_npx (void)
*** 206,236 ****
    asm ("frstor %0" : "=m" (npx));
  }
  
- static int _DPMIsetBreak(unsigned short sizetype, unsigned vaddr)
- {
- 	int handle;
- 
- 	asm volatile(						       "\n\
- 	    movw   %1,%%dx						\n\
- 	    movl   %2,%%ecx						\n\
- 	    movl   %%ecx,%%ebx						\n\
- 	    shrl   $16,%%ebx						\n\
- 	    movw   $0x0b00,%%ax						\n\
- 	    int    $0x31						\n\
- 	    jnc    3f							\n\
- 	    xorl   %%ebx,%%ebx						\n\
- 	    decl   %%ebx						\n\
- 	    jmp    1f							\n\
- 3:          movzwl %%bx,%%ebx						\n\
- 1:	    movl   %%ebx,%0						\n\
- 	    "
- 	    : "=g" (handle)			/* outputs */
- 	    : "g" (sizetype), "g"  (vaddr)	/* inputs */
- 	    : "ax", "bx", "cx", "dx"		/* regs used */
- 	);
- 	return handle;
- }
- 
  static int _DPMIcancelBreak(int handle)
  {
  	unsigned state;
--- 206,211 ----
*************** static int _DPMIcancelBreak(int handle)
*** 251,256 ****
--- 226,232 ----
  	    : "g"  (handle)			/* inputs */
  	    : "ax", "bx"			/* regs used */
  	);
+ 	printf("CancelBreak han=%d returns state=%d\n",handle,state);
  	return state;
  }
  
*************** static int _DPMIcancelBreak(int handle)
*** 258,267 ****
  void _set_break_DPMI(void);
  void _set_break_DPMI(void)
  {
!   int i;
    unsigned extract;
!   unsigned short sizetype;
    unsigned long vbase;
    
    if(__dpmi_get_segment_base_address(app_ds, &vbase) == -1)
      return;
--- 234,244 ----
  void _set_break_DPMI(void);
  void _set_break_DPMI(void)
  {
!   int i,rv;
    unsigned extract;
!   unsigned char brtype;
    unsigned long vbase;
+   __dpmi_meminfo bpinfo;
    
    if(__dpmi_get_segment_base_address(app_ds, &vbase) == -1)
      return;
*************** void _set_break_DPMI(void)
*** 271,284 ****
  
    for(i=0;i<4;i++)
      if( (edi.dr[7] >> (i*2))&3 ) {		/* enabled? */
!       sizetype = (extract >> (i*4)) & 3;    /* extract the type */
!       if(sizetype == 3) sizetype = 2;       /* convert for DPMI brain damage */
!       sizetype = (sizetype << 8) + ((extract >> (i*4+2)) & 3) + 1; /* & size */
!       breakhandle[i] = _DPMIsetBreak(sizetype, edi.dr[i]+vbase);
!       if(breakhandle[i] == -1)
!         printf("Error allocating DPMI breakpoint at address 0x%08lx\n",edi.dr[i]);
!       else
          nset++;
      } else
        breakhandle[i] = -1;
    return;
--- 248,271 ----
  
    for(i=0;i<4;i++)
      if( (edi.dr[7] >> (i*2))&3 ) {		/* enabled? */
!       brtype = (extract >> (i*4)) & 3;    /* extract the type */
!       if(brtype == 3) brtype = 2;       /* convert for DPMI brain damage */
! 
!       bpinfo.handle = -1;
!       bpinfo.size = ((extract >> (i*4+2)) & 3) + 1; /* size */
!       bpinfo.address = edi.dr[i]+vbase;
!       printf("SetBreak typ=%d siz=%d at 0x%x ",brtype,(int)bpinfo.size,(unsigned)bpinfo.address);
!       rv = __dpmi_set_debug_watchpoint(&bpinfo, brtype );
!       if(rv != -1) {
!         breakhandle[i] = bpinfo.handle;
!         if(breakhandle[i] == (bpinfo.address >> 16) ) /* Win 2K bug */
!           breakhandle[i] = nset;
          nset++;
+         printf("returns han=%d\n",breakhandle[i]);
+       } else {
+         printf("Error allocating DPMI breakpoint at address 0x%08lx\n",edi.dr[i]);
+         breakhandle[i] = -1;
+       }
      } else
        breakhandle[i] = -1;
    return;

- Raw text -


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