From 8aca67421dd83aedc58763acb05c169dd2977d46 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 8 Jan 2014 16:51:20 +0000 Subject: * exceptions.h (cygwin_exception::open_stackdumpfile): Move old function into class. (cygwin_exception::h): New member. (cygwin_exception::cygwin_exception): Initialize h to NULL. * exceptions.cc (cygwin_exception::open_stackdumpfile): Move into cygwin_exception class. Use 'h' class member. (cygwin_exception::dumpstack): Close stack dump file handle if opened. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/exception.h | 6 ++++-- winsup/cygwin/exceptions.cc | 9 +++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ededb5aca..764a3a01b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2014-01-08 Christopher Faylor + + * exceptions.h (cygwin_exception::open_stackdumpfile): Move old + function into class. + (cygwin_exception::h): New member. + (cygwin_exception::cygwin_exception): Initialize h to NULL. + * exceptions.cc (cygwin_exception::open_stackdumpfile): Move into + cygwin_exception class. Use 'h' class member. + (cygwin_exception::dumpstack): Close stack dump file handle if opened. + 2014-01-04 Christopher Faylor * fhandler.h (cltype): New enum. diff --git a/winsup/cygwin/exception.h b/winsup/cygwin/exception.h index 9c64f3883..80569e8d5 100644 --- a/winsup/cygwin/exception.h +++ b/winsup/cygwin/exception.h @@ -1,6 +1,6 @@ /* exception.h - Copyright 1996, 1997, 1998, 2000, 2001, 2005, 2010, 2011, 1012, 2013 + Copyright 1996, 1997, 1998, 2000, 2001, 2005, 2010, 2011, 1012, 2013, 2014 Red Hat, Inc. This software is a copyrighted work licensed under the terms of the @@ -147,10 +147,12 @@ class cygwin_exception PUINT_PTR framep; PCONTEXT ctx; EXCEPTION_RECORD *e; + HANDLE h; void dump_exception (); + void open_stackdumpfile (); public: cygwin_exception (PUINT_PTR in_framep, PCONTEXT in_ctx = NULL, EXCEPTION_RECORD *in_e = NULL): - framep (in_framep), ctx (in_ctx), e (in_e) {} + framep (in_framep), ctx (in_ctx), e (in_e), h (NULL) {} void dumpstack (); PCONTEXT context () const {return ctx;} }; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 98eb78760..ceddbbca5 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1,7 +1,7 @@ /* exceptions.cc Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc. + 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc. This file is part of Cygwin. @@ -122,8 +122,8 @@ error_start_init (const char *buf) __small_sprintf (debugger_command, "%s \"%s\"", buf, pgm); } -static void -open_stackdumpfile () +void +cygwin_exception::open_stackdumpfile () { /* If we have no executable name, or if the CWD handle is NULL, which means, the CWD is a virtual path, don't even try to open @@ -149,7 +149,6 @@ open_stackdumpfile () in Cygwin's cwd. Stick to caseinsensitivity. */ InitializeObjectAttributes (&attr, &ucore, OBJ_CASE_INSENSITIVE, cygheap->cwd.get_handle (), NULL); - HANDLE h; IO_STATUS_BLOCK io; NTSTATUS status; /* Try to open it to dump the stack in it. */ @@ -372,6 +371,8 @@ cygwin_exception::dumpstack () } small_printf ("End of stack trace%s\n", i == 16 ? " (more stack frames may be present)" : ""); + if (h) + NtClose (h); } bool -- cgit v1.2.3