Changeset 44aad8f for libcfa/src


Ignore:
Timestamp:
Apr 27, 2020, 4:36:58 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c59a346
Parents:
038be32 (diff), c680a4b (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.in

    r038be32 r44aad8f  
    105105        $(am__nobase_cfa_include_HEADERS_DIST) $(am__DIST_COMMON)
    106106mkinstalldirs = $(install_sh) -d
     107CONFIG_HEADER = $(top_builddir)/prelude/defines.hfa
    107108CONFIG_CLEAN_FILES =
    108109CONFIG_CLEAN_VPATH_FILES =
     
    194195am__v_at_0 = @
    195196am__v_at_1 =
    196 DEFAULT_INCLUDES = -I.@am__isrc@
     197DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/prelude
    197198depcomp = $(SHELL) $(top_srcdir)/automake/depcomp
    198199am__depfiles_maybe = depfiles
  • libcfa/src/bits/debug.hfa

    r038be32 r44aad8f  
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  4 12:29:21 2020
    13 // Update Count     : 9
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Apr 27 10:15:00 2020
     13// Update Count     : 10
    1414//
    1515
     
    4040#endif
    4141        #include <stdarg.h>
    42         #include <stdio.h>
    4342
    4443        extern void __cfaabi_bits_write( int fd, const char buffer[], int len );
     
    4948        extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg );
    5049        extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) ));
     50
     51#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__) \
     52                || defined(__CFA_DEBUG_PRINT_MONITOR__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__) \
     53                || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__)
     54        #include <stdio.h>
     55        #include <unistd.h>
     56#endif
    5157#ifdef __cforall
    5258}
    5359#endif
    5460
     61// Deprecated: Use the versions with the new module names.
    5562#ifdef __CFA_DEBUG_PRINT__
    5663        #define __cfaabi_dbg_write( buffer, len )         __cfaabi_bits_write( STDERR_FILENO, buffer, len )
    5764        #define __cfaabi_dbg_acquire()                    __cfaabi_bits_acquire()
    5865        #define __cfaabi_dbg_release()                    __cfaabi_bits_release()
    59         #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   (__VA_ARGS__)
    60         #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock (__VA_ARGS__)
    61         #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer (__VA_ARGS__)
    62         #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len );
    63         #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( __dbg_text, __dbg_len );
     66        #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   ( STDERR_FILENO, __VA_ARGS__ )
     67        #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock ( STDERR_FILENO, __VA_ARGS__ )
     68        #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer ( STDERR_FILENO, __VA_ARGS__ )
     69        #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( STDERR_FILENO, __dbg_text, __dbg_len );
     70        #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( STDERR_FILENO, __dbg_text, __dbg_len );
    6471#else
    6572        #define __cfaabi_dbg_write(...)               ((void)0)
     
    7380#endif
    7481
     82// Debug print functions and statements:
     83// Most are wrappers around the bits printing function but are not always used.
     84// If they are used depends if the group (first argument) is active or not. The group must be one
     85// defined belowe. The other arguments depend on the wrapped function.
     86#define __cfadbg_write(group, buffer, len) \
     87        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_write(STDERR_FILENO, buffer, len))
     88#define __cfadbg_acquire(group) \
     89        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_acquire())
     90#define __cfadbg_release(group) \
     91        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_release())
     92#define __cfadbg_print_safe(group, ...) \
     93        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_safe(STDERR_FILENO, __VA_ARGS__))
     94#define __cfadbg_print_nolock(group, ...) \
     95        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_nolock(STDERR_FILENO, __VA_ARGS__))
     96#define __cfadbg_print_buffer(group, ...) \
     97        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_buffer(STDERR_FILENO, __VA_ARGS__))
     98#define __cfadbg_print_buffer_decl(group, ...) \
     99        __CFADBG_PRINT_GROUP_##group(char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len ))
     100#define __cfadbg_print_buffer_local(group, ...) \
     101        __CFADBG_PRINT_GROUP_##group(__dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write(STDERR_FILENO, __dbg_text, __dbg_len))
     102
     103// The debug print groups:
     104#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__)
     105#       define __CFADBG_PRINT_GROUP_io(...) __VA_ARGS__
     106#else
     107#       define __CFADBG_PRINT_GROUP_io(...) ((void)0)
     108#endif
     109#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_MONITOR__)
     110#       define __CFADBG_PRINT_GROUP_monitor(...) __VA_ARGS__
     111#else
     112#       define __CFADBG_PRINT_GROUP_monitor(...) ((void)0)
     113#endif
     114#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__)
     115#       define __CFADBG_PRINT_GROUP_preemption(...) __VA_ARGS__
     116#else
     117#       define __CFADBG_PRINT_GROUP_preemption(...) ((void)0)
     118#endif
     119#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__)
     120#       define __CFADBG_PRINT_GROUP_runtime_core(...) __VA_ARGS__
     121#else
     122#       define __CFADBG_PRINT_GROUP_runtime_core(...) ((void)0)
     123#endif
     124#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_READY_QUEUE__)
     125#       define __CFADBG_PRINT_GROUP_ready_queue(...) __VA_ARGS__
     126#else
     127#       define __CFADBG_PRINT_GROUP_ready_queue(...) ((void)0)
     128#endif
     129#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__)
     130#       define __CFADBG_PRINT_GROUP_exception(...) __VA_ARGS__
     131#else
     132#       define __CFADBG_PRINT_GROUP_exception(...) ((void)0)
     133#endif
     134
    75135// Local Variables: //
    76136// mode: c //
  • libcfa/src/exception.c

    r038be32 r44aad8f  
    8383        struct exception_context_t * context = this_exception_context();
    8484
    85         __cfaabi_dbg_print_safe("Throwing resumption exception\n");
     85        __cfadbg_print_safe(exception, "Throwing resumption exception\n");
    8686
    8787        __attribute__((cleanup(reset_top_resume)))
     
    9696        }
    9797
    98         __cfaabi_dbg_print_safe("Unhandled exception\n");
     98        __cfadbg_print_safe(exception, "Unhandled exception\n");
    9999
    100100        // Fall back to termination:
     
    180180        struct exception_context_t * context = this_exception_context();
    181181
    182         __cfaabi_dbg_print_safe("Deleting Exception\n");
     182        __cfadbg_print_safe(exception, "Deleting Exception\n");
    183183
    184184        // Remove the exception from the list.
     
    218218                void * stop_param) {
    219219        // Verify actions follow the rules we expect.
    220         verify((actions & _UA_CLEANUP_PHASE) && actions & (_UA_FORCE_UNWIND));
     220        verify((actions & _UA_CLEANUP_PHASE) && (actions & _UA_FORCE_UNWIND));
    221221        verify(!(actions & (_UA_SEARCH_PHASE | _UA_HANDER_FRAME)));
    222222
     
    261261
    262262void __cfaehm_throw_terminate( exception_t * val ) {
    263         __cfaabi_dbg_print_safe("Throwing termination exception\n");
     263        __cfadbg_print_safe(exception, "Throwing termination exception\n");
    264264
    265265        __cfaehm_allocate_exception( val );
     
    268268
    269269void __cfaehm_rethrow_terminate(void) {
    270         __cfaabi_dbg_print_safe("Rethrowing termination exception\n");
     270        __cfadbg_print_safe(exception, "Rethrowing termination exception\n");
    271271
    272272        __cfaehm_begin_unwind();
     
    284284{
    285285
    286         //__cfaabi_dbg_print_safe("CFA: 0x%lx\n", _Unwind_GetCFA(context));
    287         __cfaabi_dbg_print_safe("Personality function (%d, %x, %llu, %p, %p):",
     286        //__cfadbg_print_safe(exception, "CFA: 0x%lx\n", _Unwind_GetCFA(context));
     287        __cfadbg_print_safe(exception, "Personality function (%d, %x, %llu, %p, %p):",
    288288                        version, actions, exception_class, unwind_exception, unwind_context);
    289289
     
    294294        if (actions & _UA_SEARCH_PHASE) {
    295295                verify(actions == _UA_SEARCH_PHASE);
    296                 __cfaabi_dbg_print_safe(" lookup phase");
     296                __cfadbg_print_safe(exception, " lookup phase");
    297297        // ... we are in clean-up phase.
    298298        } else {
    299299                verify(actions & _UA_CLEANUP_PHASE);
    300                 __cfaabi_dbg_print_safe(" cleanup phase");
     300                __cfadbg_print_safe(exception, " cleanup phase");
    301301                // We shouldn't be the handler frame during forced unwind.
    302302                if (actions & _UA_HANDLER_FRAME) {
    303303                        verify(!(actions & _UA_FORCE_UNWIND));
    304                         __cfaabi_dbg_print_safe(" (handler frame)");
     304                        __cfadbg_print_safe(exception, " (handler frame)");
    305305                } else if (actions & _UA_FORCE_UNWIND) {
    306                         __cfaabi_dbg_print_safe(" (force unwind)");
     306                        __cfadbg_print_safe(exception, " (force unwind)");
    307307                }
    308308        }
     
    345345                        void * ep = (void*)lsd_info.Start + callsite_start + callsite_len;
    346346                        void * ip = (void*)instruction_ptr;
    347                         __cfaabi_dbg_print_safe("\nfound %p - %p (%p, %p, %p), looking for %p\n",
     347                        __cfadbg_print_safe(exception, "\nfound %p - %p (%p, %p, %p), looking for %p\n",
    348348                                        bp, ep, ls, cs, cl, ip);
    349349#endif // __CFA_DEBUG_PRINT__
     
    360360                if ( 0 == callsite_landing_pad ) {
    361361                        // Nothing to do, move along
    362                         __cfaabi_dbg_print_safe(" no landing pad");
     362                        __cfadbg_print_safe(exception, " no landing pad");
    363363                } else if (actions & _UA_SEARCH_PHASE) {
    364364                        // In search phase, these means we found a potential handler we must check.
     
    398398                                // Based on the return value, check if we matched the exception
    399399                                if (ret == _URC_HANDLER_FOUND) {
    400                                         __cfaabi_dbg_print_safe(" handler found\n");
     400                                        __cfadbg_print_safe(exception, " handler found\n");
    401401                                } else {
    402                                         __cfaabi_dbg_print_safe(" no handler\n");
     402                                        __cfadbg_print_safe(exception, " no handler\n");
    403403                                }
    404404                                return ret;
     
    406406
    407407                        // This is only a cleanup handler, ignore it
    408                         __cfaabi_dbg_print_safe(" no action");
     408                        __cfadbg_print_safe(exception, " no action");
    409409                } else {
    410410                        // In clean-up phase, no destructors here but this could be the handler.
     
    428428                        _Unwind_SetIP( unwind_context, ((lsd_info.LPStart) + (callsite_landing_pad)) );
    429429
    430                         __cfaabi_dbg_print_safe(" action\n");
     430                        __cfadbg_print_safe(exception, " action\n");
    431431
    432432                        // Return have some action to run
     
    435435        }
    436436        // No handling found
    437         __cfaabi_dbg_print_safe(" table end reached\n");
     437        __cfadbg_print_safe(exception, " table end reached");
    438438
    439439        UNWIND:
    440         __cfaabi_dbg_print_safe(" unwind\n");
     440        __cfadbg_print_safe(exception, " unwind\n");
    441441
    442442        // Keep unwinding the stack
  • libcfa/src/interpose.cfa

    r038be32 r44aad8f  
    1515
    1616#include <stdarg.h>                                                                             // va_start, va_end
     17#include <stdio.h>
    1718#include <string.h>                                                                             // strlen
    1819#include <unistd.h>                                                                             // _exit, getpid
  • libcfa/src/iostream.cfa

    r038be32 r44aad8f  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr 22 10:50:46 2020
    13 // Update Count     : 933
     12// Last Modified On : Sun Apr 26 20:31:36 2020
     13// Update Count     : 985
    1414//
    1515
     
    565565                                fmt2.flags.pad0 = fmt2.flags.nobsdp = true;     \
    566566                                if ( f.base == 'b' | f.base == 'B' ) { \
    567                                         if ( fmt.flags.pc && fmt.pc > 64 ) fmt.pc -= 64; \
     567                                        if ( fmt.flags.pc && fmt.pc > 64 ) fmt.pc -= 64; else { fmt.flags.pc = false; fmt.pc = 0; } \
    568568                                        if ( fmt.flags.left ) { \
    569569                                                fmt2.wd = fmt.wd; \
     
    584584                                                printf( "left %d %d %x\n", fmt.wd, fmt.pc, fmt.all ); \
    585585                                        } else { \
     586                                                if ( fmt.wd > 64 ) fmt.wd -= 64; \
     587                                                /* if ( ! fmt.flags.nobsdp && fmt.pc < fmt.wd ) fmt.wd -= 1; */ \
    586588                                                fmt2.wd = 64; \
    587                                                 if ( fmt.wd > 64 ) fmt.wd -= 64; \
    588                                                 printf( "left %d %d %x\n", f.wd, f.pc, f.all ); \
    589                                                 printf( "left %d %d %x\n", fmt.wd, fmt.pc, fmt.all ); \
     589                                                /* printf( "R %llo %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt2.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \
    590590                                        } /* if */ \
    591                                         fmt2.pc = 64; fmt2.flags.pc = true;     \
    592                                         printf( "left %d %d %x\n", fmt2.wd, fmt2.pc, fmt2.all ); \
     591                                        /* printf( "\nC %llo %d %d '%c' %x\n", fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \
    593592                                        (ostype &)(os | fmt | "" | fmt2); \
    594593                                } else if ( f.base == 'o' ) { \
    595                                         if ( fmt.flags.pc && fmt.pc > 21 ) fmt.pc -= 21; \
     594                                        if ( fmt.flags.pc && fmt.pc > 22 ) fmt.pc -= 22; else { fmt.flags.pc = false; fmt.pc = 0; } \
     595                                        fmt.val = (unsigned long long int)fmt.val >> 2; \
     596                                        fmt2.val = ((msig & 0x3) << 1) + ((lsig & 0x8000000000000000U) != 0); \
    596597                                        if ( fmt.flags.left ) { \
    597598                                                fmt.flags.left = false; \
    598                                                 fmt.wd = 1; \
    599                                                 fmt.val = (unsigned long long int)fmt.val >> 2; \
    600                                                 fmt2.wd = 1; \
    601                                                 fmt2.val = ((msig & 0x3) << 1) + 1; \
     599                                                fmt.wd = 0; \
     600                                                /* if ( fmt2.val > 1 && fmt.flags.pc && fmt.pc > 0 ) fmt.pc -= 1; */ \
     601                                                /* printf( "L %llo %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt2.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \
    602602                                                (ostype &)(os | fmt | "" | fmt2); \
    603603                                                sepOff( os ); \
    604604                                                fmt2.flags.left = true; \
    605                                                 fmt2.wd = f.wd - ( ceiling( high1( fmt.val ), 3 ) + 1 ); \
     605                                                int msigd = ceiling( high1( fmt.val ), 3 ) + 1; \
     606                                                fmt2.wd = f.wd - (fmt.pc > msigd ? fmt.pc : msigd) - 1; \
     607                                                if ( fmt2.wd < 21 ) fmt2.wd = 21; \
    606608                                                fmt2.flags.pc = true; fmt2.pc = 21; \
    607                                                 if ( ! fmt.flags.nobsdp ) { fmt2.wd -= 1; } \
    608                                                 fmt2.val = lsig & 0x7fffffffffffffff; \
    609                                                 (ostype &)(os | fmt2); \
    610609                                        } else { \
    611                                                 fmt.val = (unsigned long long int)fmt.val >> 2; \
    612                                                 if ( fmt.wd > 21 ) fmt.wd -= 21; \
    613                                                 if ( ! fmt.flags.nobsdp ) { if ( fmt.pc < fmt.wd ) fmt.wd -= 1; else fmt.pc -= 1; } \
     610                                                if ( fmt.wd > 22 ) fmt.wd -= 22; \
     611                                                /* compensate for leading 0 */ \
     612                                                /*if ( ! fmt.flags.nobsdp && fmt.pc < fmt.wd ) fmt.wd -= 1;*/ \
    614613                                                fmt2.wd = 1; \
    615                                                 fmt2.val = ((msig & 0x3) << 1) + 1; \
     614                                                /* printf( "R %llo %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt2.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \
    616615                                                (ostype &)(os | fmt | "" | fmt2); \
    617616                                                sepOff( os ); \
    618617                                                fmt2.wd = 21; \
    619                                                 fmt2.val = lsig & 0x7fffffffffffffff; \
    620                                                 (ostype &)(os | fmt2); \
    621618                                        } /* if */ \
     619                                        fmt2.val = lsig & 0x7fffffffffffffffU; \
     620                                        /* printf( "\nC %llo %d %d '%c' %x\n", fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \
     621                                        (ostype &)(os | fmt2); \
    622622                                } else { \
    623623                                        if ( fmt.flags.pc && fmt.pc > 16 ) fmt.pc -= 16; \
Note: See TracChangeset for help on using the changeset viewer.