Changeset 74330e7
- Timestamp:
- Feb 8, 2020, 10:07:49 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3ecfa13
- Parents:
- 3e274ab
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/interpose.cfa
r3e274ab r74330e7 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 11:38:20202013 // Update Count : 16 112 // Last Modified On : Sat Feb 8 08:40:34 2020 13 // Update Count : 163 14 14 // 15 15 … … 170 170 171 171 static void __cfaabi_backtrace( int start ) { 172 enum { 173 Frames = 50, // maximum number of stack frames 174 }; 172 enum { Frames = 50, }; // maximum number of stack frames 175 173 int last = kernel_abort_lastframe(); // skip last N stack frames 176 174 177 175 void * array[Frames]; 178 176 size_t size = backtrace( array, Frames ); 179 char ** messages = backtrace_symbols( array, size ); 177 char ** messages = backtrace_symbols( array, size ); // does not demangle names 180 178 181 179 *index( messages[0], '(' ) = '\0'; // find executable name … … 185 183 char * name = 0p, * offset_begin = 0p, * offset_end = 0p; 186 184 187 for ( char * p = messages[i]; *p; ++p ) {// find parantheses and +offset185 for ( char * p = messages[i]; *p; p += 1 ) { // find parantheses and +offset 188 186 //__cfaabi_bits_print_nolock( "X %s\n", p); 189 187 if ( *p == '(' ) { … … 237 235 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 238 236 239 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text237 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 240 238 __cfaabi_dbg_write( "\n", 1 ); 241 239 } -
src/main.cc
r3e274ab r74330e7 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 17:55:53 201913 // Update Count : 6 2712 // Last Modified On : Sat Feb 8 08:33:50 2020 13 // Update Count : 633 14 14 // 15 15 … … 105 105 106 106 static void backtrace( int start ) { // skip first N stack frames 107 enum { Frames = 50 };107 enum { Frames = 50, }; // maximum number of stack frames 108 108 void * array[Frames]; 109 int size = ::backtrace( array, Frames );109 size_t size = ::backtrace( array, Frames ); 110 110 char ** messages = ::backtrace_symbols( array, size ); // does not demangle names 111 111 … … 114 114 115 115 // skip last 2 stack frames after main 116 for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) {116 for ( unsigned int i = start; i < size - 2 && messages != nullptr; i += 1 ) { 117 117 char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr; 118 118 … … 180 180 } // sigSegvBusHandler 181 181 182 static void sigFpeHandler( SIGPARMS ) { 183 const char * msg; 184 185 switch ( sfp->si_code ) { 186 case FPE_INTDIV: case FPE_FLTDIV: msg = "divide by zero"; break; 187 case FPE_FLTOVF: msg = "overflow"; break; 188 case FPE_FLTUND: msg = "underflow"; break; 189 case FPE_FLTRES: msg = "inexact result"; break; 190 case FPE_FLTINV: msg = "invalid operation"; break; 191 default: msg = "unknown"; 192 } // choose 193 cerr << "Computation error " << msg << " at location " << sfp->si_addr << endl 194 << "Possible cause is constant-expression evaluation invalid." << endl; 195 backtrace( 2 ); // skip first 2 stack frames 196 abort(); // cause core dump for debugging 197 } // sigFpeHandler 198 182 199 static void sigAbortHandler( SIGPARMS ) { 183 200 backtrace( 6 ); // skip first 6 stack frames … … 193 210 Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO ); 194 211 Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO ); 212 Signal( SIGFPE, sigFpeHandler, SA_SIGINFO ); 195 213 Signal( SIGABRT, sigAbortHandler, SA_SIGINFO ); 196 214
Note: See TracChangeset
for help on using the changeset viewer.