mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +00:00
add crash function to match the semantics of System::abort
This commit is contained in:
parent
730dade53e
commit
ca7d51edb3
@ -11,9 +11,16 @@
|
||||
#ifndef AVIAN_SYSTEM_SIGNAL_H
|
||||
#define AVIAN_SYSTEM_SIGNAL_H
|
||||
|
||||
#include <avian/common.h>
|
||||
|
||||
namespace avian {
|
||||
namespace system {
|
||||
|
||||
// Crash the process.
|
||||
// On posix, the just calls abort. On windows, we dereference a null pointer in
|
||||
// order to trigger the crash dump logic.
|
||||
NO_RETURN void crash();
|
||||
|
||||
// Registrar for unix-like "signals" (implemented with structured exceptions on windows).
|
||||
// TODO: remove dependence on generated code having a well-known "thread"
|
||||
// register. Use a thread-local variable instead.
|
||||
|
@ -49,8 +49,9 @@
|
||||
#include "dirent.h"
|
||||
#include "sched.h"
|
||||
#include "avian/arch.h"
|
||||
#include <avian/system/system.h>
|
||||
|
||||
#include <avian/system/system.h>
|
||||
#include <avian/system/signal.h>
|
||||
#include <avian/util/math.h>
|
||||
|
||||
|
||||
@ -899,7 +900,7 @@ class MySystem: public System {
|
||||
}
|
||||
|
||||
virtual void abort() {
|
||||
::abort();
|
||||
avian::system::crash();
|
||||
}
|
||||
|
||||
virtual void dispose() {
|
||||
|
@ -69,7 +69,7 @@ struct SignalRegistrar::Data {
|
||||
Data()
|
||||
{
|
||||
if(instance) {
|
||||
abort();
|
||||
crash();
|
||||
}
|
||||
|
||||
instance = this;
|
||||
@ -122,7 +122,7 @@ void handleSignal(int signal, siginfo_t*, void* context)
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
crash();
|
||||
}
|
||||
|
||||
bool jump
|
||||
@ -144,12 +144,17 @@ void handleSignal(int signal, siginfo_t*, void* context)
|
||||
} break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
crash();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace posix
|
||||
|
||||
NO_RETURN void crash()
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
SignalRegistrar::SignalRegistrar()
|
||||
{
|
||||
data = new (malloc(sizeof(Data))) Data();
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "avian/arch.h"
|
||||
#include <avian/system/system.h>
|
||||
#include <avian/system/signal.h>
|
||||
#include <avian/util/runtime-array.h>
|
||||
|
||||
#if defined(WINAPI_FAMILY)
|
||||
@ -941,9 +942,7 @@ class MySystem: public System {
|
||||
}
|
||||
|
||||
virtual void abort() {
|
||||
// trigger an EXCEPTION_ACCESS_VIOLATION, which we will catch and
|
||||
// generate a debug dump for
|
||||
*static_cast<volatile int*>(0) = 0;
|
||||
avian::system::crash();
|
||||
}
|
||||
|
||||
virtual void dispose() {
|
||||
|
@ -57,7 +57,7 @@ struct SignalRegistrar::Data {
|
||||
#endif
|
||||
{
|
||||
if (instance) {
|
||||
abort();
|
||||
crash();
|
||||
}
|
||||
instance = this;
|
||||
memset(handlers, 0, sizeof(handlers));
|
||||
@ -260,6 +260,17 @@ bool SignalRegistrar::Data::registerHandler(Handler* handler, int index)
|
||||
}
|
||||
}
|
||||
|
||||
NO_RETURN void crash()
|
||||
{
|
||||
// trigger an EXCEPTION_ACCESS_VIOLATION, which we will catch and
|
||||
// generate a debug dump for
|
||||
*static_cast<volatile int*>(0) = 0;
|
||||
|
||||
// Some (all?) compilers don't realize that we can't possibly continue past
|
||||
// the above statement.
|
||||
abort();
|
||||
}
|
||||
|
||||
bool SignalRegistrar::handleSegFault(Handler* handler)
|
||||
{
|
||||
return data->registerHandler(handler, windows::SegFaultIndex);
|
||||
|
Loading…
Reference in New Issue
Block a user