Changeset 6ea0187 in rtems-testing


Ignore:
Timestamp:
May 17, 2010, 9:47:07 PM (9 years ago)
Author:
Glenn Humphrey <glenn.humphrey@…>
Branches:
4.11, 8895273c193787f84c4585a10f6d6aceb3b25dc4
Children:
c53ae75
Parents:
d96ab18
Message:

2010-05-17 Glenn Humphrey

  • CoverageReaderBase?.h, CoverageReaderQEMU.cc, CoverageReaderQEMU.h, CoverageReaderRTEMS.cc, CoverageReaderRTEMS.h, CoverageReaderSkyeye?.cc, CoverageReaderSkyeye?.h, CoverageReaderTSIM.cc, CoverageReaderTSIM.h, app_common.cc, app_common.h, covoar.cc: Verified that the executable files and the coverage files were readable before performing any analysis.
Location:
rtems-coverage
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • rtems-coverage/ChangeLog

    rd96ab18 r6ea0187  
     12010-05-17      Glenn Humphrey
     2
     3        * CoverageReaderBase.h, CoverageReaderQEMU.cc, CoverageReaderQEMU.h,
     4        CoverageReaderRTEMS.cc, CoverageReaderRTEMS.h,
     5        CoverageReaderSkyeye.cc, CoverageReaderSkyeye.h,
     6        CoverageReaderTSIM.cc, CoverageReaderTSIM.h, app_common.cc,
     7        app_common.h, covoar.cc: Verified that the executable files and the
     8        coverage files were readable before performing any analysis.
     9
    1102010-05-17      Jennifer Averett <Jennifer.Averett@OARcorp.com>
    211
  • rtems-coverage/CoverageReaderBase.h

    rd96ab18 r6ea0187  
    4242     *  @param[in] executableInformation is the information for an
    4343     *             associated executable
    44      *
    45      *  @return Returns TRUE if the method succeeded and FALSE if it failed.
    4644     */
    47     virtual bool processFile(
     45    virtual void processFile(
    4846      const char* const     file,
    4947      ExecutableInfo* const executableInformation
  • rtems-coverage/CoverageReaderQEMU.cc

    rd96ab18 r6ea0187  
    2323/* hack so this can compile on the RH7 RTEMS 4.5 host */
    2424#if (__GNUC__ <= 2)
    25 #define STAT stat
    2625#define OPEN fopen
    2726#else
    28 #define STAT stat64
    2927#define OPEN fopen64
    3028#endif
     
    4139  }
    4240
    43   bool CoverageReaderQEMU::processFile(
     41  void CoverageReaderQEMU::processFile(
    4442    const char* const     file,
    4543    ExecutableInfo* const executableInformation
     
    4846    struct trace_header header;
    4947    uintptr_t           i;
    50     struct STAT         statbuf;
    5148    int                 status;
    5249    FILE*               traceFile;
     
    6057
    6158    //
    62     // Verify that the coverage file has a non-zero size.
    63     //
    64     // NOTE: We prefer stat64 because some of the coverage files are HUGE!
    65     status = STAT( file, &statbuf );
    66     if (status == -1) {
    67       fprintf( stderr, "Unable to stat %s\n", file );
    68       return false;
    69     }
    70 
    71     if (statbuf.st_size == 0) {
    72       fprintf( stderr, "%s is 0 bytes long\n", file );
    73       return false;
    74     }
    75 
    76     //
    7759    // Open the coverage file and read the header.
    7860    //
    7961    traceFile = OPEN( file, "r" );
    8062    if (!traceFile) {
    81       fprintf( stderr, "Unable to open %s\n", file );
    82       return false;
     63      fprintf(
     64        stderr,
     65        "ERROR: CoverageReaderQEMU::processFile - Unable to open %s\n",
     66        file
     67      );
     68      exit( -1 );
    8369    }
    8470
    8571    status = fread( &header, sizeof(trace_header), 1, traceFile );
    8672    if (status != 1) {
    87       fprintf( stderr, "Unable to read header from %s\n", file );
    88       return false;
     73      fprintf(
     74        stderr,
     75        "ERROR: CoverageReaderQEMU::processFile - "
     76        "Unable to read header from %s\n",
     77        file
     78      );
     79      exit( -1 );
    8980    }
    9081
     
    164155
    165156    fclose( traceFile );
    166     return true;
    167157  }
    168158}
  • rtems-coverage/CoverageReaderQEMU.h

    rd96ab18 r6ea0187  
    4141
    4242    /* Inherit documentation from base class. */
    43     bool processFile(
     43    void processFile(
    4444      const char* const     file,
    4545      ExecutableInfo* const executableInformation
  • rtems-coverage/CoverageReaderRTEMS.cc

    rd96ab18 r6ea0187  
    2929  }
    3030
    31   bool CoverageReaderRTEMS::processFile(
     31  void CoverageReaderRTEMS::processFile(
    3232    const char* const     file,
    3333    ExecutableInfo* const executableInformation
     
    4141    uintptr_t                    i;
    4242    uintptr_t                    length;
    43     struct stat                  statbuf;
    4443    int                          status;
    45 
    46     //
    47     // Verify that the coverage file has a non-zero size.
    48     //
    49     status = stat( file, &statbuf );
    50     if (status == -1) {
    51       fprintf( stderr, "Unable to stat %s\n", file );
    52       return false;
    53     }
    54 
    55     if (statbuf.st_size == 0) {
    56       fprintf( stderr, "%s is 0 bytes long\n", file );
    57       return false;
    58     }
    5944
    6045    //
     
    6348    coverageFile = fopen( file, "r" );
    6449    if (!coverageFile) {
    65       fprintf( stderr, "Unable to open %s\n", file );
    66       return false;
     50      fprintf(
     51        stderr,
     52        "ERROR: CoverageReaderRTEMS::processFile - Unable to open %s\n",
     53        file
     54      );
     55      exit( -1 );
    6756    }
    6857
    6958    status = fread( &header, sizeof(header), 1, coverageFile );
    7059    if (status != 1) {
    71       fprintf( stderr, "Unable to read header from %s\n", file );
    72       return false;
     60      fprintf(
     61        stderr,
     62        "ERROR: CoverageReaderRTEMS::processFile - "
     63        "Unable to read header from %s\n",
     64        file
     65      );
     66      exit( -1 );
    7367    }
    7468
     
    115109
    116110    fclose( coverageFile );
    117     return true;
    118111  }
    119112}
  • rtems-coverage/CoverageReaderRTEMS.h

    rd96ab18 r6ea0187  
    3939
    4040    /* Inherit documentation from base class. */
    41     bool processFile(
     41    void processFile(
    4242      const char* const     file,
    4343      ExecutableInfo* const executableInformation
  • rtems-coverage/CoverageReaderSkyeye.cc

    rd96ab18 r6ea0187  
    2929  }
    3030
    31   bool CoverageReaderSkyeye::processFile(
     31  void CoverageReaderSkyeye::processFile(
    3232    const char* const     file,
    3333    ExecutableInfo* const executableInformation
     
    4141    uintptr_t        i;
    4242    uintptr_t        length;
    43     struct stat      statbuf;
    4443    int              status;
    45 
    46     //
    47     // Verify that the coverage file has a non-zero size.
    48     //
    49     status = stat( file, &statbuf );
    50     if (status == -1) {
    51       fprintf( stderr, "Unable to stat %s\n", file );
    52       return false;
    53     }
    54 
    55     if (statbuf.st_size == 0) {
    56       fprintf( stderr, "%s is 0 bytes long\n", file );
    57       return false;
    58     }
    5944
    6045    //
     
    6348    coverageFile = fopen( file, "r" );
    6449    if (!coverageFile) {
    65       fprintf( stderr, "Unable to open %s\n", file );
    66       return false;
     50      fprintf(
     51        stderr,
     52        "ERROR: CoverageReaderSkyeye::processFile - Unable to open %s\n",
     53        file
     54      );
     55      exit( -1 );
    6756    }
    6857
    6958    status = fread( &header, sizeof(header), 1, coverageFile );
    7059    if (status != 1) {
    71       fprintf( stderr, "Unable to read header from %s\n", file );
    72       return false;
     60      fprintf(
     61        stderr,
     62        "ERROR: CoverageReaderSkyeye::processFile - "
     63        "Unable to read header from %s\n",
     64        file
     65      );
     66      exit( -1 );
    7367    }
    7468
     
    133127
    134128    fclose( coverageFile );
    135     return true;
    136129  }
    137130}
  • rtems-coverage/CoverageReaderSkyeye.h

    rd96ab18 r6ea0187  
    3939
    4040    /* Inherit documentation from base class. */
    41     bool processFile(
     41    void processFile(
    4242      const char* const     file,
    4343      ExecutableInfo* const executableInformation
  • rtems-coverage/CoverageReaderTSIM.cc

    rd96ab18 r6ea0187  
    2828  }
    2929
    30   bool CoverageReaderTSIM::processFile(
     30  void CoverageReaderTSIM::processFile(
    3131    const char* const     file,
    3232    ExecutableInfo* const executableInformation
     
    3838    FILE*            coverageFile;
    3939    int              i;
    40     struct stat      statbuf;
    4140    int              status;
    42 
    43     //
    44     // Verify that the coverage file has a non-zero size.
    45     //
    46     status = stat( file, &statbuf );
    47     if (status == -1) {
    48       fprintf( stderr, "Unable to stat %s\n", file );
    49       return false;
    50     }
    51 
    52     if (statbuf.st_size == 0) {
    53       fprintf( stderr, "%s is 0 bytes long\n", file );
    54       return false;
    55     }
    5641
    5742    //
     
    6045    coverageFile = fopen( file, "r" );
    6146    if (!coverageFile) {
    62       fprintf( stderr, "Unable to open %s\n", file );
    63       return false;
     47      fprintf(
     48        stderr,
     49        "ERROR: CoverageReaderTSIM::processFile - Unable to open %s\n",
     50        file
     51      );
     52      exit( -1 );
    6453    }
    6554
     
    10493
    10594    fclose( coverageFile );
    106     return true;
    10795  }
    10896}
  • rtems-coverage/CoverageReaderTSIM.h

    rd96ab18 r6ea0187  
    4040
    4141    /* Inherit documentation from base class. */
    42     bool processFile(
     42    void processFile(
    4343      const char* const     file,
    4444      ExecutableInfo* const executableInformation
  • rtems-coverage/app_common.cc

    rd96ab18 r6ea0187  
    33 */
    44
    5 #include <sys/types.h>
    6 #include <sys/stat.h>
    7 #include <unistd.h>
     5#include <stdio.h>
    86#include <stdlib.h>
    97#include <string.h>
    10 #include <stdio.h>
     8#include <sys/stat.h>
     9#include <sys/types.h>
     10#include <unistd.h>
    1111
    1212#include "app_common.h"
    1313#include "DesiredSymbols.h"
    1414#include "Explanations.h"
     15
     16/* hack so this can compile on the RH7 RTEMS 4.5 host */
     17#if (__GNUC__ <= 2)
     18#define STAT stat
     19#define OPEN fopen
     20#else
     21#define STAT stat64
     22#define OPEN fopen64
     23#endif
    1524
    1625/*
     
    2635
    2736bool FileIsNewer( const char *f1, const char *f2 ) {
    28   struct stat buf1, buf2;
     37  struct STAT buf1, buf2;
    2938
    30    if (stat( f2, &buf2 ) == -1)
     39   if (STAT( f2, &buf2 ) == -1)
    3140    return true;
    3241 
    33   if (stat (f1, &buf1 ) == -1)
     42  if (STAT( f1, &buf1 ) == -1)
    3443    exit (1);
    3544
     
    3847
    3948  return false;
     49}
     50
     51bool FileIsReadable( const char *f1 ) {
     52  struct STAT buf1;
     53
     54  if (STAT( f1, &buf1 ) == -1)
     55    return false;
     56
     57  if (buf1.st_size == 0)
     58    return false;
     59
     60  // XXX check permission ??
     61  return true;
    4062}
    4163
  • rtems-coverage/app_common.h

    rd96ab18 r6ea0187  
    2121
    2222bool FileIsNewer( const char *f1, const char *f2 );
     23bool FileIsReadable( const char *f1 );
    2324bool ReadUntilFound( FILE *file, const char *line );
    2425
  • rtems-coverage/covoar.cc

    rd96ab18 r6ea0187  
    154154  progname = argv[0];
    155155
    156   while ((opt = getopt(argc, argv, "1:e:c:E:f:s:T:vC:O:")) != -1) {
     156  while ((opt = getopt(argc, argv, "C:1:e:c:E:f:s:T:O:v")) != -1) {
    157157    switch (opt) {
    158158      case 'C': CoverageConfiguration->processFile( optarg ); break;
    159       case '1': singleExecutable = optarg;      break;
    160       case 'e': executableExtension = optarg;    break;
    161       case 'c': coverageFileExtension = optarg;  break;
    162       case 'E': explanations          = optarg;  break;
    163       case 's': symbolsFile           = optarg; break;
    164       case 'T': target                = optarg; break;
    165       case 'v': Verbose               = true;    break;
    166       case 'f': format                = optarg; break;
    167       case 'O': outputDirectory       = optarg;  break;
     159      case '1': singleExecutable      = optarg; break;
     160      case 'e': executableExtension   = optarg; break;
     161      case 'c': coverageFileExtension = optarg; break;
     162      case 'E': explanations          = optarg; break;
     163      case 'f': format                = optarg; break;
     164      case 's': symbolsFile           = optarg; break;
     165      case 'T': target                = optarg; break;
     166      case 'O': outputDirectory       = optarg; break;
     167      case 'v': Verbose               = true;   break;
    168168      default: /* '?' */
    169169        usage();
     
    180180  // arguments as coverage file names.
    181181  if (singleExecutable) {
    182     executableInfo = new Coverage::ExecutableInfo( singleExecutable );
    183     executablesToAnalyze.push_back( executableInfo );
    184     for (i=optind; i < argc; i++) {
    185       coverageFileName = argv[i];
    186       coverageFileNames.push_back( coverageFileName );
     182
     183    // Ensure that the executable is readable.
     184    if (!FileIsReadable( singleExecutable )) {
     185      fprintf(
     186        stderr,
     187        "WARNING: Unable to read executable %s\n",
     188        singleExecutable
     189      );
     190    }
     191
     192    else {
     193
     194      for (i=optind; i < argc; i++) {
     195
     196        // Ensure that the coverage file is readable.
     197        if (!FileIsReadable( argv[i] )) {
     198          fprintf(
     199            stderr,
     200            "WARNING: Unable to read coverage file %s\n",
     201            argv[i]
     202          );
     203        }
     204
     205        else
     206          coverageFileNames.push_back( argv[i] );
     207      }
     208
     209      // If there was at least one coverage file, create the
     210      // executable information.
     211      if (!coverageFileNames.empty()) {
     212        executableInfo = new Coverage::ExecutableInfo( singleExecutable );
     213        executablesToAnalyze.push_back( executableInfo );
     214      }
    187215    }
    188216  }
     
    192220  else {
    193221    for (i = optind; i < argc; i++) {
    194       executableInfo = new Coverage::ExecutableInfo( argv[i] );
    195       executablesToAnalyze.push_back( executableInfo );
    196       coverageFileName = executableInfo->getFileName();
    197       coverageFileName.replace(
    198         coverageFileName.length() - executableExtensionLength,
    199         executableExtensionLength,
    200         coverageFileExtension
    201       );
    202       coverageFileNames.push_back( coverageFileName );
    203     }
     222
     223      // Ensure that the executable is readable.
     224      if (!FileIsReadable( argv[i] )) {
     225        fprintf(
     226          stderr,
     227          "WARNING: Unable to read executable %s\n",
     228          argv[i]
     229        );
     230      }
     231
     232      else {
     233        coverageFileName = argv[i];
     234        coverageFileName.replace(
     235          coverageFileName.length() - executableExtensionLength,
     236          executableExtensionLength,
     237          coverageFileExtension
     238        );
     239
     240        if (!FileIsReadable( coverageFileName.c_str() )) {
     241          fprintf(
     242            stderr,
     243            "WARNING: Unable to read coverage file %s\n",
     244            coverageFileName.c_str()
     245          );
     246        }
     247
     248        else {
     249          executableInfo = new Coverage::ExecutableInfo( argv[i] );
     250          executablesToAnalyze.push_back( executableInfo );
     251          coverageFileNames.push_back( coverageFileName );
     252        }
     253      }
     254    }
     255  }
     256
     257  // Ensure that there is at least one executable to process.
     258  if (executablesToAnalyze.empty()) {
     259    fprintf(
     260      stderr, "ERROR: No information to analyze\n"
     261    );
     262    exit( -1 );
    204263  }
    205264
     
    267326  //
    268327
    269   // Create toolnames based on target.
     328  // Create data based on target.
    270329  TargetInfo = Target::TargetFactory( target );
    271330
     
    330389      );
    331390
    332     // along with its coverage file.
    333     if (coverageReader->processFile( (*citr).c_str(), *eitr )) {
    334 
    335       // Merge each symbols coverage map into a unified coverage map.
    336       (*eitr)->mergeCoverage();
    337     }
     391    // Process its coverage file.
     392    coverageReader->processFile( (*citr).c_str(), *eitr );
     393
     394    // Merge each symbols coverage map into a unified coverage map.
     395    (*eitr)->mergeCoverage();
    338396
    339397    if (!singleExecutable)
Note: See TracChangeset for help on using the changeset viewer.