Date: Sat, 14 Sep 2002 23:05:38 +0200 (MET DST) From: Gisle Vanem To: djgpp AT delorie DOT com Subject: Re: Detecting debugger In-Reply-To: <200209141719.01878.pavenis@lanet.lv> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sat, 14 Sep 2002, Andris wrote: > On Saturday 14 September 2002 18:53, Gisle Vanem wrote: > > Hi, > > > > I have a strange situation where running a program under a debugger > > (RHIDE or GDB) will hang the debugger on the call to a particular > > function. So I need to prevent calling this function when the program > > is a debugee. How do I detect running under a debugger? > > > > For the record, here is that function: > > > > static inline void Wait (void) /* wait until timer changes */ > > { > > unsigned long t = _farpeekl (_dos_ds,0x46C); > > while (_farpeekl(_dos_ds,0x46C) == t) > > ((void)0); > > } > > > > It's generally not a good idea to do such wait in so tight loop. > Such loop perhaps does not touch any memory using DS > segment register (only a guess as I did not tried to compile and > inspect generated assembler source), so it's not interruptable with Ctrl-Break > or Ctrl-C. Therefore I would suggest to call __dpmi_yield() in loop and see > whether problem remains instead of trying to detect when a programm is being > run under debugger That worked, thanks. I don't quite see why this should work. Seems the real-mode timer-handler isn't called to update the timer-tick unless I do call __dpmi_yield(). Gisle V.