Changes in / [695571c:10f8142]


Ignore:
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • doc/LaTeXmacros/common.tex

    r695571c r10f8142  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sun Feb  4 10:38:26 2018
    14 %% Update Count     : 365
     13%% Last Modified On : Wed Jan 31 23:10:28 2018
     14%% Update Count     : 364
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    3737
    3838\newcommand{\CFAIcon}{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
    39 \newcommand{\CFA}{\protect\CFAIcon}             % safe for section/caption
     39\newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption
    4040\newcommand{\CFL}{\textrm{Cforall}\xspace} % Cforall symbolic name
    4141\newcommand{\Celeven}{\textrm{C11}\xspace} % C11 symbolic name
     
    147147
    148148% Latin abbreviation
    149 \newcommand{\abbrevFont}{\textit}               % set empty for no italics
     149\newcommand{\abbrevFont}{\textit}       % set empty for no italics
    150150\newcommand{\EG}{\abbrevFont{e}.\abbrevFont{g}.}
    151151\newcommand*{\eg}{%
     
    215215\newcommand{\opt}{$_{opt}$\ }
    216216
    217 \usepackage{varioref}                                   % extended references
     217\usepackage{varioref}                 % extended references
    218218% adjust varioref package with default "section" and "page" titles, and optional title with faraway page numbers
    219219% \VRef{label} => Section 2.7, \VPageref{label} => page 17
     
    241241language=CFA,
    242242columns=fullflexible,
    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
     243basicstyle=\linespread{0.9}\sf,                                                 % reduce line spacing and use sanserif font
     244stringstyle=\tt,                                                                                % use typewriter font
     245tabsize=5,                                                                                              % N space tabbing
     246xleftmargin=\parindentlnth,                                                             % indent code to paragraph indentation
     247extendedchars=true,                                                                             % allow ASCII characters in the range 128-255
     248escapechar=§,                                                                                   % LaTeX escape in CFA code §...§ (section symbol), emacs: C-q M-'
     249mathescape=true,                                                                                % LaTeX math escape in CFA code $...$
     250keepspaces=true,                                                                                %
     251showstringspaces=false,                                                                 % do not show spaces with cup
     252showlines=true,                                                                                 % show blank lines at end of code
     253aboveskip=4pt,                                                                                  % spacing above/below code block
    254254belowskip=3pt,
    255255% replace/adjust listing characters that look bad in sanserif
     
    257257        {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
    258258        {<-}{$\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}]{®}{®},    % 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-^
     259moredelim=**[is][\color{red}]{®}{®},                                    % red highlighting ®...® (registered trademark symbol) emacs: C-q M-.
     260moredelim=**[is][\color{blue}]{ß}{ß},                                   % blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_
     261moredelim=**[is][\color{OliveGreen}]{¢}{¢},                     % green highlighting ¢...¢ (cent symbol) emacs: C-q M-"
     262moredelim=[is][\lstset{keywords={}}]{¶}{¶},                     % keyword escape ¶...¶ (pilcrow symbol) emacs: C-q M-^
    263263}% lstset
    264264}% CFADefaults
     
    266266\CFADefaults
    267267% inline code ©...© (copyright symbol) emacs: C-q M-)
    268 \lstMakeShortInline©                                    % single-character for \lstinline
     268\lstMakeShortInline©                                                                    % single-character for \lstinline
    269269}% CFAStyle
    270270
  • src/libcfa/bits/signal.h

    r695571c r10f8142  
    3333
    3434// Sigaction wrapper : register an signal handler
    35 static void __cfaabi_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags ) {
     35static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags ) {
    3636        struct sigaction act;
    3737
     
    4141        if ( sigaction( sig, &act, NULL ) == -1 ) {
    4242                __cfaabi_dbg_print_buffer_decl(
    43                         " __cfaabi_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",
     43                        " __kernel_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",
    4444                        sig, handler, flags, errno, strerror( errno )
    4545                );
     
    4949
    5050// Sigaction wrapper : restore default handler
    51 static void __cfaabi_sigdefault( int sig ) {
     51static void __kernel_sigdefault( int sig ) {
    5252        struct sigaction act;
    5353
     
    5858        if ( sigaction( sig, &act, NULL ) == -1 ) {
    5959                __cfaabi_dbg_print_buffer_decl(
    60                         " __cfaabi_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",
     60                        " __kernel_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",
    6161                        sig, errno, strerror( errno )
    6262                );
  • src/libcfa/concurrency/invoke.c

    r695571c r10f8142  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  6 23:00:57 2018
    13 // Update Count     : 3
     12// Last Modified On : Tue Jan 23 14:04:56 2018
     13// Update Count     : 2
    1414//
    1515
     
    5151        //Final suspend, should never return
    5252        __leave_coroutine();
    53         abortf( "Resumed dead coroutine" );
     53        abortf("Resumed dead coroutine");
    5454}
    5555
     
    8181        //Final suspend, should never return
    8282        __leave_thread_monitor( thrd );
    83         abortf( "Resumed dead thread" );
     83        abortf("Resumed dead thread");
    8484}
    8585
  • src/libcfa/concurrency/kernel.c

    r695571c r10f8142  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  6 21:51:26 2018
    13 // Update Count     : 4
     12// Last Modified On : Fri Dec  8 16:23:33 2017
     13// Update Count     : 3
    1414//
    1515
     
    588588}
    589589
    590 int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__)) {
    591         return get_coroutine(this_thread) == get_coroutine(mainThread) ? 4 : 2;
    592 }
    593 
    594590extern "C" {
    595591        void __cfaabi_dbg_bits_acquire() {
  • src/libcfa/concurrency/preemption.c

    r695571c r10f8142  
    1010// Created On       : Mon Jun 5 14:20:42 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  6 15:00:36 2018
    13 // Update Count     : 10
     12// Last Modified On : Tue Jan 23 17:59:30 2018
     13// Update Count     : 7
    1414//
    1515
     
    4242void sigHandler_ctxSwitch( __CFA_SIGPARMS__ );
    4343void sigHandler_segv     ( __CFA_SIGPARMS__ );
    44 void sigHandler_ill      ( __CFA_SIGPARMS__ );
    45 void sigHandler_fpe      ( __CFA_SIGPARMS__ );
    4644void sigHandler_abort    ( __CFA_SIGPARMS__ );
    4745
     
    245243
    246244        // Setup proper signal handlers
    247         __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART );         // CtxSwitch handler
     245        __kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART );         // CtxSwitch handler
    248246
    249247        signal_block( SIGALRM );
  • src/libcfa/interpose.c

    r695571c r10f8142  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  7 09:05:18 2018
    13 // Update Count     : 59
     12// Last Modified On : Mon Feb  5 23:40:04 2018
     13// Update Count     : 17
    1414//
    1515
     
    8888
    8989void sigHandler_segv ( __CFA_SIGPARMS__ );
    90 void sigHandler_ill  ( __CFA_SIGPARMS__ );
    91 void sigHandler_fpe  ( __CFA_SIGPARMS__ );
    9290void sigHandler_abort( __CFA_SIGPARMS__ );
    9391
     
    10098                INIT_REALRTN( exit, version );
    10199
    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
     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
    107103        }
    108104}
     
    122118}
    123119
    124 void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    125         va_list argp;
    126         va_start( argp, fmt );
     120void abort( const char *fmt, va_list argp ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    127121        abortf( fmt, argp );
    128         va_end( argp );
    129122}
    130123
    131124void * kernel_abort    ( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return NULL; }
    132125void   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; }
    134126
    135127enum { abort_text_size = 1024 };
    136128static char abort_text[ abort_text_size ];
    137 static int abort_lastframe;
    138129
    139130extern "C" {
    140131        void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    141                 void * kernel_data = kernel_abort();                    // must be done here to lock down kernel
     132                void * kernel_data = kernel_abort();
     133
    142134                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 );
    147135
    148136                if ( fmt ) {
     
    151139
    152140                        len = vsnprintf( abort_text, abort_text_size, fmt, args );
     141
    153142                        va_end( args );
     143
    154144                        __cfaabi_dbg_bits_write( abort_text, len );
    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                 }
     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
    160151
    161152                kernel_abort_msg( kernel_data, abort_text, abort_text_size );
     153
    162154                libc_abort();
    163155        }
    164156}
    165157
    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 
     158// skip first 6 stack frames by default
     159static void __kernel_backtrace() {
     160        // skip first N stack frames
     161        int start = 6;
     162
     163        enum { Frames = 50 };
    172164        void * array[Frames];
    173165        size_t size = backtrace( array, Frames );
     
    178170        __cfaabi_dbg_bits_print_nolock( "Stack back trace for: %s\n", messages[0]);
    179171
    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 ) {
     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 ) {
    184179                        //__cfaabi_dbg_bits_print_nolock( "X %s\n", p);
    185180                        // find parantheses and +offset
     
    197192
    198193                // if line contains symbol print it
    199                 int frameNo = i - Start;
     194                int frameNo = i - start;
    200195                if ( name && offset_begin && offset_end && name < offset_begin ) {
    201196                        // delimit strings
     
    211206                }
    212207        }
     208
    213209        free( messages );
    214210}
    215211
    216212void sigHandler_segv( __CFA_SIGPARMS__ ) {
    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 );
     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." );
    240215}
    241216
    242217void sigHandler_abort( __CFA_SIGPARMS__ ) {
    243         __cfaabi_backtrace();
     218        __kernel_backtrace();
    244219
    245220        // reset default signal handler
    246         __cfaabi_sigdefault( SIGABRT );
     221        __kernel_sigdefault( SIGABRT );
    247222
    248223        raise( SIGABRT );
Note: See TracChangeset for help on using the changeset viewer.