From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ef989bbe2c445551,start X-Google-Attributes: gid103376,public From: "Richard S. Kirkland" Subject: GDB Bug: Problem with ReadConsoleInput Date: 1999/08/04 Message-ID: <37A8ABEC.A70D0C39@raytheon.com> X-Deja-AN: 508926141 X-Accept-Language: en Content-Type: multipart/mixed; boundary="------------01FD38FB887579D819E99DC1" X-Complaints-To: news@icg.raytheon.com X-Trace: dfw-service1.ext.raytheon.com 933800754 138.126.255.194 (Wed, 04 Aug 1999 16:05:54 CDT) Organization: Raytheon Systems Company MIME-Version: 1.0 Reply-To: rkirklan@ieee.org NNTP-Posting-Date: Wed, 04 Aug 1999 16:05:54 CDT Newsgroups: comp.lang.ada Date: 1999-08-04T00:00:00+00:00 List-Id: This is a multi-part message in MIME format. --------------01FD38FB887579D819E99DC1 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I am porting an old DOS Ada program to Win32 on NT. I have a task which handles input via ReadConsoleInput. When the program runs outside GDB, keys are processed via this task. When I call ReadConsoleInput from this task within GDB, I get error code 6 (ERROR_INVALID_HANDLE). The handle is the same as when running without GDB. Any clues as to why GDB would affect the reading of the console input? Code Sample Follows: task body Console_task is use Win32; use type Win32.Winnt.HANDLE; use type Interfaces.C.Unsigned_Long; function Scan_Code_To_Key_Stroke is new Unchecked_Conversion( Win32.BYTE, KEY_STROKE_CLASS.PRIMITIVE_TYPE ); function To_Int is new Unchecked_Conversion( Win32.Winnt.HANDLE, Integer ); hConsole_In : Win32.Winnt.HANDLE; In_Rec : aliased Win32.Wincon.INPUT_RECORD; Num_Read : aliased Win32.DWORD; Success : Win32.BOOL := 0; KeyEv : Win32.Wincon.KEY_EVENT_RECORD; KeyStroke : KEY_STROKE_CLASS.PRIMITIVE_TYPE; ALT_KEY_PRESSED : Win32.DWORD := Win32.Wincon.RIGHT_ALT_PRESSED or Win32.Wincon.LEFT_ALT_PRESSED; CTRL_KEY_PRESSED : Win32.DWORD := Win32.Wincon.RIGHT_CTRL_PRESSED or Win32.Wincon.LEFT_CTRL_PRESSED; LSB : Win32.BYTE; ErrorInt : Integer; begin accept Start; HConsole_In := Win32.Winbase.GetStdHandle( Win32.Winbase.STD_INPUT_HANDLE); if HConsole_In = Win32.Winbase.INVALID_HANDLE_VALUE then ErrorInt := Integer( Win32.Winbase.GetLastError ); Debug_IO.Log( ErrorInt, "Console_Task called GetStdHandle"); end if; loop Success := Win32.Wincon.ReadConsoleInput( hConsoleInput => hConsole_In, lpBuffer => In_Rec'Unchecked_Access, nLength => 1, lpNumberOfEventsRead => Num_Read'Unchecked_Access ); if Success = 0 then ErrorInt := Integer( Win32.Winbase.GetLastError ); Key_Fail := Key_Fail + 1; if Key_Fail = 20 then -- Always get here when in GDB, never get here out of GDB Debug_IO.Log("Key_Fail = 20", "Console_Task"); Debug_IO.Log( ErrorInt, "Fail"); Debug_IO.Log( To_Int( HConsole_In), "hConsole_In"); -- Check to see if the Std Input has been changed by GDB??? HConsole_In := Win32.Winbase.GetStdHandle( Win32.Winbase.STD_INPUT_HANDLE); Debug_IO.Log( To_Int( HConsole_In), "hConsole_In"); end if; else Key_Count := Key_Count + 1; if Key_Count = 20 then -- Always get here without GDB, never get here in GDB Debug_IO.Log("Key_Count = 20", "Console_Task"); end if; case In_Rec.EventType is when Win32.Wincon.KEY_EVENT => -- type KEY_EVENT_RECORD is -- wincon.h:41 -- record -- bKeyDown : Win32.BOOL; -- wincon.h:42 -- wRepeatCount : Win32.WORD; -- wincon.h:43 -- wVirtualKeyCode : Win32.WORD; -- wincon.h:44 -- wVirtualScanCode : Win32.WORD; -- wincon.h:45 -- uChar : union_anonymous0_t; -- wincon.h:49 -- dwControlKeyState: Win32.DWORD; -- wincon.h:50 -- end record; KeyEv := In_Rec.Event.KeyEvent; -- -- Set the "special" keys if the appropriate bit mask -- of the Control Key State does not equal 0 -- SELF.ALT_PRESSED := 0 /= ( KeyEv.dwControlKeyState and ALT_KEY_PRESSED ); SELF.CONTROL_PRESSED := 0 /= ( KeyEv.dwControlKeyState and CTRL_KEY_PRESSED ); SELF.EXTENDED_KEY := 0 /= ( KeyEv.dwControlKeyState and Wincon.ENHANCED_KEY ); SELF.SHIFT_PRESSED := 0 /= ( KeyEv.dwControlKeyState and Wincon.SHIFT_PRESSED ); -- Process Keys on the Down Stroke if KeyEv.bKeyDown = 1 then -- set spinner to show interrupt being processed MSG.Set_Spinner_Char( SELF => SELF.SPINNER.all, CHAR => 'U' ); LSB := Win32.Utils.LOBYTE( KeyEv.WVirtualScanCode ); KeyStroke := Scan_Code_To_Key_Stroke( LSB ); Process_Normal_Keystroke( KeyStroke ); MSG.Change_Spinner( SELF => SELF.SPINNER.all ); end if; when others => null; end case; end if; end loop; end Console_Task; --------------01FD38FB887579D819E99DC1 Content-Type: text/x-vcard; charset=us-ascii; name="r-kirkland.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Richard S. Kirkland Content-Disposition: attachment; filename="r-kirkland.vcf" begin:vcard n:Kirkland;Richard x-mozilla-html:FALSE org:Raytheon Systems Company adr:;;2501 W. University, M/S 8052;McKinney;TX;75070;USA version:2.1 email;internet:rkirklan@ieee.org tel;fax:972-952-2600 tel;home:817-577-9575 tel;work:972-952-4921 x-mozilla-cpt:;0 fn:Kirkland, Richard end:vcard --------------01FD38FB887579D819E99DC1--