Changeset 169d944 for src/libcfa/interpose.c
- Timestamp:
- Feb 8, 2018, 4:52:09 PM (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:
- 06b176d
- Parents:
- 3f8ab8f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/interpose.c
r3f8ab8f r169d944 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 7 09:05:18201813 // Update Count : 5912 // Last Modified On : Thu Feb 8 16:18:09 2018 13 // Update Count : 75 14 14 // 15 15 … … 28 28 } 29 29 30 #define __NO_ABORT_OVERLOAD // no abort overload avoid ambiguities31 30 #include "bits/debug.h" 32 31 #include "bits/defs.h" … … 51 50 error = dlerror(); 52 51 if ( error ) { 53 abort f( "interpose_symbol : failed to open libc, %s\n", error );52 abort( "interpose_symbol : failed to open libc, %s\n", error ); 54 53 } 55 54 #endif … … 69 68 70 69 error = dlerror(); 71 if ( error ) abort f( "interpose_symbol : internal error, %s\n", error );70 if ( error ) abort( "interpose_symbol : internal error, %s\n", error ); 72 71 73 72 return originalFunc.fptr; … … 98 97 99 98 struct { 100 __typeof__( exit ) exit __attribute__(( noreturn));101 __typeof__( abort ) abort __attribute__(( noreturn));99 void (* exit)( int ) __attribute__ (( __noreturn__ )); 100 void (* abort)( void ) __attribute__ (( __noreturn__ )); 102 101 } __cabi_libc; 103 102 … … 123 122 124 123 // Forward declare abort after the __typeof__ call to avoid ambiguities 125 void abort ( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)); 124 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 125 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 126 126 127 127 extern "C" { 128 void abort( void ) __attribute__ (( __nothrow__, __leaf__, __noreturn__)) {129 abort f( NULL );130 } 131 132 void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {128 void abort( void ) __attribute__ (( __nothrow__, __leaf__, __noreturn__ )) { 129 abort( NULL ); 130 } 131 132 void __cabi_abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) { 133 133 va_list argp; 134 134 va_start( argp, fmt ); … … 137 137 } 138 138 139 void exit( int __status ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {140 __cabi_libc.exit( __status);141 } 142 } 143 144 void * kernel_abort ( void ) __attribute__ (( __nothrow__, __leaf__, __weak__)) { return NULL; }145 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ (( __nothrow__, __leaf__, __weak__)) {}146 int kernel_abort_lastframe( void ) __attribute__ (( __nothrow__, __leaf__, __weak__)) { return 4; }139 void exit( int status ) __attribute__ (( __nothrow__, __leaf__, __noreturn__ )) { 140 __cabi_libc.exit( status ); 141 } 142 } 143 144 void * kernel_abort ( void ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) { return NULL; } 145 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) {} 146 int kernel_abort_lastframe( void ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) { return 4; } 147 147 148 148 enum { abort_text_size = 1024 }; … … 150 150 static int abort_lastframe; 151 151 152 void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) { 152 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) { 153 va_list args; 154 va_start( args, fmt ); 155 vfprintf( stderr, fmt, args ); 156 va_end( args ); 157 __cabi_libc.exit( status ); 158 } 159 160 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) { 153 161 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 154 162 int len; … … 226 234 227 235 void sigHandler_segv( __CFA_SIGPARMS__ ) { 228 abort f( "Addressing invalid memory at location %p\n"236 abort( "Addressing invalid memory at location %p\n" 229 237 "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", 230 238 sfp->si_addr ); … … 232 240 233 241 void sigHandler_ill( __CFA_SIGPARMS__ ) { 234 abort f( "Executing illegal instruction at location %p.\n"242 abort( "Executing illegal instruction at location %p.\n" 235 243 "Possible cause is stack corruption.\n", 236 244 sfp->si_addr ); … … 248 256 default: msg = "unknown"; 249 257 } // choose 250 abort f( "Computation error %s at location %p.\n", msg, sfp->si_addr );258 abort( "Computation error %s at location %p.\n", msg, sfp->si_addr ); 251 259 } 252 260
Note: See TracChangeset
for help on using the changeset viewer.