change log for gcc-testing (2010-05-05)

rtems-vc at rtems.org rtems-vc at rtems.org
Wed May 5 23:10:03 UTC 2010


 *joel*:
2010-05-05	Joel Sherrill <joel.sherrill at oarcorp.com>

	* .cvsignore, Makefile, covoar.cc: Add very basic configuration file
	support.
	* ConfigFile.cc, ConfigFile.h, configFile.txt, configfile_test.cc:
	New files.

M    1.7  rtems-coverage/.cvsignore
M  1.199  rtems-coverage/ChangeLog
A    1.1  rtems-coverage/ConfigFile.h
A    1.1  rtems-coverage/ConfigFile.cc
M   1.17  rtems-coverage/Makefile
A    1.1  rtems-coverage/configFile.txt
A    1.1  rtems-coverage/configfile_test.cc
M   1.11  rtems-coverage/covoar.cc

diff -u gcc-testing/rtems-coverage/.cvsignore:1.6 gcc-testing/rtems-coverage/.cvsignore:1.7
--- gcc-testing/rtems-coverage/.cvsignore:1.6	Fri Apr 23 08:36:22 2010
+++ gcc-testing/rtems-coverage/.cvsignore	Wed May  5 18:09:36 2010
@@ -1,3 +1,4 @@
+configfile-test
 coverage_converter
 covmerge
 covoar

diff -u gcc-testing/rtems-coverage/ChangeLog:1.198 gcc-testing/rtems-coverage/ChangeLog:1.199
--- gcc-testing/rtems-coverage/ChangeLog:1.198	Fri Apr 30 07:43:14 2010
+++ gcc-testing/rtems-coverage/ChangeLog	Wed May  5 18:09:36 2010
@@ -1,3 +1,10 @@
+2010-05-05	Joel Sherrill <joel.sherrill at oarcorp.com>
+
+	* .cvsignore, Makefile, covoar.cc: Add very basic configuration file
+	support.
+	* ConfigFile.cc, ConfigFile.h, configFile.txt, configfile_test.cc:
+	New files.
+
 2010-04-30	Jennifer Averett
 
 	* Target_arm.cc, Target_m68k.cc, Target_powerpc.cc, Target_sparc.cc:

diff -u /dev/null gcc-testing/rtems-coverage/ConfigFile.h:1.1
--- /dev/null	Wed May  5 18:10:02 2010
+++ gcc-testing/rtems-coverage/ConfigFile.h	Wed May  5 18:09:36 2010
@@ -0,0 +1,85 @@
+/*
+ *   $Id$
+ */
+
+
+
+/*! @file FileReader.h
+ *  @brief FileReader Specification
+ *
+ *  This file contains the specification of the FileReader class.
+ */
+
+#ifndef __CONFIGURATION_FILE_H__
+#define __CONFIGURATION_FILE_H__
+
+namespace Configuration {
+
+  typedef struct {
+    const char *option;
+    const char *value;
+  } Options_t;
+
+
+  /*! @class FileReader
+   *
+   *  This is the specification of the FileReader base class.
+   *  All FileReader implementations inherit from this class.
+   */
+  class FileReader {
+
+  public:
+
+    /*! 
+     *  This method constructs a FileReader instance.
+     *
+     *  @param[in] options is the set of options
+     */
+    FileReader(
+      Options_t *options
+    );
+
+    /*! 
+     *  This method destructs a FileReader instance.
+     */
+    virtual ~FileReader();
+
+    /*!
+     *  This method processes the configuratino information from the input
+     *  @a file.
+     *
+     *  @param[in] file is the coverage file to process
+     *
+     *  @return Returns TRUE if the method succeeded and FALSE if it failed.
+     */
+    virtual bool processFile(
+      const char* const     file
+    );
+
+    bool setOption(
+      const char* const option,
+      const char* const value
+    );
+
+    const char *getOption(
+      const char* const option
+    );
+
+    void printOptions(void);
+
+  private:
+    /*!
+     *  This method processes the configuratino information from the input
+     *  @a file.
+     *
+     *  @param[in] option is the name of the option
+     *  @param[in] value is the associated value
+     *
+     *  @return Returns TRUE if the method succeeded and FALSE if it failed.
+     */
+    Options_t *options_m;
+
+  };
+
+}
+#endif

