Changeset bf8e59f in rtems-tools


Ignore:
Timestamp:
Jun 21, 2018, 7:55:24 AM (10 months ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
e86646c
Parents:
6ab939e
Message:

covoar: Covert CoverageMapBase? C to C++

Updates #3462

Location:
tester/covoar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tester/covoar/CoverageMapBase.cc

    r6ab939e rbf8e59f  
    88
    99#include <limits.h>
    10 #include <stdio.h>
    11 #include <stdlib.h>
     10
     11#include <iostream>
     12#include <iomanip>
    1213
    1314#include "CoverageMapBase.h"
     
    2122  )
    2223  {
    23     uint32_t       a;
    24     AddressRange_t range;
     24    uint32_t     a;
     25    AddressRange range;
    2526
    2627    range.fileName    = exefileName;
    2728    range.lowAddress  = low;
    2829    range.highAddress = high;
    29     RangeList.push_back( range );
     30    Ranges.push_back( range );
    3031
    3132    Size = high - low + 1;
    3233
    33     Info = new perAddressInfo_t[ Size ];
    34 
    35     for (a=0; a<Size; a++) {
    36 
    37       perAddressInfo_t *i = &Info[ a ];
     34    Info = new perAddressInfo[ Size ];
     35
     36    for (a = 0; a < Size; a++) {
     37
     38      perAddressInfo *i = &Info[ a ];
    3839
    3940      i->isStartOfInstruction = false;
     
    5455  void  CoverageMapBase::Add( uint32_t low, uint32_t high )
    5556  {
    56     AddressRange_t range;
     57    AddressRange range;
    5758
    5859    range.lowAddress  = low;
    5960    range.highAddress = high;
    60     RangeList.push_back( range );
     61    Ranges.push_back( range );
    6162  }
    6263
     
    6667  )const
    6768  {
    68     AddressRange::const_iterator  itr;
    69 
    70     for ( itr = RangeList.begin(); itr != RangeList.end(); itr++ ) {
    71       if ((address >= itr->lowAddress) && (address <= itr->highAddress)){
    72         *offset = address - itr->lowAddress;
     69    AddressRanges::const_iterator  itr;
     70
     71    for ( auto& r : Ranges ) {
     72      if ((address >= r.lowAddress) && (address <= r.highAddress)){
     73        *offset = address - r.lowAddress;
    7374        return true;
    7475      }
     
    7980
    8081
    81   void CoverageMapBase::dump( void ) const {
    82 
    83     uint32_t          a;
    84     perAddressInfo_t* entry;
    85 
     82  void CoverageMapBase::dump( void ) const
     83  {
    8684    fprintf( stderr, "Coverage Map Contents:\n" );
    87 
    8885    /*
    8986     * XXX - Dump is only marking the first Address Range.
    9087     */
    91 
    92     for (a = 0; a < Size; a++) {
    93 
    94       entry = &Info[ a ];
    95 
    96       fprintf(
    97         stderr,
    98         "0x%x - isStartOfInstruction = %s, wasExecuted = %s\n",
    99         a + RangeList.front().lowAddress,
    100         entry->isStartOfInstruction ? "TRUE" : "FALSE",
    101         entry->wasExecuted ? "TRUE" : "FALSE"
    102       );
    103       fprintf(
    104         stderr,
    105         "           isBranch = %s, wasTaken = %s, wasNotTaken = %s\n",
    106         entry->isBranch ? "TRUE" : "FALSE",
    107         entry->wasTaken ? "TRUE" : "FALSE",
    108         entry->wasNotTaken ? "TRUE" : "FALSE"
    109       );
     88    for (uint32_t a = 0; a < Size; a++) {
     89      perAddressInfo* entry = &Info[ a ];
     90      std::cerr << std::hex << std::setfill('0')
     91                << "0x" << a + Ranges.front().lowAddress
     92                << "- isStartOfInstruction:"
     93                << (char*) (entry->isStartOfInstruction ? "yes" : "no")
     94                << " wasExecuted:"
     95                << (char*) (entry->wasExecuted ? "yes" : "no")
     96                << std::endl
     97                << "           isBranch:"
     98                << (char*) (entry->isBranch ? "yes" : "no")
     99                << " wasTaken:"
     100                << (char*) (entry->wasTaken ? "yes" : "no")
     101                << " wasNotTaken:"
     102                << (char*) (entry->wasNotTaken ? "yes" : "no")
     103                << std::dec << std::setfill(' ')
     104                << std::endl;
    110105    }
    111106  }
     
    116111  ) const
    117112  {
    118     bool           status = false;
    119     uint32_t       start;
    120     AddressRange_t range;
     113    bool         status = false;
     114    uint32_t     start;
     115    AddressRange range;
    121116
    122117
     
    142137  int32_t CoverageMapBase::getFirstLowAddress() const
    143138  {
    144     return RangeList.front().lowAddress;
    145   }
    146 
    147   bool CoverageMapBase::getRange( uint32_t address, AddressRange_t *range ) const
    148   {
    149     AddressRange::const_iterator  itr;
    150 
    151     for ( itr = RangeList.begin(); itr != RangeList.end(); itr++ ) {
    152       if ((address >= itr->lowAddress) && (address <= itr->highAddress)){
    153         range->lowAddress = itr->lowAddress;
    154         range->highAddress = itr->highAddress;
     139    return Ranges.front().lowAddress;
     140  }
     141
     142  bool CoverageMapBase::getRange( uint32_t address, AddressRange *range ) const
     143  {
     144    for ( auto r : Ranges ) {
     145      if ((address >= r.lowAddress) && (address <= r.highAddress)){
     146        range->lowAddress = r.lowAddress;
     147        range->highAddress = r.highAddress;
    155148        return true;
    156149      }
  • tester/covoar/CoverageMapBase.h

    r6ab939e rbf8e59f  
    2424    /*!
    2525     *  This structure identifies the low and high addresses
    26      *  of one range.  Note:: There may be more than one address 
     26     *  of one range.  Note:: There may be more than one address
    2727     *  range per symbol.
    2828     */
    29     typedef struct {
     29    struct AddressRange {
    3030      /*!
    3131       *  This is the file from which this originated.
     
    4343      uint32_t highAddress;
    4444
    45     } AddressRange_t;
     45    };
    4646
    4747    /*
    4848     *  This type identifies a list of ranges.
    4949     */
    50     typedef std::list< AddressRange_t >           AddressRange;
    51     typedef std::list< AddressRange_t >::iterator AddressRangeIterator_t;
    52 
    53     /*!
     50    typedef std::list< AddressRange >  AddressRanges;
     51
     52    /*!
    5453     *  This method constructs a CoverageMapBase instance.
    5554     *
     
    6463    );
    6564
    66     /*! 
     65    /*!
    6766     *  This method destructs a CoverageMapBase instance.
    6867     */
     
    7473     *  @param[in]  Low specifies the lowAddress
    7574     *  @param[in]  High specifies the highAddress
    76      * 
     75     *
    7776     */
    7877    void Add( uint32_t low, uint32_t high );
    79  
     78
    8079    /*!
    8180     *  This method returns true and sets the offset if
    82      *  the address falls with the bounds of an address range 
     81     *  the address falls with the bounds of an address range
    8382     *  in the RangeList.
    8483     *
     
    8685     *  @param[out] offset contains the offset from the low
    8786     *              address of the address range.
    88      * 
     87     *
    8988     *  @return Returns TRUE if the address range can be found
    9089     *   and FALSE if it was not.
     
    108107    /*!
    109108     *  This method returns true and sets the address range if
    110      *  the address falls with the bounds of an address range 
     109     *  the address falls with the bounds of an address range
    111110     *  in the RangeList.
    112111     *
     
    114113     *  @param[out] range contains the high and low addresse for
    115114     *              the range
    116      * 
     115     *
    117116     *  @return Returns TRUE if the address range can be found
    118117     *   and FALSE if it was not.
    119118     */
    120     bool getRange( uint32_t address, AddressRange_t *range ) const;
     119    bool getRange( uint32_t address, AddressRange *range ) const;
    121120
    122121    /*!
    123122     *  This method returns the size of the address range.
    124      * 
     123     *
    125124     *  @return Returns Size of the address range.
    126125     */
     
    135134     *  @param[out] beginning contains the address of the beginning of
    136135     *              the instruction.
    137      * 
     136     *
    138137     *  @return Returns TRUE if the beginning of the instruction was
    139138     *   found and FALSE if it was not.
     
    192191     *
    193192     *  @param[in] address specifies the address to check
    194      * 
     193     *
    195194     *  @return Returns TRUE if the instruction at the specified
    196195     *   address was executed and FALSE otherwise.
     
    214213     *
    215214     *  @param[in] address specifies the address to check
    216      * 
     215     *
    217216     *  @return Returns number of executins
    218217     */
     
    366365     *  tracked per address.
    367366     */
    368     typedef struct {
     367    struct perAddressInfo {
    369368      /*!
    370369       *  This member indicates that the address is the start of
     
    394393       */
    395394      uint32_t wasNotTaken;
    396     } perAddressInfo_t;
    397 
    398     /*!
    399      * 
     395    };
     396
     397    /*!
     398     *
    400399     *  This is a list of address ranges for this symbolic address.
    401400     */
    402     AddressRange RangeList;
    403 
    404     /*!
    405      * 
     401    AddressRanges Ranges;
     402
     403    /*!
     404     *
    406405     *  This variable contains the size of the code block.
    407406     */
     
    412411     *  kept for each address.
    413412     */
    414     perAddressInfo_t* Info;
     413    perAddressInfo* Info;
    415414  };
    416415
  • tester/covoar/ExecutableInfo.cc

    r6ab939e rbf8e59f  
    3232    debug.begin(executable.elf());
    3333    debug.load_debug();
     34    debug.load_functions();
    3435  }
    3536
     
    9091  }
    9192
    92 
    9393  SymbolTable* ExecutableInfo::getSymbolTable ( void )
    9494  {
     
    103103  )
    104104  {
    105     CoverageMapBase                        *theMap;
    106     ExecutableInfo::CoverageMaps::iterator  itr;
     105    CoverageMapBase        *theMap;
     106    CoverageMaps::iterator  itr;
    107107
    108108    itr = coverageMaps.find( symbolName );
Note: See TracChangeset for help on using the changeset viewer.