* Per Instance signal handler * add custom signal handler test * add instance signal handling to callable.rs * extend signal handler test to test callable.rs * test multiple instances, multiple signal handlers * support more than one current instance import_calling_export.rs is a good example of why this is needed: execution switches from one instance to another before the first one has finished running * add another custom signal handler test case * move and update custom signal handler tests * fmt * fix libc version to 0.2 * call the correct instance signal handler We keep a stack of instances so should call last() not first(). * move custom signal handler test to top level dir * windows/mac signal handling wip * os-specific signal handling wip * disable custom signal handler test on windows * fmt * unify signal handling on mac and linux
59 lines
1.7 KiB
C++
59 lines
1.7 KiB
C++
#ifndef signal_handlers_h
|
|
#define signal_handlers_h
|
|
|
|
#include <stdint.h>
|
|
#include <setjmp.h>
|
|
#ifndef __cplusplus
|
|
#include <stdbool.h>
|
|
#endif
|
|
|
|
#include <signal.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
int8_t CheckIfTrapAtAddress(const uint8_t* pc);
|
|
// Record the Trap code and wasm bytecode offset in TLS somewhere
|
|
void RecordTrap(const uint8_t* pc, bool reset_guard_page);
|
|
|
|
#if defined(_WIN32)
|
|
#include <windows.h>
|
|
#include <winternl.h>
|
|
bool InstanceSignalHandler(LPEXCEPTION_POINTERS);
|
|
#elif defined(USE_APPLE_MACH_PORTS)
|
|
bool InstanceSignalHandler(int, siginfo_t *, void *);
|
|
#else
|
|
#include <sys/ucontext.h>
|
|
bool InstanceSignalHandler(int, siginfo_t *, ucontext_t *);
|
|
#endif
|
|
|
|
void* EnterScope(void*);
|
|
void LeaveScope(void*);
|
|
void* GetScope(void);
|
|
void Unwind(void);
|
|
|
|
// This function performs the low-overhead signal handler initialization that we
|
|
// want to do eagerly to ensure a more-deterministic global process state. This
|
|
// is especially relevant for signal handlers since handler ordering depends on
|
|
// installation order: the wasm signal handler must run *before* the other crash
|
|
// handlers and since POSIX signal handlers work LIFO, this function needs to be
|
|
// called at the end of the startup process, after other handlers have been
|
|
// installed. This function can thus be called multiple times, having no effect
|
|
// after the first call.
|
|
int
|
|
EnsureEagerSignalHandlers(void);
|
|
|
|
// Assuming EnsureEagerProcessSignalHandlers() has already been called,
|
|
// this function performs the full installation of signal handlers which must
|
|
// be performed per-thread. This operation may incur some overhead and
|
|
// so should be done only when needed to use wasm.
|
|
int
|
|
EnsureDarwinMachPorts(void);
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
#endif // signal_handlers_h
|