diff -u /dev/null gcc-testing/rtems-coverage/ConfigFile.cc:1.1
--- /dev/null	Wed May  5 18:10:02 2010
+++ gcc-testing/rtems-coverage/ConfigFile.cc	Wed May  5 18:09:36 2010
@@ -0,0 +1,125 @@
+/*
+ *   $Id$
+ */
+
+
+/*! @file ConfigFile.cc
+ *  @brief ConfigFile Implementation
+ *
+ *  This file contains the implementation of the FileReader class.
+ */
+
+#include "ConfigFile.h"
+#include <string.h>
+#include <stdio.h>
+
+namespace Configuration {
+
+  FileReader::FileReader(
+    Options_t *options
+  )
+  {
+    options_m = options;
+  }
+
+  FileReader::~FileReader()
+  {
+  }
+
+  bool FileReader::processFile(
+    const char* const     file
+  )
+  {
+    #define METHOD "FileReader::processFile - "
+    FILE *in;
+    char  line[256];
+    char  option[256];
+    char  value[256];
+    int   line_no;
+
+    if ( file == NULL ) {
+      fprintf( stderr, METHOD "NULL filename\n" );
+      return false;
+    }
+
+    in = fopen( file, "r" );
+    if ( !in ) {
+      fprintf( stderr, METHOD "unable to open %s\n", file );
+      return false;
+    }
+
+    line_no = 0;
+    while (fgets(line, sizeof(line), in) != NULL) {
+
+      line_no++;
+
+      /* Ignore empty lines and comments */
+      if (line[0] == '#' || line[0] == '\n')
+        continue;
+
+      if (sscanf(line, "%s = %[^ \r\n#]", option, value) != 2) {
+        fprintf(
+          stderr,
+          "%s: line %d is invalid: %s",
+          file,
+          line_no,
+          line
+        );
+        continue;
+      }
+
+      if ( !setOption(option, value) ) {
+        fprintf(
+          stderr,
+          "%s: line %d: option %s is unknown\n",
+          file,
+          line_no,
+          option
+        );
+        continue;
+      }
+
+    }
+
+    return false;
+  }
+
+  bool FileReader::setOption(
+    const char* const option,
+    const char* const value
+  )
+  {
+    Options_t *o;
+
+    for ( o=options_m ; o->option ; o++ ) {
+      if ( !strcmp( o->option, option ) ) {
+        o->value = strdup( value );
+        return true;
+      }
+    }
+    return false;
+  }
+
+  const char *FileReader::getOption(
+    const char* const option
+  )
+  {
+    Options_t *o;
+
+    for ( o=options_m ; o->option ; o++ ) {
+      if ( !strcmp( o->option, option ) ) {
+        return o->value;
+      }
+    }
+    return NULL;
+  }
+
+  void FileReader::printOptions(void)
+  {
+    Options_t *o;
+
+    for ( o=options_m ; o->option ; o++ ) {
+      fprintf( stderr, "(%s)=(%s)\n", o->option, o->value );
+    }
+  }
+}

diff -u gcc-testing/rtems-coverage/Makefile:1.16 gcc-testing/rtems-coverage/Makefile:1.17
--- gcc-testing/rtems-coverage/Makefile:1.16	Thu Apr 29 14:12:31 2010
+++ gcc-testing/rtems-coverage/Makefile	Wed May  5 18:09:36 2010
@@ -3,10 +3,11 @@
 #
 
 INSTALL_DIR=../bin
-CXXFLAGS=-g -Wall -O0 -march=native -mtune=native
-PROGRAMS=covoar qemu-dump-trace trace-converter
+CXXFLAGS=-g -Wall -O3 -march=native -mtune=native
+PROGRAMS=covoar qemu-dump-trace trace-converter configfile-test
 
 COMMON_OBJS= app_common.o \
+  ConfigFile.o \
   CoverageFactory.o \
   CoverageMap.o \
   CoverageMapBase.o \
@@ -49,6 +50,10 @@
   $(COMMON_OBJS) \
   covoar.o
 
+CONFIGFILE_TEST_OBJS = \
+  $(COMMON_OBJS) \
+  configfile_test.cc
+
 INSTALLED= \
     ../bin/qemu-dump-trace \
     ../bin/trace-converter
@@ -75,6 +80,9 @@
 trace-converter: $(TRACECONVERTER_OBJS)
 	$(CXX) $(CXXFLAGS) -o $(@) $(TRACECONVERTER_OBJS)
 
+configfile-test: $(CONFIGFILE_TEST_OBJS)
+	$(CXX) $(CXXFLAGS) -o $(@) $(CONFIGFILE_TEST_OBJS)
+
 #  DEPENDENCIES ON SINGLE OBJECTS
 app_common.o: app_common.h app_common.cc
 

diff -u /dev/null gcc-testing/rtems-coverage/configFile.txt:1.1
--- /dev/null	Wed May  5 18:10:02 2010
+++ gcc-testing/rtems-coverage/configFile.txt	Wed May  5 18:09:36 2010
@@ -0,0 +1,13 @@
+#
+#  This is a comment.
+#
+#  $Id$
+#
+verbose = no   
+
+verbose
+
+verbose     yes   
+
+bad_option no
+

diff -u /dev/null gcc-testing/rtems-coverage/configfile_test.cc:1.1
--- /dev/null	Wed May  5 18:10:02 2010
+++ gcc-testing/rtems-coverage/configfile_test.cc	Wed May  5 18:09:36 2010
@@ -0,0 +1,26 @@
+/*
+ * $Id$
+ */
+
+#include "ConfigFile.h"
+#include <stdio.h>
+
+Configuration::Options_t Options[] = {
+  { "verbose",  NULL },
+  { NULL,       NULL }
+};
+
+int main(
+  int   argc,
+  char *argv[]
+)
+{
+  Configuration::FileReader *config;
+
+  config = new Configuration::FileReader(Options);
+  
+  config->processFile( "configFile.txt" );
+  config->printOptions();
+
+}
+

