summaryrefslogtreecommitdiffstats
path: root/tester/covoar/TraceConverter.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/TraceConverter.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/TraceConverter.cc')
-rw-r--r--tester/covoar/TraceConverter.cc60
1 files changed, 49 insertions, 11 deletions
diff --git a/tester/covoar/TraceConverter.cc b/tester/covoar/TraceConverter.cc
index 0f7a44e..22b0f81 100644
--- a/tester/covoar/TraceConverter.cc
+++ b/tester/covoar/TraceConverter.cc
@@ -10,9 +10,10 @@
#include <sys/stat.h>
#include <string.h>
#include <getopt.h>
+#include <signal.h>
+#include <unistd.h>
#include "qemu-log.h"
-
#include "TraceReaderLogQEMU.h"
#include "TraceWriterQEMU.h"
#include "TraceList.h"
@@ -20,6 +21,9 @@
#include "app_common.h"
#include "TargetFactory.h"
+#include "rld.h"
+#include "rld-process.h"
+
char* progname;
void usage()
@@ -32,6 +36,40 @@ void usage()
exit(1);
}
+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
@@ -45,10 +83,14 @@ int main(
const char *tracefile = "";
const char *logname = "/tmp/qemu.log";
Coverage::ExecutableInfo* executableInfo;
-
- //
- // Process command line options.
- //
+ rld::process::tempfile objdumpFile( ".dmp" );
+ rld::process::tempfile err( ".err" );
+
+ setup_signals();
+
+ //
+ // Process command line options.
+ //
progname = argv[0];
while ((opt = getopt(argc, argv, "c:e:l:L:t:v")) != -1) {
@@ -88,17 +130,13 @@ int main(
executableInfo = new Coverage::ExecutableInfo( executable );
objdumpProcessor = new Coverage::ObjdumpProcessor();
-
+
// If a dynamic library was specified, determine the load address.
if (dynamicLibrary)
executableInfo->setLoadAddress(
objdumpProcessor->determineLoadAddress( executableInfo )
);
-
- objdumpProcessor->loadAddressTable( executableInfo );
-
+ objdumpProcessor->loadAddressTable( executableInfo, objdumpFile, err );
log.processFile( logname );
-
trace.writeFile( tracefile, &log );
-
}