Newer
Older
minerva / Ports / backward-cpp / patches / 0002-backward-Pretend-to-be-Linux-with-some-modifications.patch
@minerva minerva on 13 Jul 2 KB Initial commit
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Andrew Kaster <andrewdkaster@gmail.com>
Date: Sat, 11 Mar 2023 15:17:34 -0700
Subject: [PATCH] backward: Pretend to be Linux, with some modifications

---
 backward.hpp | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/backward.hpp b/backward.hpp
index 670aa45853997c515974bb9411d7a9e72aeeee78..ff51271a9490d3f16520ca459849d384b3f2061a 100644
--- a/backward.hpp
+++ b/backward.hpp
@@ -63,7 +63,7 @@
 #elif defined(BACKWARD_SYSTEM_UNKNOWN)
 #elif defined(BACKWARD_SYSTEM_WINDOWS)
 #else
-#if defined(__linux) || defined(__linux__)
+#if defined(__linux) || defined(__linux__) || defined(__minerva__)
 #define BACKWARD_SYSTEM_LINUX
 #elif defined(__APPLE__)
 #define BACKWARD_SYSTEM_DARWIN
@@ -219,7 +219,9 @@
 #endif
 #include <signal.h>
 #include <sys/stat.h>
+#ifndef __minerva__
 #include <syscall.h>
+#endif
 #include <unistd.h>
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
@@ -742,7 +744,7 @@ public:
 protected:
   void load_thread_info() {
 #ifdef BACKWARD_SYSTEM_LINUX
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) && !defined(__minerva__)
     _thread_id = static_cast<size_t>(syscall(SYS_gettid));
 #else
     _thread_id = static_cast<size_t>(gettid());
@@ -4171,7 +4173,9 @@ public:
       SIGBUS,  // Bus error (bad memory access)
       SIGFPE,  // Floating point exception
       SIGILL,  // Illegal Instruction
+#if !defined(__minerva__)
       SIGIOT,  // IOT trap. A synonym for SIGABRT
+#endif
       SIGQUIT, // Quit from keyboard
       SIGSEGV, // Invalid memory reference
       SIGSYS,  // Bad argument to routine (SVr4)
@@ -4262,6 +4266,8 @@ public:
     error_addr = reinterpret_cast<void *>(uctx->uc_mcontext->__ss.__rip);
 #elif defined(__APPLE__)
     error_addr = reinterpret_cast<void *>(uctx->uc_mcontext->__ss.__eip);
+#elif defined(__minerva__) && defined(__x86_64__)
+    error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.rip);
 #else
 #warning ":/ sorry, ain't know no nothing none not of your architecture!"
 #endif
@@ -4277,7 +4283,8 @@ public:
     printer.print(st, stderr);
 
 #if (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700) || \
-    (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L)
+    (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) && \
+    !defined(__minerva__)
     psiginfo(info, nullptr);
 #else
     (void)info;