2010-02-28 23:54:25 +08:00
|
|
|
/* exception.h
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
2012-02-13 06:43:33 +08:00
|
|
|
#pragma once
|
2010-02-28 23:54:25 +08:00
|
|
|
|
2014-08-22 17:21:33 +08:00
|
|
|
#define exception_list void
|
|
|
|
typedef struct _DISPATCHER_CONTEXT *PDISPATCHER_CONTEXT;
|
|
|
|
|
|
|
|
class exception
|
|
|
|
{
|
|
|
|
static EXCEPTION_DISPOSITION myfault (EXCEPTION_RECORD *, exception_list *,
|
|
|
|
CONTEXT *, PDISPATCHER_CONTEXT);
|
|
|
|
static EXCEPTION_DISPOSITION handle (EXCEPTION_RECORD *, exception_list *,
|
|
|
|
CONTEXT *, PDISPATCHER_CONTEXT);
|
|
|
|
public:
|
|
|
|
exception () __attribute__ ((always_inline))
|
|
|
|
{
|
|
|
|
/* Install SEH handler. */
|
2014-03-29 06:31:53 +08:00
|
|
|
asm volatile ("\n\
|
|
|
|
1: \n\
|
|
|
|
.seh_handler \
|
2014-08-22 17:21:33 +08:00
|
|
|
_ZN9exception6handleEP17_EXCEPTION_RECORDPvP8_CONTEXTP19_DISPATCHER_CONTEXT, \
|
2014-03-29 06:31:53 +08:00
|
|
|
@except \n\
|
|
|
|
.seh_handlerdata \n\
|
|
|
|
.long 1 \n\
|
|
|
|
.rva 1b, 2f, 2f, 2f \n\
|
|
|
|
.seh_code \n");
|
2010-02-28 23:54:25 +08:00
|
|
|
};
|
2014-03-29 06:31:53 +08:00
|
|
|
~exception () __attribute__ ((always_inline))
|
|
|
|
{
|
|
|
|
asm volatile ("\n\
|
|
|
|
nop \n\
|
|
|
|
2: \n\
|
|
|
|
nop \n");
|
|
|
|
}
|
2010-02-28 23:54:25 +08:00
|
|
|
};
|
|
|
|
|
2015-07-08 02:45:06 +08:00
|
|
|
LONG CALLBACK myfault_altstack_handler (EXCEPTION_POINTERS *);
|
|
|
|
|
2013-01-03 02:34:06 +08:00
|
|
|
class cygwin_exception
|
2012-02-13 06:43:33 +08:00
|
|
|
{
|
2013-04-23 17:44:36 +08:00
|
|
|
PUINT_PTR framep;
|
2013-01-03 02:34:06 +08:00
|
|
|
PCONTEXT ctx;
|
|
|
|
EXCEPTION_RECORD *e;
|
2014-01-09 00:51:20 +08:00
|
|
|
HANDLE h;
|
2013-01-03 02:34:06 +08:00
|
|
|
void dump_exception ();
|
2014-01-09 00:51:20 +08:00
|
|
|
void open_stackdumpfile ();
|
2013-01-03 02:34:06 +08:00
|
|
|
public:
|
2013-04-23 17:44:36 +08:00
|
|
|
cygwin_exception (PUINT_PTR in_framep, PCONTEXT in_ctx = NULL, EXCEPTION_RECORD *in_e = NULL):
|
2014-01-09 00:51:20 +08:00
|
|
|
framep (in_framep), ctx (in_ctx), e (in_e), h (NULL) {}
|
2013-01-03 02:34:06 +08:00
|
|
|
void dumpstack ();
|
|
|
|
PCONTEXT context () const {return ctx;}
|
2015-03-31 03:56:03 +08:00
|
|
|
EXCEPTION_RECORD *exception_record () const {return e;}
|
2013-01-03 02:34:06 +08:00
|
|
|
};
|