Changeset 9347 in orxonox.OLD for branches/proxy/src/util/signal_handler.cc
- Timestamp:
- Jul 20, 2006, 11:43:27 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/util/signal_handler.cc
r9240 r9347 27 27 } 28 28 29 void SignalHandler::doCatch( std::string appName ) 29 /** 30 * register signal handlers for SIGSEGV and SIGABRT 31 * @param appName path to executable eg argv[0] 32 * @param fileName filename to append backtrace to 33 */ 34 void SignalHandler::doCatch( const std::string & appName, const std::string & fileName ) 30 35 { 31 36 this->appName = appName; 37 this->fileName = fileName; 38 39 // make sure doCatch is only called once without calling dontCatch 40 assert( sigRecList.size() == 0 ); 32 41 33 42 catchSignal( SIGSEGV ); … … 35 44 } 36 45 46 /** 47 * restore previous signal handlers 48 */ 37 49 void SignalHandler::dontCatch() 38 50 { … … 45 57 } 46 58 59 /** 60 * catch signal sig 61 * @param sig signal to catch 62 */ 47 63 void SignalHandler::catchSignal( int sig ) 48 64 { … … 58 74 } 59 75 76 /** 77 * sigHandler is called when receiving signals 78 * @param sig 79 */ 60 80 void SignalHandler::sigHandler( int sig ) 61 81 { … … 167 187 ) 168 188 charsFound++; 189 else 190 charsFound = 0; 169 191 170 192 if ( charsFound == 6 ) … … 183 205 write( sigPipe[1], &someData, sizeof(someData) ); 184 206 185 write( gdbIn[1], "bt\n q\n", 5);207 write( gdbIn[1], "bt\nk\nq\n", 7 ); 186 208 187 209 … … 202 224 ) 203 225 charsFound++; 226 else 227 charsFound = 0; 204 228 205 229 if ( charsFound == 6 ) … … 210 234 } 211 235 212 if ( promptFound == 2)236 if ( promptFound == 3 ) 213 237 { 214 238 break; … … 240 264 bt.insert(0, timeString); 241 265 242 FILE * f = fopen( GDB_BT_FILE, "a" );266 FILE * f = fopen( getInstance()->fileName.c_str(), "a" ); 243 267 244 268 if ( !f ) 245 269 { 246 perror( "could not append to " GDB_BT_FILE);270 perror( ( std::string( "could not append to " ) + getInstance()->fileName ).c_str() ); 247 271 exit(EXIT_FAILURE); 248 272 } … … 250 274 if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() ) 251 275 { 252 printf( "could not write %d byte to " GDB_BT_FILE, bt.length());276 printf( ( std::string("could not write %d byte to ") + getInstance()->fileName ).c_str(), bt.length()); 253 277 exit(EXIT_FAILURE); 254 278 }
Note: See TracChangeset
for help on using the changeset viewer.