Changes in / [10f8142:695571c]


Ignore:
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • doc/LaTeXmacros/common.tex

    r10f8142 r695571c  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Wed Jan 31 23:10:28 2018
    14 %% Update Count     : 364
     13%% Last Modified On : Sun Feb  4 10:38:26 2018
     14%% Update Count     : 365
    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

    r10f8142 r695571c  
    3333
    3434// Sigaction wrapper : register an signal handler
    35 static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags ) {
     35static void __cfaabi_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                         " __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",
    4444                        sig, handler, flags, errno, strerror( errno )
    4545                );
     
    4949
    5050// Sigaction wrapper : restore default handler
    51 static void __kernel_sigdefault( int sig ) {
     51static void __cfaabi_sigdefault( int sig ) {
    5252        struct sigaction act;
    5353
     
    5858        if ( sigaction( sig, &act, NULL ) == -1 ) {
    5959                __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",
    6161                        sig, errno, strerror( errno )
    6262                );
  • src/libcfa/concurrency/invoke.c

    r10f8142 r695571c  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan 23 14:04:56 2018
    13 // Update Count     : 2
     12// Last Modified On : Tue Feb  6 23:00:57 2018
     13// Update Count     : 3
    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

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

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

    r10f8142 r695571c  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb  5 23:40:04 2018
    13 // Update Count     : 17
     12// Last Modified On : Wed Feb  7 09:05:18 2018
     13// Update Count     : 59
    1414//
    1515
     
    8888
    8989void sigHandler_segv ( __CFA_SIGPARMS__ );
     90void sigHandler_ill  ( __CFA_SIGPARMS__ );
     91void sigHandler_fpe  ( __CFA_SIGPARMS__ );
    9092void sigHandler_abort( __CFA_SIGPARMS__ );
    9193
     
    98100                INIT_REALRTN( exit, version );
    99101
    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
    103107        }
    104108}
     
    118122}
    119123
    120 void abort( const char *fmt, va_list argp ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
     124void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
     125        va_list argp;
     126        va_start( argp, fmt );
    121127        abortf( fmt, argp );
     128        va_end( argp );
    122129}
    123130
    124131void * kernel_abort    ( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return NULL; }
    125132void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ ((__nothrow__, __leaf__, __weak__)) {}
     133int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return 4; }
    126134
    127135enum { abort_text_size = 1024 };
    128136static char abort_text[ abort_text_size ];
     137static int abort_lastframe;
    129138
    130139extern "C" {
    131140        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
    134142                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 );
    135147
    136148                if ( fmt ) {
     
    139151
    140152                        len = vsnprintf( abort_text, abort_text_size, fmt, args );
    141 
    142153                        va_end( args );
    143 
    144154                        __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                }
    151160
    152161                kernel_abort_msg( kernel_data, abort_text, abort_text_size );
    153 
    154162                libc_abort();
    155163        }
    156164}
    157165
    158 // skip first 6 stack frames by default
    159 static void __kernel_backtrace() {
    160         // skip first N stack frames
    161         int start = 6;
    162 
    163         enum { Frames = 50 };
     166static void __cfaabi_backtrace() {
     167        enum {
     168                Frames = 50,                                                                    // maximum number of stack frames
     169                Start = 8,                                                                              // skip first N stack frames
     170        };
     171
    164172        void * array[Frames];
    165173        size_t size = backtrace( array, Frames );
     
    170178        __cfaabi_dbg_bits_print_nolock( "Stack back trace for: %s\n", messages[0]);
    171179
    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 ) {
    179184                        //__cfaabi_dbg_bits_print_nolock( "X %s\n", p);
    180185                        // find parantheses and +offset
     
    192197
    193198                // if line contains symbol print it
    194                 int frameNo = i - start;
     199                int frameNo = i - Start;
    195200                if ( name && offset_begin && offset_end && name < offset_begin ) {
    196201                        // delimit strings
     
    206211                }
    207212        }
    208 
    209213        free( messages );
    210214}
    211215
    212216void 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
     222void 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
     228void 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 );
    215240}
    216241
    217242void sigHandler_abort( __CFA_SIGPARMS__ ) {
    218         __kernel_backtrace();
     243        __cfaabi_backtrace();
    219244
    220245        // reset default signal handler
    221         __kernel_sigdefault( SIGABRT );
     246        __cfaabi_sigdefault( SIGABRT );
    222247
    223248        raise( SIGABRT );
Note: See TracChangeset for help on using the changeset viewer.