Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

main.cc File Reference

The entry point. More...

#include <string.h>
#include "Consumer.hh"
#include "Basic_Consumer.hh"
#include "Per_Task_Consumer.hh"
#include "Reference_Reader.hh"
#include "Binary_Raw_Reader.hh"
#include "Text_Raw_Reader.hh"
#include "Instruction_Reduced_Reader.hh"
#include "Page_Reduced_Reader.hh"

Go to the source code of this file.

Functions

int main (const unsigned int argc, const char **const argv)
 The entry point.


Detailed Description

The entry point.

Author:
Scott F. H. Kaplan <sfkaplan@cs.amherst.edu>
Date:
November 2002
This file is the entry point for Laplace-merge. From the command line arguments, it determines what type of merge is requested, what type of reference trace format to parse, creates objects for those choices, and then performs the merge.

Definition in file main.cc.


Function Documentation

int main const unsigned int    argc,
const char **const    argv
 

The entry point.

Parameters:
argc The number of arguments given at the command line.
argv The vector of argument strings passed at the command line.
Returns:
An execution result code.
Parse the command line arguments to obtain the type of merge requested and the pathnames of the input traces. Create and invoke an object that will perform the requested type of merge.

Definition at line 46 of file main.cc.

References Consumer::merge().

00046                                                         {
00047 
00048   // Were the correct number of arguments passed?
00049   if (argc != 6) {
00050 
00051     // No.  Emit usage and exit.
00052     fprintf(stderr, "Usage: %s\n", argv[0]);
00053     fprintf(stderr, "       <merge type (basic, per-task)>\n");
00054     fprintf(stderr, "       <reference trace type (binary-raw, text-raw, instruction-reduced, page-reduced)>\n");
00055     fprintf(stderr, "       <reference trace pathname>\n");
00056     fprintf(stderr, "       <kernel trace pathname>\n");
00057     fprintf(stderr, "       <output pathname>\n");
00058     return 1;
00059 
00060   }
00061 
00062   // Assign names to the arguments.
00063   const char* const merge_type = argv[1];
00064   const char* const reference_trace_type = argv[2];
00065   const char* const reference_trace_pathname = argv[3];
00066   const char* const kernel_trace_pathname = argv[4];
00067   const char* const output_pathname = argv[5];
00068 
00069   // Determine what kind of reference trace is being used.
00070   Reference_Reader* reference_reader = 0;
00071   if (strcmp(reference_trace_type, "text-raw") == 0) {
00072 
00073     reference_reader = new Text_Raw_Reader(reference_trace_pathname);
00074 
00075   } else if (strcmp(reference_trace_type, "binary-raw") == 0) {
00076 
00077     reference_reader =
00078       new Binary_Raw_Reader(reference_trace_pathname);
00079 
00080   } else if (strcmp(reference_trace_type,
00081         "instruction-reduced") == 0) {
00082 
00083     reference_reader =
00084       new Instruction_Reduced_Reader(reference_trace_pathname);
00085 
00086   } else if (strcmp(reference_trace_type, "page-reduced") == 0) {
00087 
00088     reference_reader =
00089       new Page_Reduced_Reader(reference_trace_pathname);
00090 
00091   } else {
00092 
00093     fprintf(stderr,
00094       "main(): Unknown reference trace type %s\n",
00095       reference_trace_type);
00096     exit(1);
00097 
00098   }
00099 
00100   // Ensure that the reference reader was allocated.
00101   if (reference_reader == 0) {
00102 
00103     fprintf(stderr, "main(): Unable to allocate reference reader\n");
00104     exit(1);
00105 
00106   }
00107 
00108   // Determine what kind of consumer was requested.
00109   Consumer* consumer = 0;
00110   if (strcmp(merge_type, "basic") == 0) {
00111 
00112     consumer = new Basic_Consumer(reference_reader,
00113           kernel_trace_pathname,
00114           output_pathname);
00115 
00116   } else if (strcmp(merge_type, "per-task") == 0) {
00117 
00118     consumer = new Per_Task_Consumer(reference_reader,
00119              kernel_trace_pathname,
00120              output_pathname);
00121 
00122   } else {
00123 
00124     fprintf(stderr, "main(): Unknown merge type %s\n", merge_type);
00125     exit(1);
00126 
00127   }
00128 
00129   // Ensure that the consumer was allocated.
00130   if (consumer == 0) {
00131 
00132     fprintf(stderr, "main(): Consumer allocation failed\n");
00133     exit(1);
00134 
00135   }
00136 
00137   // Merge the traces.
00138   consumer->merge();
00139 
00140   // Eliminate the consumer object.
00141   delete consumer;
00142   consumer = 0;
00143 
00144   // Eliminate the reference reader object.
00145   delete reference_reader;
00146   reference_reader = 0;
00147 
00148   // Exit successfully.
00149   return 0;
00150 
00151 } // main


Generated on Fri Jan 31 10:33:36 2003 for Laplace-merge by doxygen1.3-rc2