[c81ebf9] | 1 | // -*- Mode: CFA -*-
|
---|
| 2 | //
|
---|
| 3 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
|
---|
| 4 | //
|
---|
| 5 | // The contents of this file are covered under the licence agreement in the
|
---|
| 6 | // file "LICENCE" distributed with Cforall.
|
---|
| 7 | //
|
---|
| 8 | // signal.c --
|
---|
| 9 | //
|
---|
| 10 | // Author : Thierry Delisle
|
---|
| 11 | // Created On : Mon Jun 5 14:20:42 2017
|
---|
| 12 | // Last Modified By : Thierry Delisle
|
---|
| 13 | // Last Modified On : --
|
---|
| 14 | // Update Count : 0
|
---|
| 15 | //
|
---|
| 16 |
|
---|
[2ac095d] | 17 | #include "libhdr.h"
|
---|
[c81ebf9] | 18 | #include "preemption.h"
|
---|
| 19 |
|
---|
| 20 | extern "C" {
|
---|
[82ff5845] | 21 | #include <errno.h>
|
---|
[1c273d0] | 22 | #include <execinfo.h>
|
---|
[4e6fb8e] | 23 | #define __USE_GNU
|
---|
[c81ebf9] | 24 | #include <signal.h>
|
---|
[4e6fb8e] | 25 | #undef __USE_GNU
|
---|
[82ff5845] | 26 | #include <stdio.h>
|
---|
| 27 | #include <string.h>
|
---|
| 28 | #include <unistd.h>
|
---|
[c81ebf9] | 29 | }
|
---|
| 30 |
|
---|
[1c273d0] | 31 |
|
---|
| 32 | #ifdef __USE_STREAM__
|
---|
| 33 | #include "fstream"
|
---|
| 34 | #endif
|
---|
[82ff5845] | 35 |
|
---|
| 36 | #define __CFA_DEFAULT_PREEMPTION__ 10000
|
---|
[c81ebf9] | 37 |
|
---|
| 38 | __attribute__((weak)) unsigned int default_preemption() {
|
---|
| 39 | return __CFA_DEFAULT_PREEMPTION__;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
[82ff5845] | 42 | #define __CFA_SIGCXT__ ucontext_t *
|
---|
| 43 | #define __CFA_SIGPARMS__ __attribute__((unused)) int sig, __attribute__((unused)) siginfo_t *sfp, __attribute__((unused)) __CFA_SIGCXT__ cxt
|
---|
| 44 |
|
---|
[c81ebf9] | 45 | static void preempt( processor * this );
|
---|
| 46 | static void timeout( thread_desc * this );
|
---|
| 47 |
|
---|
[82ff5845] | 48 | void sigHandler_ctxSwitch( __CFA_SIGPARMS__ );
|
---|
| 49 | void sigHandler_alarm ( __CFA_SIGPARMS__ );
|
---|
[1c273d0] | 50 | void sigHandler_segv ( __CFA_SIGPARMS__ );
|
---|
| 51 | void sigHandler_abort ( __CFA_SIGPARMS__ );
|
---|
[82ff5845] | 52 |
|
---|
| 53 | static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags );
|
---|
| 54 |
|
---|
[c81ebf9] | 55 | //=============================================================================================
|
---|
| 56 | // Kernel Preemption logic
|
---|
| 57 | //=============================================================================================
|
---|
| 58 |
|
---|
| 59 | void kernel_start_preemption() {
|
---|
[82ff5845] | 60 | LIB_DEBUG_PRINT_SAFE("Kernel : Starting preemption\n");
|
---|
| 61 | __kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO );
|
---|
| 62 | __kernel_sigaction( SIGALRM, sigHandler_alarm , SA_SIGINFO );
|
---|
[1c273d0] | 63 | __kernel_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO );
|
---|
| 64 | __kernel_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO );
|
---|
| 65 | // __kernel_sigaction( SIGABRT, sigHandler_abort , SA_SIGINFO );
|
---|
[82ff5845] | 66 | }
|
---|
[c81ebf9] | 67 |
|
---|
[82ff5845] | 68 | void kernel_stop_preemption() {
|
---|
| 69 | //Block all signals, we are no longer in a position to handle them
|
---|
| 70 | sigset_t mask;
|
---|
| 71 | sigfillset( &mask );
|
---|
| 72 | sigprocmask( SIG_BLOCK, &mask, NULL );
|
---|
| 73 | LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n");
|
---|
[4e6fb8e] | 74 |
|
---|
[1c273d0] | 75 | // assert( !systemProcessor->alarms.head );
|
---|
| 76 | // assert( systemProcessor->alarms.tail == &systemProcessor->alarms.head );
|
---|
[c81ebf9] | 77 | }
|
---|
| 78 |
|
---|
[4e6fb8e] | 79 | LIB_DEBUG_DO( bool validate( alarm_list_t * this ); )
|
---|
| 80 |
|
---|
[c81ebf9] | 81 | void tick_preemption() {
|
---|
[1c273d0] | 82 | // LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Ticking preemption\n" );
|
---|
[82ff5845] | 83 |
|
---|
[c81ebf9] | 84 | alarm_list_t * alarms = &systemProcessor->alarms;
|
---|
| 85 | __cfa_time_t currtime = __kernel_get_time();
|
---|
| 86 | while( alarms->head && alarms->head->alarm < currtime ) {
|
---|
| 87 | alarm_node_t * node = pop(alarms);
|
---|
[1c273d0] | 88 | // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Ticking %p\n", node );
|
---|
| 89 |
|
---|
[c81ebf9] | 90 | if( node->kernel_alarm ) {
|
---|
| 91 | preempt( node->proc );
|
---|
| 92 | }
|
---|
| 93 | else {
|
---|
| 94 | timeout( node->thrd );
|
---|
| 95 | }
|
---|
| 96 |
|
---|
[1c273d0] | 97 | verify( validate( alarms ) );
|
---|
[4e6fb8e] | 98 |
|
---|
[c81ebf9] | 99 | if( node->period > 0 ) {
|
---|
[82ff5845] | 100 | node->alarm = currtime + node->period;
|
---|
[c81ebf9] | 101 | insert( alarms, node );
|
---|
| 102 | }
|
---|
| 103 | else {
|
---|
| 104 | node->set = false;
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | if( alarms->head ) {
|
---|
| 109 | __kernel_set_timer( alarms->head->alarm - currtime );
|
---|
| 110 | }
|
---|
[82ff5845] | 111 |
|
---|
[0b33412] | 112 | verify( validate( alarms ) );
|
---|
[1c273d0] | 113 | // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Ticking preemption done\n" );
|
---|
[c81ebf9] | 114 | }
|
---|
| 115 |
|
---|
| 116 | void update_preemption( processor * this, __cfa_time_t duration ) {
|
---|
[1c273d0] | 117 | LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Processor : %p updating preemption to %lu\n", this, duration );
|
---|
[82ff5845] | 118 |
|
---|
[c81ebf9] | 119 | alarm_node_t * alarm = this->preemption_alarm;
|
---|
[82ff5845] | 120 | duration *= 1000;
|
---|
[c81ebf9] | 121 |
|
---|
| 122 | // Alarms need to be enabled
|
---|
| 123 | if ( duration > 0 && !alarm->set ) {
|
---|
| 124 | alarm->alarm = __kernel_get_time() + duration;
|
---|
| 125 | alarm->period = duration;
|
---|
| 126 | register_self( alarm );
|
---|
| 127 | }
|
---|
| 128 | // Zero duraction but alarm is set
|
---|
| 129 | else if ( duration == 0 && alarm->set ) {
|
---|
| 130 | unregister_self( alarm );
|
---|
| 131 | alarm->alarm = 0;
|
---|
| 132 | alarm->period = 0;
|
---|
| 133 | }
|
---|
| 134 | // If alarm is different from previous, change it
|
---|
| 135 | else if ( duration > 0 && alarm->period != duration ) {
|
---|
| 136 | unregister_self( alarm );
|
---|
| 137 | alarm->alarm = __kernel_get_time() + duration;
|
---|
| 138 | alarm->period = duration;
|
---|
| 139 | register_self( alarm );
|
---|
| 140 | }
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | void ?{}( preemption_scope * this, processor * proc ) {
|
---|
| 144 | (&this->alarm){ proc };
|
---|
| 145 | this->proc = proc;
|
---|
| 146 | this->proc->preemption_alarm = &this->alarm;
|
---|
| 147 | update_preemption( this->proc, this->proc->preemption );
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | void ^?{}( preemption_scope * this ) {
|
---|
[82ff5845] | 151 | disable_interrupts();
|
---|
| 152 |
|
---|
[c81ebf9] | 153 | update_preemption( this->proc, 0 );
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | //=============================================================================================
|
---|
| 157 | // Kernel Signal logic
|
---|
| 158 | //=============================================================================================
|
---|
| 159 |
|
---|
[b227f68] | 160 | LIB_DEBUG_DO( static thread_local void * last_interrupt = 0; )
|
---|
| 161 |
|
---|
[82ff5845] | 162 | extern "C" {
|
---|
| 163 | void disable_interrupts() {
|
---|
[4e6fb8e] | 164 | __attribute__((unused)) unsigned short new_val = __atomic_add_fetch_2( &disable_preempt_count, 1, __ATOMIC_SEQ_CST );
|
---|
[0b33412] | 165 | verify( new_val < (unsigned short)65_000 );
|
---|
| 166 | verify( new_val != (unsigned short) 0 );
|
---|
[82ff5845] | 167 | }
|
---|
| 168 |
|
---|
| 169 | void enable_interrupts_noRF() {
|
---|
[2ac095d] | 170 | __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
|
---|
[0b33412] | 171 | verify( prev != (unsigned short) 0 );
|
---|
[82ff5845] | 172 | }
|
---|
| 173 |
|
---|
[2ac095d] | 174 | void enable_interrupts( DEBUG_CTX_PARAM ) {
|
---|
[1c273d0] | 175 | processor * proc = this_processor;
|
---|
| 176 | thread_desc * thrd = this_thread;
|
---|
[4e6fb8e] | 177 | unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
|
---|
[0b33412] | 178 | verify( prev != (unsigned short) 0 );
|
---|
[1c273d0] | 179 | if( prev == 1 && proc->pending_preemption ) {
|
---|
| 180 | proc->pending_preemption = false;
|
---|
| 181 | LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Executing deferred CtxSwitch on %p\n", this_processor );
|
---|
| 182 | BlockInternal( thrd );
|
---|
| 183 | LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Executing deferred back\n" );
|
---|
[82ff5845] | 184 | }
|
---|
[4e6fb8e] | 185 |
|
---|
[2ac095d] | 186 | LIB_DEBUG_DO( proc->last_enable = caller; )
|
---|
[82ff5845] | 187 | }
|
---|
| 188 | }
|
---|
| 189 |
|
---|
[1c273d0] | 190 | static inline void signal_unblock( int sig ) {
|
---|
[b227f68] | 191 | // LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Processor : %p unblocking sig %i\n", this_processor, sig );
|
---|
| 192 |
|
---|
| 193 | // LIB_DEBUG_DO(
|
---|
| 194 | // sigset_t waiting;
|
---|
| 195 | // sigemptyset(&waiting);
|
---|
| 196 | // sigpending(&waiting);
|
---|
| 197 | // verify( !sigismember(&waiting, sig) );
|
---|
| 198 | // )
|
---|
[1c273d0] | 199 |
|
---|
[82ff5845] | 200 | sigset_t mask;
|
---|
| 201 | sigemptyset( &mask );
|
---|
[1c273d0] | 202 | sigaddset( &mask, sig );
|
---|
[82ff5845] | 203 |
|
---|
| 204 | if ( sigprocmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
|
---|
| 205 | abortf( "internal error, sigprocmask" );
|
---|
| 206 | } // if
|
---|
| 207 | }
|
---|
| 208 |
|
---|
[c81ebf9] | 209 | static inline bool preemption_ready() {
|
---|
[4e6fb8e] | 210 | return disable_preempt_count == 0;
|
---|
[c81ebf9] | 211 | }
|
---|
| 212 |
|
---|
| 213 | static inline void defer_ctxSwitch() {
|
---|
| 214 | this_processor->pending_preemption = true;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | static inline void defer_alarm() {
|
---|
| 218 | systemProcessor->pending_alarm = true;
|
---|
| 219 | }
|
---|
| 220 |
|
---|
[1c273d0] | 221 | extern "C" {
|
---|
| 222 | __attribute__((noinline)) void __debug_break() {
|
---|
| 223 | pthread_kill( pthread_self(), SIGTRAP );
|
---|
| 224 | }
|
---|
| 225 | }
|
---|
[82ff5845] | 226 |
|
---|
[1c273d0] | 227 | void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) {
|
---|
[b227f68] | 228 | LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "CtxSw IRH %10p running %10p @ %10p\n", this_processor, this_thread, (void *)(cxt->uc_mcontext.gregs[REG_RIP]) );
|
---|
| 229 | LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[REG_RIP]); )
|
---|
[82ff5845] | 230 |
|
---|
[c81ebf9] | 231 | if( preemption_ready() ) {
|
---|
[b227f68] | 232 | // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Ctx Switch IRH : Blocking thread %p on %p\n", this_thread, this_processor );
|
---|
[1c273d0] | 233 | signal_unblock( SIGUSR1 );
|
---|
| 234 | BlockInternal( (thread_desc*)this_thread );
|
---|
[b227f68] | 235 | // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Ctx Switch IRH : Back\n\n");
|
---|
[c81ebf9] | 236 | }
|
---|
| 237 | else {
|
---|
[b227f68] | 238 | // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Ctx Switch IRH : Defering\n" );
|
---|
[c81ebf9] | 239 | defer_ctxSwitch();
|
---|
[1c273d0] | 240 | signal_unblock( SIGUSR1 );
|
---|
[c81ebf9] | 241 | }
|
---|
| 242 | }
|
---|
| 243 |
|
---|
[82ff5845] | 244 | void sigHandler_alarm( __CFA_SIGPARMS__ ) {
|
---|
[b227f68] | 245 | LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "\nAlarm IRH %10p running %10p @ %10p\n", this_processor, this_thread, (void *)(cxt->uc_mcontext.gregs[REG_RIP]) );
|
---|
| 246 | LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[REG_RIP]); )
|
---|
[82ff5845] | 247 |
|
---|
[2ac095d] | 248 | if( try_lock( &systemProcessor->alarm_lock DEBUG_CTX2 ) ) {
|
---|
[c81ebf9] | 249 | tick_preemption();
|
---|
| 250 | unlock( &systemProcessor->alarm_lock );
|
---|
| 251 | }
|
---|
| 252 | else {
|
---|
| 253 | defer_alarm();
|
---|
| 254 | }
|
---|
[82ff5845] | 255 |
|
---|
[1c273d0] | 256 | signal_unblock( SIGALRM );
|
---|
| 257 |
|
---|
[82ff5845] | 258 | if( preemption_ready() && this_processor->pending_preemption ) {
|
---|
[b227f68] | 259 | // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Alarm IRH : Blocking thread %p on %p\n", this_thread, this_processor );
|
---|
[82ff5845] | 260 | this_processor->pending_preemption = false;
|
---|
[1c273d0] | 261 | BlockInternal( (thread_desc*)this_thread );
|
---|
[b227f68] | 262 | // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Alarm Switch IRH : Back\n\n");
|
---|
[82ff5845] | 263 | }
|
---|
[c81ebf9] | 264 | }
|
---|
| 265 |
|
---|
| 266 | static void preempt( processor * this ) {
|
---|
[1c273d0] | 267 | // LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Processor : signalling %p\n", this );
|
---|
[82ff5845] | 268 |
|
---|
| 269 | if( this != systemProcessor ) {
|
---|
| 270 | pthread_kill( this->kernel_thread, SIGUSR1 );
|
---|
| 271 | }
|
---|
| 272 | else {
|
---|
| 273 | defer_ctxSwitch();
|
---|
| 274 | }
|
---|
[c81ebf9] | 275 | }
|
---|
| 276 |
|
---|
| 277 | static void timeout( thread_desc * this ) {
|
---|
| 278 | //TODO : implement waking threads
|
---|
[82ff5845] | 279 | }
|
---|
| 280 |
|
---|
| 281 | static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags ) {
|
---|
| 282 | struct sigaction act;
|
---|
| 283 |
|
---|
| 284 | act.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler;
|
---|
[1c273d0] | 285 | act.sa_flags = flags;
|
---|
| 286 |
|
---|
| 287 | // disabled during signal handler
|
---|
[82ff5845] | 288 | sigemptyset( &act.sa_mask );
|
---|
[1c273d0] | 289 | sigaddset( &act.sa_mask, sig );
|
---|
[82ff5845] | 290 |
|
---|
[1c273d0] | 291 | if ( sigaction( sig, &act, NULL ) == -1 ) {
|
---|
| 292 | LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO,
|
---|
| 293 | " __kernel_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",
|
---|
| 294 | sig, handler, flags, errno, strerror( errno )
|
---|
| 295 | );
|
---|
| 296 | _exit( EXIT_FAILURE );
|
---|
| 297 | }
|
---|
| 298 | }
|
---|
| 299 |
|
---|
| 300 | typedef void (*sa_handler_t)(int);
|
---|
| 301 |
|
---|
| 302 | static void __kernel_sigdefault( int sig ) {
|
---|
| 303 | struct sigaction act;
|
---|
| 304 |
|
---|
| 305 | // act.sa_handler = SIG_DFL;
|
---|
| 306 | act.sa_flags = 0;
|
---|
| 307 | sigemptyset( &act.sa_mask );
|
---|
[82ff5845] | 308 |
|
---|
| 309 | if ( sigaction( sig, &act, NULL ) == -1 ) {
|
---|
[1c273d0] | 310 | LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO,
|
---|
| 311 | " __kernel_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",
|
---|
| 312 | sig, errno, strerror( errno )
|
---|
| 313 | );
|
---|
[82ff5845] | 314 | _exit( EXIT_FAILURE );
|
---|
[1c273d0] | 315 | }
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | //=============================================================================================
|
---|
| 319 | // Terminating Signals logic
|
---|
| 320 | //=============================================================================================
|
---|
| 321 |
|
---|
| 322 | LIB_DEBUG_DO(
|
---|
| 323 | static void __kernel_backtrace( int start ) {
|
---|
| 324 | // skip first N stack frames
|
---|
| 325 |
|
---|
| 326 | enum { Frames = 50 };
|
---|
| 327 | void * array[Frames];
|
---|
| 328 | int size = backtrace( array, Frames );
|
---|
| 329 | char ** messages = backtrace_symbols( array, size );
|
---|
| 330 |
|
---|
| 331 | // find executable name
|
---|
| 332 | *index( messages[0], '(' ) = '\0';
|
---|
| 333 | #ifdef __USE_STREAM__
|
---|
| 334 | serr | "Stack back trace for:" | messages[0] | endl;
|
---|
| 335 | #else
|
---|
| 336 | fprintf( stderr, "Stack back trace for: %s\n", messages[0]);
|
---|
| 337 | #endif
|
---|
| 338 |
|
---|
| 339 | // skip last 2 stack frames after main
|
---|
| 340 | for ( int i = start; i < size && messages != NULL; i += 1 ) {
|
---|
| 341 | char * name = NULL;
|
---|
| 342 | char * offset_begin = NULL;
|
---|
| 343 | char * offset_end = NULL;
|
---|
| 344 |
|
---|
| 345 | for ( char *p = messages[i]; *p; ++p ) {
|
---|
| 346 | // find parantheses and +offset
|
---|
| 347 | if ( *p == '(' ) {
|
---|
| 348 | name = p;
|
---|
| 349 | }
|
---|
| 350 | else if ( *p == '+' ) {
|
---|
| 351 | offset_begin = p;
|
---|
| 352 | }
|
---|
| 353 | else if ( *p == ')' ) {
|
---|
| 354 | offset_end = p;
|
---|
| 355 | break;
|
---|
| 356 | }
|
---|
| 357 | }
|
---|
| 358 |
|
---|
| 359 | // if line contains symbol print it
|
---|
| 360 | int frameNo = i - start;
|
---|
| 361 | if ( name && offset_begin && offset_end && name < offset_begin ) {
|
---|
| 362 | // delimit strings
|
---|
| 363 | *name++ = '\0';
|
---|
| 364 | *offset_begin++ = '\0';
|
---|
| 365 | *offset_end++ = '\0';
|
---|
| 366 |
|
---|
| 367 | #ifdef __USE_STREAM__
|
---|
| 368 | serr | "(" | frameNo | ")" | messages[i] | ":"
|
---|
| 369 | | name | "+" | offset_begin | offset_end | endl;
|
---|
| 370 | #else
|
---|
| 371 | fprintf( stderr, "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
|
---|
| 372 | #endif
|
---|
| 373 | }
|
---|
| 374 | // otherwise, print the whole line
|
---|
| 375 | else {
|
---|
| 376 | #ifdef __USE_STREAM__
|
---|
| 377 | serr | "(" | frameNo | ")" | messages[i] | endl;
|
---|
| 378 | #else
|
---|
| 379 | fprintf( stderr, "(%i) %s\n", frameNo, messages[i] );
|
---|
| 380 | #endif
|
---|
| 381 | }
|
---|
| 382 | }
|
---|
| 383 |
|
---|
| 384 | free( messages );
|
---|
| 385 | }
|
---|
| 386 | )
|
---|
| 387 |
|
---|
| 388 | void sigHandler_segv( __CFA_SIGPARMS__ ) {
|
---|
| 389 | LIB_DEBUG_DO(
|
---|
| 390 | #ifdef __USE_STREAM__
|
---|
| 391 | serr | "*CFA runtime error* program cfa-cpp terminated with"
|
---|
| 392 | | (sig == SIGSEGV ? "segment fault." : "bus error.")
|
---|
| 393 | | endl;
|
---|
| 394 | #else
|
---|
| 395 | fprintf( stderr, "*CFA runtime error* program cfa-cpp terminated with %s\n", sig == SIGSEGV ? "segment fault." : "bus error." );
|
---|
| 396 | #endif
|
---|
| 397 |
|
---|
| 398 | // skip first 2 stack frames
|
---|
| 399 | __kernel_backtrace( 1 );
|
---|
| 400 | )
|
---|
| 401 | exit( EXIT_FAILURE );
|
---|
[0b33412] | 402 | }
|
---|
[1c273d0] | 403 |
|
---|
| 404 | // void sigHandler_abort( __CFA_SIGPARMS__ ) {
|
---|
| 405 | // // skip first 6 stack frames
|
---|
| 406 | // LIB_DEBUG_DO( __kernel_backtrace( 6 ); )
|
---|
| 407 |
|
---|
| 408 | // // reset default signal handler
|
---|
| 409 | // __kernel_sigdefault( SIGABRT );
|
---|
| 410 |
|
---|
| 411 | // raise( SIGABRT );
|
---|
| 412 | // }
|
---|