boost1.42 (1.42.0-4) hurd-execution_monitor.patch

Summary

 boost/test/impl/execution_monitor.ipp |  115 ++++++++++++++++++++++++++++++++++
 1 file changed, 115 insertions(+)

    
download this patch

Patch contents

Description: Avoid build problem on hurd
 Hurd does not define sigaction::sa_handler so
 implement logic using basic sa_handler.
Author: Pino Toscano <pino@kde.org>
Bug: 552383
Forwarded: not yet

--- boost1.42-1.42.0.orig/boost/test/impl/execution_monitor.ipp
+++ boost1.42-1.42.0/boost/test/impl/execution_monitor.ipp
@@ -301,22 +301,37 @@
 public:
     // Constructor
     system_signal_exception()
+#ifdef SA_SIGINFO
     : m_sig_info( 0 )
     , m_context( 0 )
+#else
+    : m_sig( 0 )
+#endif
     {}
 
     // Access methods
+#ifdef SA_SIGINFO
     void        operator()( siginfo_t* i, void* c )
     {
         m_sig_info  = i;
         m_context   = c;
     }
+#else
+    void        operator()( int s )
+    {
+        m_sig       = s;
+    }
+#endif
     void        report() const;
 
 private:
     // Data members
+#ifdef SA_SIGINFO
     siginfo_t*  m_sig_info; // system signal detailed info
     void*       m_context;  // signal context
+#else
+    int         m_sig;      // sistem signal
+#endif
 };
 
 //____________________________________________________________________________//
@@ -324,6 +339,7 @@
 void
 system_signal_exception::report() const
 {
+#ifdef SA_SIGINFO
     if( !m_sig_info )
         return; // no error actually occur?
 
@@ -608,6 +624,59 @@
     default:
         report_error( execution_exception::system_error, "unrecognized signal" );
     }
+#else
+    if( !m_sig )
+        return; // no error actually occur?
+
+    switch( m_sig ) {
+    case SIGILL:
+        report_error( execution_exception::system_fatal_error, 
+                      "signal: SIGILL (illegal instruction)" ); 
+        break;
+
+    case SIGFPE:
+        report_error( execution_exception::system_error,
+                      "signal: SIGFPE (errnoneous arithmetic operations)" );
+        break;
+
+    case SIGSEGV:
+        report_error( execution_exception::system_fatal_error,
+                      "signal: SIGSEGV (memory access violation)" );
+        break;
+
+    case SIGBUS:
+        report_error( execution_exception::system_fatal_error,
+                      "signal: SIGSEGV (memory access violation)" );
+        break;
+
+    case SIGCHLD:
+        report_error( execution_exception::system_fatal_error,
+                      "signal: SIGCHLD (child process has terminated)" );
+        break;
+
+#if defined(BOOST_TEST_CATCH_SIGPOLL)
+
+    case SIGPOLL:
+        report_error( execution_exception::system_error, 
+                      "signal: SIGPOLL (asynchronous I/O event occured)" ); 
+        break;
+
+#endif
+
+    case SIGABRT:
+        report_error( execution_exception::system_error,
+                      "signal: SIGABRT (application abort requested)" );
+        break;
+
+    case SIGALRM:
+        report_error( execution_exception::timeout_error,
+                      "signal: SIGALRM (timeout while executing function)" );
+        break;
+
+    default:
+        report_error( execution_exception::system_error, "unrecognized signal" );
+    }
+#endif
 }
 
 //____________________________________________________________________________//
@@ -618,8 +687,13 @@
 
 // Forward declaration
 extern "C" {
+#ifdef SA_SIGINFO
 static void execution_monitor_jumping_signal_handler( int sig, siginfo_t* info, void* context );
 static void execution_monitor_attaching_signal_handler( int sig, siginfo_t* info, void* context );
+#else
+static void execution_monitor_jumping_signal_handler( int sig );
+static void execution_monitor_attaching_signal_handler( int sig );
+#endif
 }
 
 class signal_action {
@@ -662,9 +736,14 @@
         return;
     }
 
+#ifdef SA_SIGINFO
     m_new_action.sa_flags     |= SA_SIGINFO;
     m_new_action.sa_sigaction  = attach_dbg ? &execution_monitor_attaching_signal_handler
                                             : &execution_monitor_jumping_signal_handler;
+#else
+    m_new_action.sa_handler = attach_dbg ? &execution_monitor_attaching_signal_handler
+                                         : &execution_monitor_jumping_signal_handler;
+#endif
     BOOST_TEST_SYS_ASSERT( sigemptyset( &m_new_action.sa_mask ) != -1 );
 
 #ifdef BOOST_TEST_USE_ALT_STACK
@@ -813,6 +892,7 @@
 
 extern "C" {
 
+#ifdef SA_SIGINFO
 static bool ignore_sigchild( siginfo_t* info )
 {
     return info->si_signo == SIGCHLD
@@ -825,9 +905,16 @@
             && (int)info->si_status == 0;
 #endif
 }
+#else
+static bool ignore_sigchild( int sig )
+{
+    return sig == SIGCHLD;
+}
+#endif
 
 //____________________________________________________________________________//
 
+#ifdef SA_SIGINFO
 static void execution_monitor_jumping_signal_handler( int sig, siginfo_t* info, void* context )
 {
     if( ignore_sigchild( info ) )
@@ -854,6 +941,34 @@
 
 //____________________________________________________________________________//
 
+#else
+static void execution_monitor_jumping_signal_handler( int sig )
+{
+    if( ignore_sigchild( sig ) )
+        return;
+
+    signal_handler::sys_sig()( sig );
+
+    siglongjmp( signal_handler::jump_buffer(), sig );
+}
+
+//____________________________________________________________________________//
+
+static void execution_monitor_attaching_signal_handler( int sig )
+{
+    if( ignore_sigchild( sig ) )
+        return;
+
+    if( !debug::attach_debugger( false ) )
+        execution_monitor_jumping_signal_handler( sig );
+
+    // debugger attached; it will handle the signal
+    BOOST_TEST_SYS_ASSERT( ::signal( sig, SIG_DFL ) != SIG_ERR );
+}
+#endif
+
+//____________________________________________________________________________//
+
 }
 
 } // namespace detail