source: rtems-tools/tester/covoar/TraceConverter.cc @ 100f517

4.104.115
Last change on this file since 100f517 was 100f517, checked in by Chris Johns <chrisj@…>, on 05/09/14 at 11:50:37

covoar: Merger the covoar source from rtems-testing.git.

Use waf to build covoar.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*! @file TraceReaderLogQEMU.cc
2 *  @brief TraceReaderLogQEMU Implementation
3 *
4 *  This file contains the implementation of the functions supporting
5 *  reading the QEMU coverage data files.
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <sys/stat.h>
11#include <string.h>
12#include <getopt.h>
13
14#include "qemu-log.h"
15
16#include "TraceReaderLogQEMU.h"
17#include "TraceWriterQEMU.h"
18#include "TraceList.h"
19#include "ObjdumpProcessor.h"
20#include "app_common.h"
21#include "TargetFactory.h"
22
23char*       progname;
24
25void usage()
26{
27  fprintf(
28    stderr,
29    "Usage: %s [-v] -c CPU -e executable -t tracefile [-E logfile]\n",
30    progname
31  );
32  exit(1);
33}
34
35int main(
36  int    argc,
37  char** argv
38)
39{
40  int                          opt;
41  Trace::TraceReaderLogQEMU    log;
42  Trace::TraceWriterQEMU       trace;
43  const char                  *cpuname    = "";
44  const char                  *executable = "";
45  const char                  *tracefile  =  "";
46  const char                  *logname = "/tmp/qemu.log";
47  Coverage::ExecutableInfo*    executableInfo;
48   
49  //
50  // Process command line options.
51  //
52  progname = argv[0];
53
54  while ((opt = getopt(argc, argv, "c:e:l:L:t:v")) != -1) {
55    switch (opt) {
56      case 'c': cpuname = optarg;        break;
57      case 'e': executable = optarg;     break;
58      case 'l': logname = optarg;        break;
59      case 'L': dynamicLibrary = optarg; break;
60      case 't': tracefile = optarg;      break;
61      case 'v': Verbose = true;          break;
62      default:  usage();
63    }
64  }
65
66  // Make sure we have all the required parameters
67  if ( !cpuname ) {
68    fprintf( stderr, "cpuname not specified\n" );
69    usage();
70  }
71
72  if ( !executable ) {
73    fprintf( stderr, "executable not specified\n" );
74    usage();
75  }
76
77  if ( !tracefile ) {
78    fprintf( stderr, "output trace file not specified\n" );
79    usage();
80  }
81
82  // Create toolnames.
83  TargetInfo = Target::TargetFactory( cpuname );
84
85  if (dynamicLibrary)
86    executableInfo = new Coverage::ExecutableInfo( executable, dynamicLibrary );
87  else
88    executableInfo = new Coverage::ExecutableInfo( executable );
89
90  objdumpProcessor = new Coverage::ObjdumpProcessor();
91 
92  // If a dynamic library was specified, determine the load address.
93  if (dynamicLibrary)
94    executableInfo->setLoadAddress(
95      objdumpProcessor->determineLoadAddress( executableInfo )
96    );
97
98  objdumpProcessor->loadAddressTable( executableInfo );
99
100  log.processFile( logname );
101
102  trace.writeFile( tracefile, &log );
103
104}
Note: See TracBrowser for help on using the repository browser.