From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9766 invoked by alias); 21 Sep 2009 22:26:52 -0000 Received: (qmail 9757 invoked by uid 22791); 21 Sep 2009 22:26:51 -0000 X-Spam-Check-By: sourceware.org Received: from pool-98-110-183-151.bstnma.fios.verizon.net (HELO cgf.cx) (98.110.183.151) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Sep 2009 22:26:46 +0000 Received: from ednor.cgf.cx (ednor.casa.cgf.cx [192.168.187.5]) by cgf.cx (Postfix) with ESMTP id 4883A13C0C4; Mon, 21 Sep 2009 18:26:37 -0400 (EDT) Received: by ednor.cgf.cx (Postfix, from userid 201) id 41EF62B352; Mon, 21 Sep 2009 18:26:37 -0400 (EDT) Date: Mon, 21 Sep 2009 22:26:00 -0000 From: Christopher Faylor To: gdb-patches@sourceware.org, Pierre Muller Subject: Re: [RFA] windows-nat.c Cygwin save_context fix Message-ID: <20090921222637.GC17886@ednor.casa.cgf.cx> Mail-Followup-To: gdb-patches@sourceware.org, Pierre Muller References: <001d01ca3ace$4878c9f0$d96a5dd0$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001d01ca3ace$4878c9f0$d96a5dd0$@u-strasbg.fr> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-09/txt/msg00687.txt.bz2 On Mon, Sep 21, 2009 at 05:14:57PM +0200, Pierre Muller wrote: > Cygwin has a way to give a "fake" context for >an exception using a OUTPUT_DEBUG_STRING_EVENT. > > While trying to debug some crashes inside cygwin dll, >I realized the the saved_context code has a problem. > > The saved context was correctly written to the thread_info >struct, but later overwritten by a call to GetThreadContext. > > After the cygwin special output_debug_string was correctly >converted into a context stored in saved_context. > The next call to do_windows_fetch_inferior_registers >then copied this context to the thread_info struct, >set the reload_context field to zero. > > But a later call to thread_rec() with get_context=1 >can reset reload_context to one, if suspended field >is zero (this only happens if it is not the main thread). > > My patch fixes the problem by explicitly calling >SuspendThread for the threaded of the saved_context >if suspended is still zero at that point. > > >Pierre Muller >Pascal language support maintainer for GDB > > > >2009-09-21 Pierre Muller > > * src/gdb/windows-nat.c (saved_threadid): New variable. > (do_windows_fetch_inferior_registers): Check for correct thread id > and force call to SuspendThread if needed. > (handle_output_debug_string): Set saved_threadid. I REALLY hate SuspendThread and am not likely to accept a patch which uses it as a solution. I don't really understand the scenario that you are talking about since I (obviously?) have no problems debugging SEGVs in cygwin. However, would just removing the "have_saved_context = 0;" from do_windows_fetch_inferior_registers fix the problem? cgf