Fix windows support

This commit is contained in:
Andrea Cavalli 2020-09-05 15:36:26 +02:00
parent 8dfeb82bc9
commit 8fb0a0673e
3 changed files with 34 additions and 16 deletions

View File

@ -34,6 +34,8 @@
* @copyright 2012 Samsung R&D Institute Russia, 2016 Moscow Institute of Physics and Technology
*/
#ifndef _WIN32
#include "death_handler.h"
#include <assert.h>
#include <execinfo.h>
@ -556,11 +558,15 @@ void DeathHandler::HandleSignal(int sig, void * /* info */, void *secret) {
// Overwrite sigaction with caller's address
#ifdef __linux__
#if defined(__arm__)
#if defined(__arm__) || defined(__aarch64__)
#if defined(__aarch64__)
trace[1] = reinterpret_cast<void *>(uc->uc_mcontext.arm_pc);
#else
trace[1] = reinterpret_cast<void *>(uc->uc_mcontext.arm_pc);
#endif
#else
#if !defined(__i386__) && !defined(__x86_64__)
#error Only ARM, x86 and x86-64 are supported
#error Only ARM, AARCH64, x86 and x86-64 are supported
#endif
#if defined(__x86_64__)
trace[1] = reinterpret_cast<void *>(uc->uc_mcontext.gregs[REG_RIP]);
@ -727,3 +733,5 @@ void DeathHandler::HandleSignal(int sig, void * /* info */, void *secret) {
#endif
} // namespace Debug
#endif

View File

@ -51,6 +51,8 @@
* Underlying code style is very similar to [Google C++ Style Guide](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml). It is checked with cpplint.py.
*/
#ifndef _WIN32
#ifndef DEATH_HANDLER_H_
#define DEATH_HANDLER_H_
@ -258,3 +260,5 @@ class DeathHandler {
} // namespace Debug
#endif // DEATH_HANDLER_H_
#endif

View File

@ -12,7 +12,9 @@
#include "td/utils/Slice.h"
#include "td/utils/Time.h"
#ifndef _WIN32
#include "td/utils/death_handler.h"
#endif
#include <atomic>
#include <cstdlib>
@ -278,12 +280,16 @@ void process_fatal_error(CSlice message) {
if (callback) {
callback(message);
}
#ifndef _WIN32
#if TD_THREAD_UNSUPPORTED || TD_EVENTFD_UNSUPPORTED
std::abort();
#else
struct sigaction sa{};
Debug::DeathHandler::HandleSignal(SIGABRT, &sa, nullptr);
#endif
#else
std::abort();
#endif
}
namespace {