1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#pragma once
#include "Utils/Platform.h"
#include "Code/Binary.h"
#ifdef WINDOWS
namespace code {
namespace eh {
/**
* Windows-specific exception handling.
*/
// Activate stack information. Needed for stack traces, etc.
void activateWindowsInfo(Engine &e);
// Exception handler function. Common to both 32- and 64-bit systems.
extern "C"
EXCEPTION_DISPOSITION windowsHandler(_EXCEPTION_RECORD *er, void *frame, _CONTEXT *ctx, void *dispatch);
// Interface used by 'windowsHandler'. Implemented by either Seh32.cpp or Seh64.cpp.
struct SehFrame {
// Pointer to the stack:
void *stackPtr;
// Distance between the stack ptr and the base pointer on the stack.
ptrdiff_t frameOffset;
// Pointer to the Binary containing metadata:
Binary *binary;
// Current active block and activation.
Nat part;
Nat activation;
};
// Get a SEH frame from unwind state.
SehFrame extractFrame(_EXCEPTION_RECORD *er, void *frame, _CONTEXT *ctx, void *dispatch);
// Modify state to resume from an exception.
void resumeFrame(SehFrame &frame, Binary::Resume &resume, storm::RootObject *object,
_CONTEXT *ctx, _EXCEPTION_RECORD *er, void *dispatch);
// Cleanup a stack frame.
void cleanupFrame(SehFrame &frame);
// Clean up a stack frame until the specified point. Returns the new active part.
Nat cleanupPartialFrame(SehFrame &frame, Nat cleanUntil);
// Implemented by the backends as needed. Called by the exception handler.
void cleanupPartialFrame(SehFrame &frame, _EXCEPTION_RECORD *er);
}
}
/**
* Things missing from the Win32 headers:
*/
#ifndef EXCEPTION_UNWINDING
#define EXCEPTION_UNWINDING 0x2
#endif
#ifndef EXCEPTION_NONCONTINUABLE
#define EXCEPTION_NONCONTINUABLE 0x1
#endif
#ifndef EXCEPTION_TARGET_UNWIND
#define EXCEPTION_TARGET_UNWIND 0x20
#endif
#else
namespace code {
namespace eh {
// To make code compile on non-windows platforms.
extern "C"
void windowsHandler();
}
}
#endif
|