diff --git a/tdutils/td/utils/death_handler.cc b/tdutils/td/utils/death_handler.cc index 3bbe04d01..4da663b41 100644 --- a/tdutils/td/utils/death_handler.cc +++ b/tdutils/td/utils/death_handler.cc @@ -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 #include @@ -556,18 +558,22 @@ void DeathHandler::HandleSignal(int sig, void * /* info */, void *secret) { // Overwrite sigaction with caller's address #ifdef __linux__ -#if defined(__arm__) - trace[1] = reinterpret_cast(uc->uc_mcontext.arm_pc); -#else -#if !defined(__i386__) && !defined(__x86_64__) -#error Only ARM, x86 and x86-64 are supported -#endif -#if defined(__x86_64__) - trace[1] = reinterpret_cast(uc->uc_mcontext.gregs[REG_RIP]); -#else - trace[1] = reinterpret_cast(uc->uc_mcontext.gregs[REG_EIP]); -#endif -#endif + #if defined(__arm__) || defined(__aarch64__) + #if defined(__aarch64__) + trace[1] = reinterpret_cast(uc->uc_mcontext.arm_pc); + #else + trace[1] = reinterpret_cast(uc->uc_mcontext.arm_pc); + #endif + #else + #if !defined(__i386__) && !defined(__x86_64__) + #error Only ARM, AARCH64, x86 and x86-64 are supported + #endif + #if defined(__x86_64__) + trace[1] = reinterpret_cast(uc->uc_mcontext.gregs[REG_RIP]); + #else + trace[1] = reinterpret_cast(uc->uc_mcontext.gregs[REG_EIP]); + #endif + #endif const int path_max_length = 2048; char* name_buf = memory; @@ -727,3 +733,5 @@ void DeathHandler::HandleSignal(int sig, void * /* info */, void *secret) { #endif } // namespace Debug + +#endif diff --git a/tdutils/td/utils/death_handler.h b/tdutils/td/utils/death_handler.h index be12fac56..8a1218b37 100644 --- a/tdutils/td/utils/death_handler.h +++ b/tdutils/td/utils/death_handler.h @@ -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 \ No newline at end of file diff --git a/tdutils/td/utils/logging.cpp b/tdutils/td/utils/logging.cpp index a6c5722f6..86831d1de 100644 --- a/tdutils/td/utils/logging.cpp +++ b/tdutils/td/utils/logging.cpp @@ -12,7 +12,9 @@ #include "td/utils/Slice.h" #include "td/utils/Time.h" +#ifndef _WIN32 #include "td/utils/death_handler.h" +#endif #include #include @@ -278,11 +280,15 @@ void process_fatal_error(CSlice message) { if (callback) { callback(message); } -#if TD_THREAD_UNSUPPORTED || TD_EVENTFD_UNSUPPORTED - std::abort(); +#ifndef _WIN32 + #if TD_THREAD_UNSUPPORTED || TD_EVENTFD_UNSUPPORTED + std::abort(); + #else + struct sigaction sa{}; + Debug::DeathHandler::HandleSignal(SIGABRT, &sa, nullptr); + #endif #else - struct sigaction sa{}; - Debug::DeathHandler::HandleSignal(SIGABRT, &sa, nullptr); + std::abort(); #endif }