Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9406 in orxonox.OLD for trunk/src/util/signal_handler.cc


Ignore:
Timestamp:
Jul 24, 2006, 11:09:47 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/signal_handler.cc

    r9240 r9406  
    2727}
    2828
    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 */
     34void SignalHandler::doCatch( const std::string & appName, const std::string & fileName )
    3035{
    3136  this->appName = appName;
     37  this->fileName = fileName;
     38 
     39  // make sure doCatch is only called once without calling dontCatch
     40  assert( sigRecList.size() == 0 );
    3241
    3342  catchSignal( SIGSEGV );
     
    3544}
    3645
     46/**
     47 * restore previous signal handlers
     48 */
    3749void SignalHandler::dontCatch()
    3850{
     
    4557}
    4658
     59/**
     60 * catch signal sig
     61 * @param sig signal to catch
     62 */
    4763void SignalHandler::catchSignal( int sig )
    4864{
     
    5874}
    5975
     76/**
     77 * sigHandler is called when receiving signals
     78 * @param sig
     79 */
    6080void SignalHandler::sigHandler( int sig )
    6181{
     
    167187        )
    168188          charsFound++;
     189    else
     190      charsFound = 0;
    169191
    170192    if ( charsFound == 6 )
     
    183205  write( sigPipe[1], &someData, sizeof(someData) );
    184206
    185   write( gdbIn[1], "bt\nq\n", 5 );
     207  write( gdbIn[1], "bt\nk\nq\n", 7 );
    186208
    187209 
     
    202224        )
    203225          charsFound++;
     226    else
     227      charsFound = 0;
    204228
    205229    if ( charsFound == 6 )
     
    210234    }
    211235
    212     if ( promptFound == 2 )
     236    if ( promptFound == 3 )
    213237    {
    214238      break;
     
    240264  bt.insert(0, timeString);
    241265 
    242   FILE * f = fopen( GDB_BT_FILE, "a" );
     266  FILE * f = fopen( getInstance()->fileName.c_str(), "a" );
    243267
    244268  if ( !f )
    245269  {
    246     perror("could not append to " GDB_BT_FILE);
     270    perror( ( std::string( "could not append to " ) + getInstance()->fileName ).c_str() );
    247271    exit(EXIT_FAILURE);
    248272  }
     
    250274  if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() )
    251275  {
    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());
    253277    exit(EXIT_FAILURE);
    254278  }
Note: See TracChangeset for help on using the changeset viewer.