kbhit() not working when debugging

kbhit() not working when debugging

Post by Gerrit van » Fri, 17 Aug 2007 07:06:39


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.
--
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: XXXX@XXXXX.COM
Web: http://www.yqcomputer.com/
 
 
 

kbhit() not working when debugging

Post by Alexei A. » Fri, 17 Aug 2007 09:35:53


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 de *** , I don't know for sure, but it may get in the way
with its own keyboard stuff.

Just some thoughts.

Alex

 
 
 

kbhit() not working when debugging

Post by Gerrit van » Sat, 18 Aug 2007 23:37:38


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: XXXX@XXXXX.COM
Web: http://www.yqcomputer.com/