summaryrefslogtreecommitdiffstats
path: root/tester/covoar/covoar.cc
diff options
context:
space:
mode:
authorCillian O'Donnell <cpodonnell8@gmail.com>2017-08-26 09:15:56 +0100
committerChris Johns <chrisj@rtems.org>2017-08-29 18:06:11 +1000
commit6a4859e627fa10690741d36b2f1c39a1c4d6cc3a (patch)
tree39e04c8186bd342f815cfe79641a16febb6c3bc2 /tester/covoar/covoar.cc
parentcovoar/wscript: Add paths to rtemstoolkit to build. (diff)
downloadrtems-tools-6a4859e627fa10690741d36b2f1c39a1c4d6cc3a.tar.bz2
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.
Diffstat (limited to 'tester/covoar/covoar.cc')
-rw-r--r--tester/covoar/covoar.cc55
1 files changed, 52 insertions, 3 deletions
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index a3f137e..005cb8e 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -23,6 +23,8 @@
#include "TargetFactory.h"
#include "GcovData.h"
+#include "rld-process.h"
+
/*
* Variables to control general behavior
*/
@@ -45,7 +47,7 @@ char gcovBashCommand[256];
const char* target = NULL;
const char* format = NULL;
FILE* gcnosFile = NULL;
-Gcov::GcovData* gcovFile;
+Gcov::GcovData* gcovFile;
/*
* Print program usage message
@@ -146,6 +148,40 @@ void check_configuration(void)
coverageFormat = Coverage::CoverageFormatToEnum( format );
}
+static void
+fatal_signal( int signum )
+{
+ signal( signum, SIG_DFL );
+
+ rld::process::temporaries_clean_up();
+
+ /*
+ * Get the same signal again, this time not handled, so its normal effect
+ * occurs.
+ */
+ kill( getpid(), signum );
+}
+
+static void
+setup_signals( void )
+{
+ if ( signal( SIGINT, SIG_IGN ) != SIG_IGN )
+ signal( SIGINT, fatal_signal );
+#ifdef SIGHUP
+ if ( signal( SIGHUP, SIG_IGN ) != SIG_IGN )
+ signal( SIGHUP, fatal_signal );
+#endif
+ if ( signal( SIGTERM, SIG_IGN ) != SIG_IGN )
+ signal( SIGTERM, fatal_signal );
+#ifdef SIGPIPE
+ if ( signal( SIGPIPE, SIG_IGN ) != SIG_IGN )
+ signal( SIGPIPE, fatal_signal );
+#endif
+#ifdef SIGCHLD
+ signal( SIGCHLD, SIG_DFL );
+#endif
+}
+
int main(
int argc,
char** argv
@@ -158,6 +194,11 @@ int main(
int i;
int opt;
const char* singleExecutable = NULL;
+ rld::process::tempfile objdumpFile( ".dmp" );
+ rld::process::tempfile err( ".err" );
+ bool debug = false;
+
+ setup_signals();
CoverageConfiguration = new Configuration::FileReader(Options);
@@ -166,7 +207,7 @@ int main(
//
progname = argv[0];
- while ((opt = getopt(argc, argv, "C:1:L:e:c:g:E:f:s:T:O:p:v")) != -1) {
+ while ((opt = getopt(argc, argv, "C:1:L:e:c:g:E:f:s:T:O:p:v:d")) != -1) {
switch (opt) {
case 'C': CoverageConfiguration->processFile( optarg ); break;
case '1': singleExecutable = optarg; break;
@@ -181,6 +222,7 @@ int main(
case 'O': outputDirectory = optarg; break;
case 'v': Verbose = true; break;
case 'p': projectName = optarg; break;
+ case 'd': debug = true; break;
default: /* '?' */
usage();
exit( -1 );
@@ -394,7 +436,7 @@ int main(
);
// Load the objdump for the symbols in this executable.
- objdumpProcessor->load( *eitr );
+ objdumpProcessor->load( *eitr, objdumpFile, err );
}
//
@@ -503,5 +545,12 @@ int main(
AllExplanations->writeNotFound( notFound.c_str() );
}
+ //Leave tempfiles around if debug flag (-d) is enabled.
+ if ( debug ) {
+ objdumpFile.override( "objdump_file" );
+ objdumpFile.keep();
+ err.override( "objdump_exec_log" );
+ err.keep();
+ }
return 0;
}