From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17426 invoked by alias); 23 Oct 2007 21:55:49 -0000 Received: (qmail 17417 invoked by uid 22791); 23 Oct 2007 21:55:48 -0000 X-Spam-Check-By: sourceware.org Received: from pool-70-20-17-24.bstnma.fios.verizon.net (HELO ednor.cgf.cx) (70.20.17.24) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 23 Oct 2007 21:55:38 +0000 Received: by ednor.cgf.cx (Postfix, from userid 201) id A1AF32B353; Tue, 23 Oct 2007 17:47:30 -0400 (EDT) Date: Tue, 23 Oct 2007 22:06:00 -0000 From: Christopher Faylor To: gdb-patches@sourceware.org Subject: Re: [RFC] win32-nat.c: Handle EXCEPTION_INVALID_HANDLE as SIGSYS Message-ID: <20071023214730.GB5570@ednor.casa.cgf.cx> Mail-Followup-To: gdb-patches@sourceware.org References: <008101c814b1$9aeb2dd0$d0c18970$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <008101c814b1$9aeb2dd0$d0c18970$@u-strasbg.fr> User-Agent: Mutt/1.5.16 (2007-06-09) 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: 2007-10/txt/msg00554.txt.bz2 On Mon, Oct 22, 2007 at 03:44:01PM +0200, Pierre Muller wrote: > This patch does several things, >that should probably be separated into several smaller >patches, but I send it here together as a RFC. > > The patch mainly fixes the problems described in the thread starting with: >http://sourceware.org/ml/gdb/2007-10/msg00131.html > > The patch first implements recognition of >the exception EXCEPTION_INVALID_HANDLE generated >by a call to CloseHandle with an invalid parameter. > > The new variable stop_on_invalid_handle, >which can be set via "set stoponinvalidhandle", >allows to either ignore that exception completely >(with just a comment if verbose is set, default behavior), >or to map it to SIGSYS, which can then be handled as any >target signal via "handle SIGSYS ..." > > Combined to this I integrated the new variable >old_behavior, which allowed me to disable >all CloseHandle calls present in the win32-nat.c source >that resulted in later INVALID_HANDLE exception. > These exceptions come from the fact that the >win32 API specifications say that the thread and process >handles are closed by the system after the >corresponding debug events, and thus they should never be closed by >the debugger itself. So if I got this wrong and closed some handles that shouldn't have been closed why doesn't this patch just get rid of those cases? This patch seems amazingly complicated to me for something which seems to just be trapping a behavior that is apparently inappropriate for gdb to be doing in the first place. However, if there still is a need for these CloseHandles then it seems like there should be just one macro or function which does the equivalent of the many cases of if (old_behavior) CloseHandle(...) that are sprinkled throughout this patch. And, amusingly enough, this patch illustrates, within days of making mingw available, exactly the kind of situation I didn't want to get into by allowing gdb to build under MinGW. It forces me to evaluate a multipage patch which isn't needed for Cygwin. cgf