From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19909 invoked by alias); 22 Aug 2007 11:10:42 -0000 Received: (qmail 19806 invoked by uid 22791); 22 Aug 2007 11:10:41 -0000 X-Spam-Check-By: sourceware.org Received: from Unknown (HELO mail2.br-automation.com) (213.33.116.61) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 22 Aug 2007 11:10:39 +0000 X-AuditID: c0a80110-aa710bb0000009d6-8a-46cc19a18d78 Received: from brsmtp01.br-automation.com (unknown [192.168.1.60]) by mail2.br-automation.com (Symantec Mail Security) with ESMTP id C543A912 for ; Wed, 22 Aug 2007 13:10:25 +0200 (CEST) In-Reply-To: <20070821025607.GA14389@ednor.casa.cgf.cx> To: gdb@sourceware.org Subject: Re: gdb-6.6 mingw port hangs after Ctrl-C MIME-Version: 1.0 X-Mailer: Lotus Notes Release 7.0.2 September 26, 2006 Message-ID: From: Roland Puntaier Date: Wed, 22 Aug 2007 11:10:00 -0000 Content-Type: text/plain; charset="US-ASCII" X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00163.txt.bz2 > Christopher Faylor: > You can stop another thread with a "SuspendThread()" call and you can > cause the thread to resume in another location with a "ResumeThread()" > by changing the EIP that is passed to it. However, if you do that while > you are in the middle of a low-level Windows function which, say, holds > a mutex, then you are going to eventually run into problems. I wanted to try this with the following changes in remoted.c, but I could'nt find a way to get the EIP of the new address, i.e. "continueHere:". How could that be done? #include //Added static HANDLE h_main_thread = 0;//Added static void interrupt_query (void) { target_terminal_ours (); if (query ("Interrupted while waiting for the program.\n\ Give up (and stop debugging it)? ")) { target_mourn_inferior (); if (h_main_thread){//Added CONTEXT threadContext;//Added SuspendThread(h_main_thread);//Added GetThreadContext(h_main_thread,&threadContext);//Added threadContext.Eip = &continueHere;//Added and wished it would work SetThreadContext(h_main_thread,&threadContext);//Added ResumeThread(h_main_thread);//Added ExitThread(0);//Added }//Added continueHere://Added and wished it would work deprecated_throw_reason (RETURN_QUIT); } target_terminal_inferior (); } ... static ptid_t remote_wait (ptid_t ptid, struct target_waitstatus *status) { ... h_main_thread=GetCurrentThread();//Added ofunc = signal (SIGINT, remote_interrupt); getpkt (&rs->buf, &rs->buf_size, 1); signal (SIGINT, ofunc); h_main_thread=0;//Added .... > Christopher Faylor: > You'd need to use overlapped I/O for those situations. If you do that > then you'd have to decide whether you want gdb to work on Windows 9x/Me > or not. This seems less brute force: WSARecv(), WSAWaitForMultipleEvents() instead of recv() and let WSAWaitForMultipleEvents() return through an event signaled in interrupt_query() and if that event happened, continue calling deprecated_throw_reason (RETURN_QUIT); this time from the main thread.