delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2007/08/17/10:39:43

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Gerrit van Niekerk" <gerritvn AT gpvno DOT co DOT za>
Organization: GPvNO
To: "Alexei A. Frounze" <alexfrunews AT gmail DOT com>, djgpp AT delorie DOT com
Date: Fri, 17 Aug 2007 16:37:38 +0200
MIME-Version: 1.0
Subject: Re: kbhit() not working when debugging
Message-ID: <46C5CED2.27789.D2C849F@gerritvn.gpvno.co.za>
In-reply-to: <1187224553.564679.262950@g12g2000prg.googlegroups.com>
References: <46C3950F DOT 4931 DOT 47ADF6D AT gerritvn DOT gpvno DOT co DOT za>, <1187224553 DOT 564679 DOT 262950 AT g12g2000prg DOT googlegroups DOT com>
X-mailer: Pegasus Mail for Windows (4.41)
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

On 16 Aug 2007 at 0:35, Alexei A. Frounze wrote:

> On Aug 15, 3:06 pm, "Gerrit van Niekerk" <gerri DOT  DOT  DOT  AT gpvno DOT co DOT za> wrote:
> > I have a DJGPP program executing a fairly long loop containing kbhit() to
> > check for keyboard input. When executing normally, it works fine, but as
> > soon as the program is invoked using GDB (version 6.1.1), the kbhit() never
> > returns anything but 0 when using CWSDPMI under ROM-DOS. This is the
> > case even if just running the program without setting any breakpoints or
> > watchpoints.
> >
> > GDB works fine in a DOS-BOX in WinXP.
> >
> > I have tried both DJGPP 2.03 and 2.04 with the same result.
> >
> > Any help will be appreciated.
> 
> I'm not sure if it's related, but calling kbhit() in a loop may make
> the OS (Windows NT/2000/XP/etc) think the program isn't doing anything
> but just waiting for the keyboard input. As the consequence, the OS
> may give the app significantly less time to run or give none at all
> (that is, pause it) until a key is actually pressed. In one app I had
> to hook up the keyboard interrupt and instead of repeatedly calling
> kbhit() poll a global variable that my keyboard ISR would set (and the
> poller atomically reset when done handling).
> 
> As for the debugger, I don't know for sure, but it may get in the way
> with its own keyboard stuff.
> 
It is only when running GDB on ROM-DOS that it is a problem. Works fine in a 
DOS-BOX under WinXP and always when not running GDB.

Anyway, I solved the problem by using __dpmi_int(0x16,&r) instead of kbhit() 
and getch(). Works fine now with GDB.
-- 
Gerrit van Niekerk
GP van Niekerk Ondernemings BK
Roosstraat 211, Meyerspark, 0184, South Africa
Tel: +27(12)8036501 Fax SA: 0866 413 555
Cell: +27(73)6891370
Fax Int'l: +1(206)2034139
Email: gerritvn AT gpvno DOT co DOT za
Web: http://www.gpvno.co.za



- Raw text -


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