delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/09/14/13:17:00

From: Andris <pavenis AT lanet DOT lv>
Organization: Pavenis
To: djgpp AT delorie DOT com, Gisle Vanem <giva AT bgnett DOT no>
Subject: Re: Detecting debugger
Date: Sat, 14 Sep 2002 17:19:01 +0300
User-Agent: KMail/1.4.7
References: <Pine DOT UW2 DOT 3 DOT 95 DOT 1020914174437 DOT 4257A-100000 AT bryggen DOT bgnett DOT no>
In-Reply-To: <Pine.UW2.3.95.1020914174437.4257A-100000@bryggen.bgnett.no>
MIME-Version: 1.0
Message-Id: <200209141719.01878.pavenis@lanet.lv>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id g8EHGtI31270
Reply-To: djgpp AT delorie DOT com

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

Andris




- Raw text -


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