mirror of
https://github.com/corda/corda.git
synced 2025-06-22 17:09:00 +00:00
add crash function to match the semantics of System::abort
This commit is contained in:
@ -11,9 +11,16 @@
|
|||||||
#ifndef AVIAN_SYSTEM_SIGNAL_H
|
#ifndef AVIAN_SYSTEM_SIGNAL_H
|
||||||
#define AVIAN_SYSTEM_SIGNAL_H
|
#define AVIAN_SYSTEM_SIGNAL_H
|
||||||
|
|
||||||
|
#include <avian/common.h>
|
||||||
|
|
||||||
namespace avian {
|
namespace avian {
|
||||||
namespace system {
|
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).
|
// Registrar for unix-like "signals" (implemented with structured exceptions on windows).
|
||||||
// TODO: remove dependence on generated code having a well-known "thread"
|
// TODO: remove dependence on generated code having a well-known "thread"
|
||||||
// register. Use a thread-local variable instead.
|
// register. Use a thread-local variable instead.
|
||||||
|
@ -49,8 +49,9 @@
|
|||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
#include "avian/arch.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>
|
#include <avian/util/math.h>
|
||||||
|
|
||||||
|
|
||||||
@ -899,7 +900,7 @@ class MySystem: public System {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void abort() {
|
virtual void abort() {
|
||||||
::abort();
|
avian::system::crash();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void dispose() {
|
virtual void dispose() {
|
||||||
|
@ -69,7 +69,7 @@ struct SignalRegistrar::Data {
|
|||||||
Data()
|
Data()
|
||||||
{
|
{
|
||||||
if(instance) {
|
if(instance) {
|
||||||
abort();
|
crash();
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
@ -122,7 +122,7 @@ void handleSignal(int signal, siginfo_t*, void* context)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
abort();
|
crash();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool jump
|
bool jump
|
||||||
@ -144,12 +144,17 @@ void handleSignal(int signal, siginfo_t*, void* context)
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
abort();
|
crash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace posix
|
} // namespace posix
|
||||||
|
|
||||||
|
NO_RETURN void crash()
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
SignalRegistrar::SignalRegistrar()
|
SignalRegistrar::SignalRegistrar()
|
||||||
{
|
{
|
||||||
data = new (malloc(sizeof(Data))) Data();
|
data = new (malloc(sizeof(Data))) Data();
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "avian/arch.h"
|
#include "avian/arch.h"
|
||||||
#include <avian/system/system.h>
|
#include <avian/system/system.h>
|
||||||
|
#include <avian/system/signal.h>
|
||||||
#include <avian/util/runtime-array.h>
|
#include <avian/util/runtime-array.h>
|
||||||
|
|
||||||
#if defined(WINAPI_FAMILY)
|
#if defined(WINAPI_FAMILY)
|
||||||
@ -941,9 +942,7 @@ class MySystem: public System {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void abort() {
|
virtual void abort() {
|
||||||
// trigger an EXCEPTION_ACCESS_VIOLATION, which we will catch and
|
avian::system::crash();
|
||||||
// generate a debug dump for
|
|
||||||
*static_cast<volatile int*>(0) = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void dispose() {
|
virtual void dispose() {
|
||||||
|
@ -57,7 +57,7 @@ struct SignalRegistrar::Data {
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (instance) {
|
if (instance) {
|
||||||
abort();
|
crash();
|
||||||
}
|
}
|
||||||
instance = this;
|
instance = this;
|
||||||
memset(handlers, 0, sizeof(handlers));
|
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)
|
bool SignalRegistrar::handleSegFault(Handler* handler)
|
||||||
{
|
{
|
||||||
return data->registerHandler(handler, windows::SegFaultIndex);
|
return data->registerHandler(handler, windows::SegFaultIndex);
|
||||||
|
Reference in New Issue
Block a user