Ticket #1900: rtems-testing.patch

File rtems-testing.patch, 14.9 KB (added by Pawel, on Aug 31, 2011 at 6:47:40 PM)

Another path to change taken/was taken into counters

  • rtems-testing/covoar/ChangeLog

    RCS file: /usr1/CVS/rtems-testing/covoar/ChangeLog,v
    retrieving revision 1.22
    diff -u -8 -p -r1.22 ChangeLog
     
     12011-08-31      Pawel Zagorski <pzagor@agh.edu.pl>
     2
     3        * covoar/CoverageMapBase.cc, covoar/CoverageMapBase.h,
     4        covoar/DesiredSymbols.cc, covoar/DesiredSymbols.h,
     5        covoar/app_common.cc, covoar/app_common.h,
     6        rtems-coverage/do_coverage:
     7        Modified do_coverage script and source code to gather information
     8        about object files from which symbols originate. Changed tracking
     9        of "branch was taken" and "branch was not taken" from booleans to
     10        counters. Change propagated and new helper methods added:
     11        (getWasTaken, getWasNotTaken, sumWasTaken, sumWasNotTaken)
     12
    1132011-08-21      Pawel Zagorski <pzagor@agh.edu.pl>
    214
    315        PR 1900/testing
    416        * CoverageMapBase.cc, CoverageMapBase.h, DesiredSymbols.cc:
    517        Changed tracking of "instruction was executed" from a boolean
    618        to a counter.  This change was propagated as needed and a helper
    719        method to access new information (getWasExecuted) was added.
    820        * covoar.cc: Removed unnecessary blank line.
  • rtems-testing/covoar/CoverageMapBase.cc

    RCS file: /usr1/CVS/rtems-testing/covoar/CoverageMapBase.cc,v
    retrieving revision 1.5
    diff -u -8 -p -r1.5 CoverageMapBase.cc
    namespace Coverage { 
    3838    for (a=0; a<Size; a++) {
    3939
    4040      perAddressInfo_t *i = &Info[ a ];
    4141
    4242      i->isStartOfInstruction = false;
    4343      i->wasExecuted          = 0;
    4444      i->isBranch             = false;
    4545      i->isNop                = false;
    46       i->wasTaken             = false;
    47       i->wasNotTaken          = false;
     46      i->wasTaken             = 0;
     47      i->wasNotTaken          = 0;
    4848    }
    4949  }
    5050
    5151  CoverageMapBase::~CoverageMapBase()
    5252  {
    5353    if (Info)
    5454      delete Info;
    5555  }
    namespace Coverage { 
    287287    uint32_t    address
    288288  )
    289289  {
    290290    uint32_t offset;
    291291 
    292292    if (determineOffset( address, &offset ) != true)
    293293      return;
    294294
    295     Info[ offset ].wasTaken = true;
     295    Info[ offset ].wasTaken += 1;
    296296  }
    297297
    298298  void CoverageMapBase::setWasNotTaken(
    299299    uint32_t    address
    300300  )
    301301  {
    302302    uint32_t offset;
    303303 
    304304    if (determineOffset( address, &offset ) != true)
    305305      return;
    306306
    307     Info[ offset ].wasNotTaken = true;
     307    Info[ offset ].wasNotTaken += 1;
    308308  }
    309309
    310310  bool CoverageMapBase::wasAlwaysTaken( uint32_t address ) const
    311311  {
    312312    uint32_t offset;
    313313 
    314314    if (determineOffset( address, &offset ) != true)
    315315      return false;
    namespace Coverage { 
    326326      return false;
    327327
    328328    return (!Info[ offset ].wasTaken &&
    329329            Info[ offset ].wasNotTaken);
    330330  }
    331331
    332332  bool CoverageMapBase::wasNotTaken( uint32_t address ) const
    333333  {
     334            uint32_t offset;
     335            bool     result;
     336
     337            result = true;
     338
     339            if (determineOffset( address, &offset ) != true)
     340              result = false;
     341
     342            if (Info[ offset ].wasNotTaken <= 0)
     343              result = false;
     344
     345            return result;
     346  }
     347
     348  void CoverageMapBase::sumWasNotTaken( uint32_t address, uint32_t addition)
     349  {
    334350    uint32_t offset;
    335  
     351
    336352    if (determineOffset( address, &offset ) != true)
    337       return false;
     353      return;
     354
     355    Info[ offset ].wasNotTaken += addition;
     356  }
     357
     358  uint32_t CoverageMapBase::getWasNotTaken( uint32_t address ) const
     359  {
     360    uint32_t offset;
     361
     362    if (determineOffset( address, &offset ) != true)
     363      return 0;
    338364
    339365    return Info[ offset ].wasNotTaken;
    340366  }
    341367
    342368  bool CoverageMapBase::wasTaken( uint32_t address ) const
    343369  {
    344370    uint32_t offset;
     371    bool     result;
     372
     373    result = true;
    345374 
    346375    if (determineOffset( address, &offset ) != true)
    347       return false;
     376      result = false;
     377
     378    if (Info[ offset ].wasTaken <= 0)
     379      result = false;
     380
     381    return result;
     382  }
     383
     384  void CoverageMapBase::sumWasTaken( uint32_t address, uint32_t addition)
     385  {
     386    uint32_t offset;
     387
     388    if (determineOffset( address, &offset ) != true)
     389      return;
     390
     391    Info[ offset ].wasTaken += addition;
     392  }
     393
     394  uint32_t CoverageMapBase::getWasTaken( uint32_t address ) const
     395  {
     396    uint32_t offset;
     397
     398    if (determineOffset( address, &offset ) != true)
     399      return 0;
    348400
    349401    return Info[ offset ].wasTaken;
    350402  }
    351403}
  • rtems-testing/covoar/CoverageMapBase.h

    RCS file: /usr1/CVS/rtems-testing/covoar/CoverageMapBase.h,v
    retrieving revision 1.4
    diff -u -8 -p -r1.4 CoverageMapBase.h
    namespace Coverage { 
    248248     *  @param[in] address specifies the address to check
    249249     *
    250250     *  @return Returns TRUE if a branch instruction is at the
    251251     *   specified address and FALSE otherwise.
    252252     */
    253253    bool isBranch( uint32_t address ) const;
    254254
    255255    /*!
    256      *  This method sets the boolean which indicates if the branch
    257      *  at the specified address was taken.
     256     *  This method increments the counter which indicates how many times
     257     *  the branch at the specified address was taken.
    258258     *
    259259     *  @param[in] address specifies the address of the branch instruction
    260260     */
    261261    void setWasTaken( uint32_t address );
    262262
    263263    /*!
    264      *  This method sets the boolean which indicates if the branch
    265      *  at the specified address was NOT taken.
     264     *  This method increases the counter which indicates how many times
     265     *  the branch at the specified address was taken. It is used
     266     *  for merging coverage maps.
     267     *
     268     *  @param[in] address specifies the address which was executed
     269     *  @param[in] address specifies the execution count that should be
     270     *             added
     271     */
     272    virtual void sumWasTaken( uint32_t address, uint32_t addition );
     273
     274    /*!
     275     *  This method returns an unsigned integer which indicates how often
     276     *  the branch at the specified address was taken.
     277     *
     278     *  @param[in] address specifies the address to check
     279     *
     280     *  @return Returns number of executins
     281     */
     282    uint32_t getWasTaken( uint32_t address ) const;
     283
     284    /*!
     285     *  This method increments the counter which indicates how many times
     286     *  the branch at the specified address was not taken.
    266287     *
    267288     *  @param[in] address specifies the address of the branch instruction
    268289     */
    269290    void setWasNotTaken( uint32_t address );
    270291
    271292    /*!
     293     *  This method increases the counter which indicates how many times
     294     *  the branch at the specified address was not taken. It is used
     295     *  for merging coverage maps.
     296     *
     297     *  @param[in] address specifies the address which was executed
     298     *  @param[in] address specifies the execution count that should be
     299     *             added
     300     */
     301    virtual void sumWasNotTaken( uint32_t address, uint32_t addition );
     302
     303    /*!
     304     *  This method returns an unsigned integer which indicates how often
     305     *  the branch at the specified address was not taken.
     306     *
     307     *  @param[in] address specifies the address to check
     308     *
     309     *  @return Returns number of executins
     310     */
     311    uint32_t getWasNotTaken( uint32_t address ) const;
     312
     313
     314    /*!
    272315     *  This method returns a boolean which indicates if the branch
    273316     *  instruction at the specified address is ALWAYS taken.
    274317     *
    275318     *  @param[in] address specifies the address to check
    276319     *
    277320     *  @return Returns TRUE if the branch instruction at the
    278321     *   specified address is ALWAYS taken and FALSE otherwise.
    279322     */
    namespace Coverage { 
    335378      /*!
    336379       *  This member indicates that the address is a NOP instruction.
    337380       */
    338381      bool isNop;
    339382      /*!
    340383       *  When isBranch is TRUE, this member indicates that the branch
    341384       *  instruction at the address was taken.
    342385       */
    343       bool wasTaken;
     386      uint32_t wasTaken;
    344387      /*!
    345388       *  When isBranch is TRUE, this member indicates that the branch
    346389       *  instruction at the address was NOT taken.
    347390       */
    348       bool wasNotTaken;
     391      uint32_t wasNotTaken;
    349392    } perAddressInfo_t;
    350393
    351394    /*!
    352395     *
    353396     *  This is a list of address ranges for this symbolic address.
    354397     */
    355398    AddressRange RangeList;
    356399
  • rtems-testing/covoar/DesiredSymbols.cc

    RCS file: /usr1/CVS/rtems-testing/covoar/DesiredSymbols.cc,v
    retrieving revision 1.8
    diff -u -8 -p -r1.8 DesiredSymbols.cc
    namespace Coverage { 
    2929  DesiredSymbols::~DesiredSymbols()
    3030  {
    3131  }
    3232
    3333  void DesiredSymbols::load(
    3434    const char* const symbolsFile
    3535  )
    3636  {
    37     char*                   cStatus;
     37    int                   cStatus;
    3838    bool                    done = false;
    3939    FILE*                   sFile;
    4040    SymbolInformation*      symInfo;
    4141    int                     line = 1;
    4242    std::string             symbol;
    4343
    4444    // Ensure that symbols file name is given.
    4545    if ( !symbolsFile ) {
    namespace Coverage { 
    6464    // Process symbols file.
    6565    while ( !done ) {
    6666
    6767      symInfo = new SymbolInformation;
    6868
    6969      // Skip blank lines between symbols
    7070      do {
    7171        inputBuffer[0] = '\0';
    72         cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, sFile );
    73         if ( cStatus == NULL ) {
     72        inputBuffer2[0] = '\0';
     73        cStatus = fscanf( sFile, "%s %s", inputBuffer, inputBuffer2 );
     74        //TODO: Store inputBuffer2 value containing symbol source file
     75        if ( cStatus == EOF ) {
    7476          done = true;
    7577        }
    7678        else {
    77           inputBuffer[ strlen(inputBuffer) - 1] = '\0';
     79          //inputBuffer[ strlen(inputBuffer) - 1] = '\0';
    7880          line++;
    7981        }
    8082      } while ( !done && (inputBuffer[0] == '\0') );
    8183
    8284      // Have we already seen this one?
    8385      if ( !done ) {
    8486        if (set.find( inputBuffer ) != set.end()) {
    8587          fprintf(
    namespace Coverage { 
    673675      if (sourceCoverageMap->isStartOfInstruction( sAddress ))
    674676        destinationCoverageMap->setIsStartOfInstruction( dAddress );
    675677
    676678      // Merge the execution data.
    677679      executionCount = sourceCoverageMap->getWasExecuted( sAddress );
    678680      destinationCoverageMap->sumWasExecuted( dAddress, executionCount );
    679681
    680682      // Merge the branch data.
    681       if (sourceCoverageMap->wasTaken( sAddress ))
    682         destinationCoverageMap->setWasTaken( dAddress );
     683      executionCount = sourceCoverageMap->getWasTaken( sAddress );
     684      destinationCoverageMap->sumWasTaken( dAddress, executionCount );
    683685
    684       if (sourceCoverageMap->wasNotTaken( sAddress ))
    685         destinationCoverageMap->setWasNotTaken( dAddress );
     686      executionCount = sourceCoverageMap->getWasNotTaken( sAddress );
     687      destinationCoverageMap->sumWasNotTaken( dAddress, executionCount );
    686688    }
    687689  }
    688690
    689691}
  • rtems-testing/covoar/DesiredSymbols.h

    RCS file: /usr1/CVS/rtems-testing/covoar/DesiredSymbols.h,v
    retrieving revision 1.2
    diff -u -8 -p -r1.2 DesiredSymbols.h
    namespace Coverage { 
    185185  public:
    186186
    187187    /*!
    188188     *  This map associates each symbol with its symbol information.
    189189     */
    190190    typedef std::map<std::string, SymbolInformation> symbolSet_t;
    191191
    192192    /*!
    193      *  This variable contains a map of ymbol sets for each
     193     *  This variable contains a map of symbol sets for each
    194194     *  symbol in the system keyed on the symbol name.
    195195     */
    196196    symbolSet_t set;
    197197
    198198    /*!
    199199     *  This method constructs a DesiredSymbols instance.
    200200     */
    201201    DesiredSymbols();
  • rtems-testing/covoar/app_common.cc

    RCS file: /usr1/CVS/rtems-testing/covoar/app_common.cc,v
    retrieving revision 1.2
    diff -u -8 -p -r1.2 app_common.cc
    Coverage::ObjdumpProcessor* objdumpProce 
    3030Coverage::DesiredSymbols*   SymbolsToAnalyze    = NULL;
    3131bool                        Verbose             = false;
    3232const char*                 outputDirectory     = ".";
    3333bool                        BranchInfoAvailable = false;
    3434Target::TargetBase*         TargetInfo          = NULL;
    3535const char*                 dynamicLibrary      = NULL;
    3636const char*                 projectName         = NULL;
    3737char                        inputBuffer[MAX_LINE_LENGTH];
     38char                        inputBuffer2[MAX_LINE_LENGTH];
    3839
    3940
    4041bool FileIsNewer(
    4142  const char *f1,
    4243  const char *f2
    4344)
    4445{
    4546  struct STAT buf1, buf2;
  • rtems-testing/covoar/app_common.h

    RCS file: /usr1/CVS/rtems-testing/covoar/app_common.h,v
    retrieving revision 1.2
    diff -u -8 -p -r1.2 app_common.h
    extern bool Verb 
    1818extern const char*                  outputDirectory;
    1919extern bool                         BranchInfoAvailable;
    2020extern Target::TargetBase*          TargetInfo;
    2121extern const char*                  dynamicLibrary;
    2222extern const char*                  projectName;
    2323
    2424#define MAX_LINE_LENGTH             512
    2525extern char                         inputBuffer[MAX_LINE_LENGTH];
     26extern char                         inputBuffer2[MAX_LINE_LENGTH];
    2627
    2728
    2829bool FileIsNewer( const char *f1, const char *f2 );
    2930bool FileIsReadable( const char *f1 );
    3031bool ReadUntilFound( FILE *file, const char *line );
    3132
    3233#endif
  • rtems-testing/rtems-coverage/do_coverage

    RCS file: /usr1/CVS/rtems-testing/rtems-coverage/do_coverage,v
    retrieving revision 1.75
    diff -u -8 -p -r1.75 do_coverage
    generate_reports() 
    458458filter_nm()
    459459{
    460460  for l in $*
    461461  do
    462462    if [ -r ${l} ] ; then
    463463      test ${verbose} = "yes" && echo Generating symbols from ${l} >&2
    464464      # echo "========= START $l"
    465465      ${TARGET}-nm --format=sysv $l | grep "FUNC|" | \
    466         cut -d'|' -f1 | sed -e 's/ *$//'
     466        cut -d'|' -f1 | sed -e 's/ *$//' -e "s,$, ${l},"
     467
    467468      # echo "========= END $l"
    468469
    469470    # no else
    470471      # We keep a complete CURRENT list and some are not in old versions
    471472    fi
    472473  done
    473474}
    474475