Changeset 6a4859e in rtems-tools for tester/covoar/covoar.cc


Ignore:
Timestamp:
08/26/17 08:15:56 (6 years ago)
Author:
Cillian O'Donnell <cpodonnell8@…>
Branches:
5, master
Children:
4600903
Parents:
4cee5c3
git-author:
Cillian O'Donnell <cpodonnell8@…> (08/26/17 08:15:56)
git-committer:
Chris Johns <chrisj@…> (08/29/17 08:06:11)
Message:

covoar: Use rld tempfile and add signals to clean up in event of crash.

Use rld tempfile for temporary files and add fatal signal handling to clean
them up in the event of a crash.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester/covoar/covoar.cc

    r4cee5c3 r6a4859e  
    2323#include "TargetFactory.h"
    2424#include "GcovData.h"
     25
     26#include "rld-process.h"
    2527
    2628/*
     
    4648const char*                          format = NULL;
    4749FILE*                                gcnosFile = NULL;
    48 Gcov::GcovData*                      gcovFile;
     50Gcov::GcovData*          gcovFile;
    4951
    5052/*
     
    147149}
    148150
     151static void
     152fatal_signal( int signum )
     153{
     154  signal( signum, SIG_DFL );
     155
     156  rld::process::temporaries_clean_up();
     157
     158  /*
     159   * Get the same signal again, this time not handled, so its normal effect
     160   * occurs.
     161   */
     162  kill( getpid(), signum );
     163}
     164
     165static void
     166setup_signals( void )
     167{
     168  if ( signal( SIGINT, SIG_IGN ) != SIG_IGN )
     169    signal( SIGINT, fatal_signal );
     170#ifdef SIGHUP
     171  if ( signal( SIGHUP, SIG_IGN ) != SIG_IGN )
     172    signal( SIGHUP, fatal_signal );
     173#endif
     174  if ( signal( SIGTERM, SIG_IGN ) != SIG_IGN )
     175    signal( SIGTERM, fatal_signal );
     176#ifdef SIGPIPE
     177  if ( signal( SIGPIPE, SIG_IGN ) != SIG_IGN )
     178    signal( SIGPIPE, fatal_signal );
     179#endif
     180#ifdef SIGCHLD
     181  signal( SIGCHLD, SIG_DFL );
     182#endif
     183}
     184
    149185int main(
    150186  int    argc,
     
    159195  int                                            opt;
    160196  const char*                                    singleExecutable = NULL;
     197  rld::process::tempfile                         objdumpFile( ".dmp" );
     198  rld::process::tempfile                         err( ".err" );
     199  bool                                           debug = false;
     200
     201  setup_signals();
    161202
    162203  CoverageConfiguration = new Configuration::FileReader(Options);
     
    167208  progname = argv[0];
    168209
    169   while ((opt = getopt(argc, argv, "C:1:L:e:c:g:E:f:s:T:O:p:v")) != -1) {
     210  while ((opt = getopt(argc, argv, "C:1:L:e:c:g:E:f:s:T:O:p:v:d")) != -1) {
    170211    switch (opt) {
    171212      case 'C': CoverageConfiguration->processFile( optarg ); break;
     
    182223      case 'v': Verbose               = true;   break;
    183224      case 'p': projectName           = optarg; break;
     225      case 'd': debug                 = true;   break;
    184226      default: /* '?' */
    185227        usage();
     
    395437
    396438    // Load the objdump for the symbols in this executable.
    397     objdumpProcessor->load( *eitr );
     439    objdumpProcessor->load( *eitr, objdumpFile, err );
    398440  }
    399441
     
    504546  }
    505547
     548  //Leave tempfiles around if debug flag (-d) is enabled.
     549  if ( debug ) {
     550        objdumpFile.override( "objdump_file" );
     551        objdumpFile.keep();
     552        err.override( "objdump_exec_log" );
     553        err.keep();
     554  }
    506555  return 0;
    507556}
Note: See TracChangeset for help on using the changeset viewer.