This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] win32-nat.c: Handle EXCEPTION_INVALID_HANDLE as SIGSYS


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]