diff -u gcc-testing/rtems-coverage/covoar.cc:1.10 gcc-testing/rtems-coverage/covoar.cc:1.11
--- gcc-testing/rtems-coverage/covoar.cc:1.10	Thu Apr 29 14:12:31 2010
+++ gcc-testing/rtems-coverage/covoar.cc	Wed May  5 18:09:36 2010
@@ -39,12 +39,13 @@
 char*                                executableExtension = NULL;
 int                                  executableExtensionLength = 0;
 std::list<Coverage::ExecutableInfo*> executablesToAnalyze;
-char*                                explanations = NULL;
+const char*                          explanations = NULL;
 char*                                progname;
 bool                                 singleExecutable = false;
 const char*                          sizeReportFile = "sizes.txt";
 const char*                          symbolsFile = NULL;
-char*                                target = NULL;
+const char*                          target = NULL;
+const char*                          format = NULL;
 
 
 /*
@@ -67,6 +68,7 @@
     "  -1 EXECUTABLE             - name of executable to get symbols from\n"
     "  -e EXE_EXTENSION          - extension of the executables to analyze\n"
     "  -c COVERAGEFILE_EXTENSION - extension of the coverage files to analyze\n"
+    "  -C ConfigurationFileName  - name of configuration file\n"
     "\n",
     progname,
     progname
@@ -76,6 +78,62 @@
 #define PrintableString(_s) \
        ((!(_s)) ? "NOT SET" : (_s))
 
+/*
+ *  Configuration File Support
+ */
+#include "ConfigFile.h"
+Configuration::FileReader *CoverageConfiguration;
+
+Configuration::Options_t Options[] = {
+  { "explanations", NULL },
+  { "format",       NULL },
+  { "symbolsFile ", NULL },
+  { "target",       NULL },
+  { "verbose",      NULL },
+  { NULL,           NULL }
+};
+
+bool isTrue(const char *value)
+{
+  if ( !value )                  return false;
+  if ( !strcmp(value, "true") )  return true;
+  if ( !strcmp(value, "TRUE") )  return true;
+  if ( !strcmp(value, "yes") )   return true;
+  if ( !strcmp(value, "YES") )   return true;
+  return false;
+}
+
+#define GET_BOOL(_opt, _val) \
+  if (isTrue(CoverageConfiguration->getOption(_opt))) \
+    _val = true;
+
+#define GET_STRING(_opt, _val) \
+  do { \
+    const char *_t; \
+    _t = CoverageConfiguration->getOption(_opt); \
+    if ( _t ) _val = _t; \
+  } while(0)
+  
+
+void check_configuration(void)
+{
+  GET_BOOL( "verbose", Verbose );
+
+  GET_STRING( "format",       format );
+  GET_STRING( "target",       target );
+  GET_STRING( "explanations", explanations );
+  GET_STRING( "symbolsFile",  symbolsFile );
+
+  // Now calculate some values
+  if ( coverageFileExtension )
+    coverageExtensionLength = strlen( coverageFileExtension );
+
+  if ( executableExtension )
+    executableExtensionLength = strlen( executableExtension );
+  if ( format )
+    coverageFormat = Coverage::CoverageFormatToEnum(optarg);
+}
+
 int main(
   int    argc,
   char** argv
@@ -85,16 +143,17 @@
   std::string                                    coverageFileName;
   std::list<Coverage::ExecutableInfo*>::iterator eitr;
   Coverage::ExecutableInfo*                      executableInfo = NULL;
-  char*                                          format = NULL;
   int                                            i;
   int                                            opt;
 
+  CoverageConfiguration = new Configuration::FileReader(Options);
+  
   //
   // Process command line options.
   //
   progname = argv[0];
 
-  while ((opt = getopt(argc, argv, "1:e:c:E:f:s:T:v")) != -1) {
+  while ((opt = getopt(argc, argv, "1:e:c:E:f:s:T:vC:")) != -1) {
     switch (opt) {
       case '1':
         singleExecutable = true;
@@ -103,26 +162,26 @@
         break;
       case 'e':
         executableExtension = optarg;
-        executableExtensionLength = strlen( executableExtension );
         break;
       case 'c':
          coverageFileExtension = optarg;
-         coverageExtensionLength = strlen( coverageFileExtension );
+         break;
+      case 'C':
+         CoverageConfiguration->processFile( optarg );
          break;
       case 'E': explanations          = optarg;  break;
       case 's': symbolsFile           = optarg;  break;
       case 'T': target                = optarg;  break;
       case 'v': Verbose               = true;    break;
-      case 'f':
-        format = optarg;
-        coverageFormat = Coverage::CoverageFormatToEnum(optarg);
-        break;
+      case 'f': format                = optarg;  break;
       default: /* '?' */
         usage();
         exit( -1 );
     }
   }
 
+  check_configuration();
+
   // If a single executable was specified, process the remaining
   // arguments as coverage file names.
   if (singleExecutable) {



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20100505/ca860a32/attachment.html>


More information about the vc mailing list