Changeset 695571c
- Timestamp:
- Feb 7, 2018, 9:59:03 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 0723a57, 5f4f31f
- Parents:
- 10f8142 (diff), a424315d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/LaTeXmacros/common.tex
r10f8142 r695571c 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Wed Jan 31 23:10:28201814 %% Update Count : 36 413 %% Last Modified On : Sun Feb 4 10:38:26 2018 14 %% Update Count : 365 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 37 37 38 38 \newcommand{\CFAIcon}{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name 39 \newcommand{\CFA}{\protect\CFAIcon} 39 \newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption 40 40 \newcommand{\CFL}{\textrm{Cforall}\xspace} % Cforall symbolic name 41 41 \newcommand{\Celeven}{\textrm{C11}\xspace} % C11 symbolic name … … 147 147 148 148 % Latin abbreviation 149 \newcommand{\abbrevFont}{\textit} % set empty for no italics149 \newcommand{\abbrevFont}{\textit} % set empty for no italics 150 150 \newcommand{\EG}{\abbrevFont{e}.\abbrevFont{g}.} 151 151 \newcommand*{\eg}{% … … 215 215 \newcommand{\opt}{$_{opt}$\ } 216 216 217 \usepackage{varioref} 217 \usepackage{varioref} % extended references 218 218 % adjust varioref package with default "section" and "page" titles, and optional title with faraway page numbers 219 219 % \VRef{label} => Section 2.7, \VPageref{label} => page 17 … … 241 241 language=CFA, 242 242 columns=fullflexible, 243 basicstyle=\linespread{0.9}\sf, 244 stringstyle=\tt, 245 tabsize=5, 246 xleftmargin=\parindentlnth, 247 extendedchars=true, 248 escapechar=§, 249 mathescape=true, 250 keepspaces=true, 251 showstringspaces=false, 252 showlines=true, 253 aboveskip=4pt, 243 basicstyle=\linespread{0.9}\sf, % reduce line spacing and use sanserif font 244 stringstyle=\tt, % use typewriter font 245 tabsize=5, % N space tabbing 246 xleftmargin=\parindentlnth, % indent code to paragraph indentation 247 extendedchars=true, % allow ASCII characters in the range 128-255 248 escapechar=§, % LaTeX escape in CFA code §...§ (section symbol), emacs: C-q M-' 249 mathescape=true, % LaTeX math escape in CFA code $...$ 250 keepspaces=true, % 251 showstringspaces=false, % do not show spaces with cup 252 showlines=true, % show blank lines at end of code 253 aboveskip=4pt, % spacing above/below code block 254 254 belowskip=3pt, 255 255 % replace/adjust listing characters that look bad in sanserif … … 257 257 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1 258 258 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2, 259 moredelim=**[is][\color{red}]{®}{®}, 260 moredelim=**[is][\color{blue}]{ß}{ß}, 261 moredelim=**[is][\color{OliveGreen}]{¢}{¢}, 262 moredelim=[is][\lstset{keywords={}}]{¶}{¶}, 259 moredelim=**[is][\color{red}]{®}{®}, % red highlighting ®...® (registered trademark symbol) emacs: C-q M-. 260 moredelim=**[is][\color{blue}]{ß}{ß}, % blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_ 261 moredelim=**[is][\color{OliveGreen}]{¢}{¢}, % green highlighting ¢...¢ (cent symbol) emacs: C-q M-" 262 moredelim=[is][\lstset{keywords={}}]{¶}{¶}, % keyword escape ¶...¶ (pilcrow symbol) emacs: C-q M-^ 263 263 }% lstset 264 264 }% CFADefaults … … 266 266 \CFADefaults 267 267 % inline code ©...© (copyright symbol) emacs: C-q M-) 268 \lstMakeShortInline© 268 \lstMakeShortInline© % single-character for \lstinline 269 269 }% CFAStyle 270 270 -
src/libcfa/bits/signal.h
r10f8142 r695571c 33 33 34 34 // Sigaction wrapper : register an signal handler 35 static void __ kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags ) {35 static void __cfaabi_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags ) { 36 36 struct sigaction act; 37 37 … … 41 41 if ( sigaction( sig, &act, NULL ) == -1 ) { 42 42 __cfaabi_dbg_print_buffer_decl( 43 " __ kernel_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",43 " __cfaabi_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n", 44 44 sig, handler, flags, errno, strerror( errno ) 45 45 ); … … 49 49 50 50 // Sigaction wrapper : restore default handler 51 static void __ kernel_sigdefault( int sig ) {51 static void __cfaabi_sigdefault( int sig ) { 52 52 struct sigaction act; 53 53 … … 58 58 if ( sigaction( sig, &act, NULL ) == -1 ) { 59 59 __cfaabi_dbg_print_buffer_decl( 60 " __ kernel_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",60 " __cfaabi_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n", 61 61 sig, errno, strerror( errno ) 62 62 ); -
src/libcfa/concurrency/invoke.c
r10f8142 r695571c 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jan 23 14:04:56201813 // Update Count : 212 // Last Modified On : Tue Feb 6 23:00:57 2018 13 // Update Count : 3 14 14 // 15 15 … … 51 51 //Final suspend, should never return 52 52 __leave_coroutine(); 53 abortf( "Resumed dead coroutine");53 abortf( "Resumed dead coroutine" ); 54 54 } 55 55 … … 81 81 //Final suspend, should never return 82 82 __leave_thread_monitor( thrd ); 83 abortf( "Resumed dead thread");83 abortf( "Resumed dead thread" ); 84 84 } 85 85 -
src/libcfa/concurrency/kernel.c
r10f8142 r695571c 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 8 16:23:33 201713 // Update Count : 312 // Last Modified On : Tue Feb 6 21:51:26 2018 13 // Update Count : 4 14 14 // 15 15 … … 588 588 } 589 589 590 int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__)) { 591 return get_coroutine(this_thread) == get_coroutine(mainThread) ? 4 : 2; 592 } 593 590 594 extern "C" { 591 595 void __cfaabi_dbg_bits_acquire() { -
src/libcfa/concurrency/preemption.c
r10f8142 r695571c 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jan 23 17:59:30201813 // Update Count : 712 // Last Modified On : Tue Feb 6 15:00:36 2018 13 // Update Count : 10 14 14 // 15 15 … … 42 42 void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ); 43 43 void sigHandler_segv ( __CFA_SIGPARMS__ ); 44 void sigHandler_ill ( __CFA_SIGPARMS__ ); 45 void sigHandler_fpe ( __CFA_SIGPARMS__ ); 44 46 void sigHandler_abort ( __CFA_SIGPARMS__ ); 45 47 … … 243 245 244 246 // Setup proper signal handlers 245 __ kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART ); // CtxSwitch handler247 __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART ); // CtxSwitch handler 246 248 247 249 signal_block( SIGALRM ); -
src/libcfa/interpose.c
r10f8142 r695571c 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 5 23:40:04201813 // Update Count : 1712 // Last Modified On : Wed Feb 7 09:05:18 2018 13 // Update Count : 59 14 14 // 15 15 … … 88 88 89 89 void sigHandler_segv ( __CFA_SIGPARMS__ ); 90 void sigHandler_ill ( __CFA_SIGPARMS__ ); 91 void sigHandler_fpe ( __CFA_SIGPARMS__ ); 90 92 void sigHandler_abort( __CFA_SIGPARMS__ ); 91 93 … … 98 100 INIT_REALRTN( exit, version ); 99 101 100 __kernel_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO ); // Failure handler 101 __kernel_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO ); // Failure handler 102 __kernel_sigaction( SIGABRT, sigHandler_abort, SA_SIGINFO ); // Failure handler 102 __cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO ); // Failure handler 103 __cfaabi_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO ); // Failure handler 104 __cfaabi_sigaction( SIGILL , sigHandler_ill , SA_SIGINFO ); // Failure handler 105 __cfaabi_sigaction( SIGFPE , sigHandler_fpe , SA_SIGINFO ); // Failure handler 106 __cfaabi_sigaction( SIGABRT, sigHandler_abort, SA_SIGINFO ); // Failure handler 103 107 } 104 108 } … … 118 122 } 119 123 120 void abort( const char *fmt, va_list argp ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 124 void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 125 va_list argp; 126 va_start( argp, fmt ); 121 127 abortf( fmt, argp ); 128 va_end( argp ); 122 129 } 123 130 124 131 void * kernel_abort ( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return NULL; } 125 132 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ ((__nothrow__, __leaf__, __weak__)) {} 133 int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return 4; } 126 134 127 135 enum { abort_text_size = 1024 }; 128 136 static char abort_text[ abort_text_size ]; 137 static int abort_lastframe; 129 138 130 139 extern "C" { 131 140 void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 132 void * kernel_data = kernel_abort(); 133 141 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 134 142 int len; 143 144 abort_lastframe = kernel_abort_lastframe(); 145 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid) 146 __cfaabi_dbg_bits_write( abort_text, len ); 135 147 136 148 if ( fmt ) { … … 139 151 140 152 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 141 142 153 va_end( args ); 143 144 154 __cfaabi_dbg_bits_write( abort_text, len ); 145 //__cfaabi_dbg_bits_write( "\n", 1 ); 146 } 147 148 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld)\n", (long int)getpid() ); // use UNIX pid (versus getPid) 149 __cfaabi_dbg_bits_write( abort_text, len ); 150 155 156 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 157 __cfaabi_dbg_bits_write( "\n", 1 ); 158 } 159 } 151 160 152 161 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); 153 154 162 libc_abort(); 155 163 } 156 164 } 157 165 158 // skip first 6 stack frames by default 159 static void __kernel_backtrace(){160 // skip first Nstack frames161 int start = 6;162 163 enum { Frames = 50 }; 166 static void __cfaabi_backtrace() { 167 enum { 168 Frames = 50, // maximum number of stack frames 169 Start = 8, // skip first N stack frames 170 }; 171 164 172 void * array[Frames]; 165 173 size_t size = backtrace( array, Frames ); … … 170 178 __cfaabi_dbg_bits_print_nolock( "Stack back trace for: %s\n", messages[0]); 171 179 172 // skip last 2 stack frames after main 173 for ( int i = start; i < size && messages != NULL; i += 1 ) { 174 char * name = NULL; 175 char * offset_begin = NULL; 176 char * offset_end = NULL; 177 178 for ( char *p = messages[i]; *p; ++p ) { 180 for ( int i = Start; i < size - abort_lastframe && messages != NULL; i += 1 ) { 181 char * name = NULL, * offset_begin = NULL, * offset_end = NULL; 182 183 for ( char * p = messages[i]; *p; ++p ) { 179 184 //__cfaabi_dbg_bits_print_nolock( "X %s\n", p); 180 185 // find parantheses and +offset … … 192 197 193 198 // if line contains symbol print it 194 int frameNo = i - start;199 int frameNo = i - Start; 195 200 if ( name && offset_begin && offset_end && name < offset_begin ) { 196 201 // delimit strings … … 206 211 } 207 212 } 208 209 213 free( messages ); 210 214 } 211 215 212 216 void sigHandler_segv( __CFA_SIGPARMS__ ) { 213 // skip first only 1 stack frames in case of segfault. 214 abortf( "*CFA runtime error* program cfa-cpp terminated with %s\n", sig == SIGSEGV ? "segment fault." : "bus error." ); 217 abortf( "Addressing invalid memory at location %p\n" 218 "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n", 219 sfp->si_addr ); 220 } 221 222 void sigHandler_ill( __CFA_SIGPARMS__ ) { 223 abortf( "Executing illegal instruction at location %p.\n" 224 "Possible cause is stack corruption.\n", 225 sfp->si_addr ); 226 } 227 228 void sigHandler_fpe( __CFA_SIGPARMS__ ) { 229 const char * msg; 230 231 choose( sfp->si_code ) { 232 case FPE_INTDIV, FPE_FLTDIV: msg = "divide by zero"; 233 case FPE_FLTOVF: msg = "overflow"; 234 case FPE_FLTUND: msg = "underflow"; 235 case FPE_FLTRES: msg = "inexact result"; 236 case FPE_FLTINV: msg = "invalid operation"; 237 default: msg = "unknown"; 238 } // choose 239 abortf( "Computation error %s at location %p.\n", msg, sfp->si_addr ); 215 240 } 216 241 217 242 void sigHandler_abort( __CFA_SIGPARMS__ ) { 218 __ kernel_backtrace();243 __cfaabi_backtrace(); 219 244 220 245 // reset default signal handler 221 __ kernel_sigdefault( SIGABRT );246 __cfaabi_sigdefault( SIGABRT ); 222 247 223 248 raise( SIGABRT );
Note: See TracChangeset
for help on using the changeset viewer.