From: Eli Zaretskii Date: Fri, 9 Aug 2013 10:18:48 +0000 (+0300) Subject: Define a few variables of obscure types to aid debugging exceptions on Windows. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1686^2~348 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=55902276706ea2db832ad5748a18ab392a0873f1;p=emacs.git Define a few variables of obscure types to aid debugging exceptions on Windows. src/w32.c (PEXCEPTION_POINTERS, PEXCEPTION_RECORD, PCONTEXT): Define variables of these types so that GDB would know about them, as aid for debugging fatal exceptions. (Bug#15024) See also http://sourceware.org/ml/gdb/2013-08/msg00010.html for related discussions. --- diff --git a/src/ChangeLog b/src/ChangeLog index d57086f7141..aa424d2ec06 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2013-08-09 Eli Zaretskii + + * w32.c (PEXCEPTION_POINTERS, PEXCEPTION_RECORD, PCONTEXT): Define + variables of these types so that GDB would know about them, as aid + for debugging fatal exceptions. (Bug#15024) See also + http://sourceware.org/ml/gdb/2013-08/msg00010.html for related + discussions. + 2013-08-08 Jan Djärv * nsterm.m (ns_update_begin): Don't change clip path if it would be diff --git a/src/w32.c b/src/w32.c index bb2f0acd99a..9b87cfc8faa 100644 --- a/src/w32.c +++ b/src/w32.c @@ -89,6 +89,21 @@ typedef struct _MEMORY_STATUS_EX { DWORDLONG ullAvailExtendedVirtual; } MEMORY_STATUS_EX,*LPMEMORY_STATUS_EX; +/* These are here so that GDB would know about these data types. This + allows to attach GDB to Emacs when a fatal exception is triggered + and Windows pops up the "application needs to be closed" dialog. + At that point, _gnu_exception_handler, the top-level exception + handler installed by the MinGW startup code, is somewhere on the + call-stack of the main thread, so going to that call frame and + looking at the argument to _gnu_exception_handler, which is a + PEXCEPTION_POINTERS pointer, can reveal the exception code + (excptr->ExceptionRecord->ExceptionCode) and the address where the + exception happened (excptr->ExceptionRecord->ExceptionAddress), as + well as some additional information specific to the exception. */ +PEXCEPTION_POINTERS excptr; +PEXCEPTION_RECORD excprec; +PCONTEXT ctxrec; + #include #include