/* error_logf() * Prints the arguments to stderr or syslog * Works like printf (see vfprintf) */ void erts_run_erl_log_error(int priority, int line, const char *format, ...) { va_list args; va_start(args, format); #ifdef HAVE_SYSLOG_H if (RUN_DAEMON) { vsyslog(priority,format,args); } else #endif #ifdef __OSE__ if (RUN_DAEMON) { char *buff = malloc(sizeof(char)*1024); vsnprintf(buff,1024,format, args); ramlog_printf(buff); } else #endif { time_t now = time(NULL); fprintf(stderr, "run_erl:%d [%d] %s", line, #ifdef __OSE__ (int)current_process(), #else (int)getpid(), #endif ctime(&now)); vfprintf(stderr, format, args); } va_end(args); }
int ethr_assert_failed(const char *file, int line, const char *func, char *a) { fprintf(stderr, "%s:%d: %s(): Assertion failed: %s\n", file, line, func, a); #ifdef __OSE__ ramlog_printf("%d: %s:%d: %s(): Assertion failed: %s\n", current_process(),file, line, func, a); #endif ethr_abort__(); return 0; }
Val make_mythryl_signal_handler_arg ( // Called only from handle-interprocess-signal code in src/c/main/run-mythryl-code-and-runtime-eventloop.c //=============================== // Task* task, Val* resume_after_handling_signal ){ // We're handling an interprocess signal for // // src/c/main/run-mythryl-code-and-runtime-eventloop.c // // Depending on platform, resume_after_handling_signal // is from one of // src/c/machine-dependent/prim.intel32.asm // src/c/machine-dependent/prim.intel32.masm // src/c/machine-dependent/prim.sun.asm // src/c/machine-dependent/prim.pwrpc32.asm // // Our job is to build the Mythryl argument record for // the Mythryl signal handler. The handler has type // // posix_interprocess_signal_handler : (Int, Int, Fate(Void)) -> X // // where // The first argument is the signal id // For example SIGALRM, // the second argument is the signal count // I.e., number of times signal has been recieved since last handled. // the third argument is the resumption fate. // // The return type is X because the Mythryl // signal handler should never return. // // NOTE: Maybe this should be combined with choose_signal??? XXX BUGGO FIXME Hostthread* hostthread = task->hostthread; Val run_fate = make_posthandler_resumption_fate_from_task( task, resume_after_handling_signal ); // Allocate the Mythryl signal handler's argument record: // Val arg = make_three_slot_record( task, // TAGGED_INT_FROM_C_INT( hostthread->next_posix_signal_id ), TAGGED_INT_FROM_C_INT( hostthread->next_posix_signal_count ), run_fate ); if (hostthread->next_posix_signal_id == 2 /*SIGINT*/) ramlog_printf("#%d make_mythryl_signal_handler_arg: hostthread->next_posix_signal_id==SIGINT\n", syscalls_seen ); #ifdef SIGNAL_DEBUG debug_say( "make_mythryl_signal_handler_arg: resumeC = %#x, arg = %#x\n", run_fate, arg ); #endif return arg; }
static int erts_sys_ramlog_printf(char *format, va_list arg_list) { int res,i; erts_dsprintf_buf_t dsbuf = ERTS_DSPRINTF_BUF_INITER(grow_vprintf_buf); res = erts_vdsprintf(&dsbuf, format, arg_list); if (res >= 0) { for (i = 0; i < dsbuf.str_len; i+= 50) /* We print 50 characters at a time because otherwise the ramlog looks broken */ ramlog_printf("%.*s",dsbuf.str_len-50 < 0?dsbuf.str_len:50,dsbuf.str+i); } if (dsbuf.str) free((void *) dsbuf.str); return res; }