* 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.
This commit is contained in:
Christopher Faylor 2014-01-08 16:51:20 +00:00
parent 847980a43b
commit 8aca67421d
3 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,13 @@
2014-01-08 Christopher Faylor <me.cygwin2013@cgf.cx>
* 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 <me.cygwin2013@cgf.cx> 2014-01-04 Christopher Faylor <me.cygwin2013@cgf.cx>
* fhandler.h (cltype): New enum. * fhandler.h (cltype): New enum.

View File

@ -1,6 +1,6 @@
/* exception.h /* 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. Red Hat, Inc.
This software is a copyrighted work licensed under the terms of the This software is a copyrighted work licensed under the terms of the
@ -147,10 +147,12 @@ class cygwin_exception
PUINT_PTR framep; PUINT_PTR framep;
PCONTEXT ctx; PCONTEXT ctx;
EXCEPTION_RECORD *e; EXCEPTION_RECORD *e;
HANDLE h;
void dump_exception (); void dump_exception ();
void open_stackdumpfile ();
public: public:
cygwin_exception (PUINT_PTR in_framep, PCONTEXT in_ctx = NULL, EXCEPTION_RECORD *in_e = NULL): 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 (); void dumpstack ();
PCONTEXT context () const {return ctx;} PCONTEXT context () const {return ctx;}
}; };

View File

@ -1,7 +1,7 @@
/* exceptions.cc /* exceptions.cc
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 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. This file is part of Cygwin.
@ -122,8 +122,8 @@ error_start_init (const char *buf)
__small_sprintf (debugger_command, "%s \"%s\"", buf, pgm); __small_sprintf (debugger_command, "%s \"%s\"", buf, pgm);
} }
static void void
open_stackdumpfile () cygwin_exception::open_stackdumpfile ()
{ {
/* If we have no executable name, or if the CWD handle is NULL, /* 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 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. */ in Cygwin's cwd. Stick to caseinsensitivity. */
InitializeObjectAttributes (&attr, &ucore, OBJ_CASE_INSENSITIVE, InitializeObjectAttributes (&attr, &ucore, OBJ_CASE_INSENSITIVE,
cygheap->cwd.get_handle (), NULL); cygheap->cwd.get_handle (), NULL);
HANDLE h;
IO_STATUS_BLOCK io; IO_STATUS_BLOCK io;
NTSTATUS status; NTSTATUS status;
/* Try to open it to dump the stack in it. */ /* 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", small_printf ("End of stack trace%s\n",
i == 16 ? " (more stack frames may be present)" : ""); i == 16 ? " (more stack frames may be present)" : "");
if (h)
NtClose (h);
} }
bool bool