Changeset 898a5e8 in rtems-testing


Ignore:
Timestamp:
Jan 25, 2011, 9:26:00 PM (8 years ago)
Author:
Jennifer Averett <Jennifer.Averett@…>
Branches:
4.11, 8895273c193787f84c4585a10f6d6aceb3b25dc4
Children:
f1698c78
Parents:
ccbc6aa
Message:

2011-01-25 Jennifer Averett <Jennifer.Averett@…>

Location:
covoar
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • covoar/ChangeLog

    rccbc6aa r898a5e8  
     12011-01-25      Jennifer Averett <Jennifer.Averett@OARcorp.com>
     2
     3        * CoverageMapBase.cc, CoverageMapBase.h, CoverageReaderQEMU.cc,
     4        DesiredSymbols.cc, ExecutableInfo.cc, SymbolTable.cc, SymbolTable.h:
     5        Modifications to track multiple address ranges for the same symbol.
     6
    172011-01-25      Joel Sherrill <joel.sherrill@oarcorp.com>
    28
  • covoar/CoverageMapBase.cc

    rccbc6aa r898a5e8  
    2323    uint32_t low,
    2424    uint32_t high
    25   ) : lowAddress(low), highAddress(high)
    26   {
    27     uint32_t a;
    28 
    29     Info = new perAddressInfo_t[ high - low + 1 ];
    30 
    31     for (a=low; a<=high; a++) {
    32 
    33       perAddressInfo_t *i = &Info[ a-low ];
     25  )
     26  {
     27    uint32_t       a;
     28    AddressRange_t range;
     29
     30    range.lowAddress  = low;
     31    range.highAddress = high;
     32    RangeList.push_back( range );
     33
     34    Size = high - low + 1;
     35
     36    Info = new perAddressInfo_t[ Size ];
     37
     38    for (a=0; a<Size; a++) {
     39
     40      perAddressInfo_t *i = &Info[ a ];
    3441
    3542      i->isStartOfInstruction = false;
     
    4653      delete Info;
    4754  }
     55 
     56  void  CoverageMapBase::Add( uint32_t low, uint32_t high )
     57  {
     58    AddressRange_t range;
     59
     60    range.lowAddress  = low;
     61    range.highAddress = high;
     62    RangeList.push_back( range );
     63  }
     64 
     65  bool CoverageMapBase::determineOffset(
     66    uint32_t  address,
     67    uint32_t *offset
     68  )const
     69  {
     70    AddressRange::const_iterator  itr;
     71
     72    for ( itr = RangeList.begin(); itr != RangeList.end(); itr++ ) {
     73      if ((address >= itr->lowAddress) && (address <= itr->highAddress)){
     74        *offset = address - itr->lowAddress;
     75        return true;
     76      }
     77    }
     78    *offset = 0;
     79    return false;
     80  }
     81
    4882
    4983  void CoverageMapBase::dump( void ) const {
     
    5488    fprintf( stderr, "Coverage Map Contents:\n" );
    5589
    56     for (a = lowAddress; a <= highAddress; a++) {
    57 
    58       entry = &Info[ a - lowAddress ];
     90    /*
     91     * XXX - Dump is only marking the first Address Range.
     92     */
     93
     94    for (a = 0; a < Size; a++) {
     95
     96      entry = &Info[ a ];
    5997
    6098      fprintf(
    6199        stderr,
    62100        "0x%x - isStartOfInstruction = %s, wasExecuted = %s\n",
    63         a,
     101        a + RangeList.front().lowAddress,
    64102        entry->isStartOfInstruction ? "TRUE" : "FALSE",
    65103        entry->wasExecuted ? "TRUE" : "FALSE"
     
    80118  ) const
    81119  {
    82     bool     status = false;
    83     uint32_t start;
    84 
    85     if ((address < lowAddress) || (address > highAddress))
     120    bool           status = false;
     121    uint32_t       start;
     122    AddressRange_t range;
     123
     124
     125    status = getRange( address, &range );
     126    if ( status != true )
    86127      return status;
    87128
    88129    start = address;
    89130
    90     while (start >= lowAddress ) {
    91       if (Info[ start - lowAddress ].isStartOfInstruction) {
     131    while (start >= range.lowAddress ) {
     132      if (Info[ start - range.lowAddress ].isStartOfInstruction) {
    92133        *beginning = start;
    93134        status = true;
     
    101142  }
    102143
    103   uint32_t CoverageMapBase::getHighAddress( void ) const
    104   {
    105     return highAddress;
    106   }
    107 
    108   uint32_t CoverageMapBase::getLowAddress( void ) const
    109   {
    110     return lowAddress;
     144  int32_t CoverageMapBase::getFirstLowAddress() const
     145  {
     146    return RangeList.front().lowAddress;
     147  }
     148
     149  bool CoverageMapBase::getRange( uint32_t address, AddressRange_t *range ) const
     150  {
     151    AddressRange::const_iterator  itr;
     152
     153    for ( itr = RangeList.begin(); itr != RangeList.end(); itr++ ) {
     154      if ((address >= itr->lowAddress) && (address <= itr->highAddress)){
     155        range->lowAddress = itr->lowAddress;
     156        range->highAddress = itr->highAddress;
     157        return true;
     158      }
     159    }
     160
     161    range->lowAddress  = 0;
     162    range->highAddress = 0;
     163
     164    return false;
     165
     166  }
     167
     168  uint32_t CoverageMapBase::getSize() const
     169  {
     170    return Size;
    111171  }
    112172
     
    115175  )
    116176  {
    117     if ((address < lowAddress) || (address > highAddress))
    118       return;
    119     Info[ address - lowAddress ].isStartOfInstruction = true;
     177    uint32_t offset;
     178 
     179    if (determineOffset( address, &offset ) != true)
     180      return;
     181
     182    Info[ offset ].isStartOfInstruction = true;
    120183  }
    121184
    122185  bool CoverageMapBase::isStartOfInstruction( uint32_t address ) const
    123186  {
    124     if ((address < lowAddress) || (address > highAddress))
    125       return false;
    126     return Info[ address - lowAddress ].isStartOfInstruction;
     187    uint32_t offset;
     188 
     189    if (determineOffset( address, &offset ) != true)
     190      return false;
     191
     192    return Info[ offset ].isStartOfInstruction;
    127193  }
    128194
    129195  void CoverageMapBase::setWasExecuted( uint32_t address )
    130196  {
    131     if ((address < lowAddress) || (address > highAddress))
    132       return;
    133     Info[ address - lowAddress ].wasExecuted = true;
     197    uint32_t offset;
     198 
     199    if (determineOffset( address, &offset ) != true)
     200      return;
     201
     202    Info[ offset ].wasExecuted = true;
    134203  }
    135204
    136205  bool CoverageMapBase::wasExecuted( uint32_t address ) const
    137206  {
    138     if ((address < lowAddress) || (address > highAddress))
    139       return false;
    140     return Info[ address - lowAddress ].wasExecuted;
     207    uint32_t offset;
     208 
     209    if (determineOffset( address, &offset ) != true)
     210      return false;
     211
     212   return Info[ offset ].wasExecuted;
    141213  }
    142214
     
    145217  )
    146218  {
    147     if ((address < lowAddress) || (address > highAddress))
    148       return;
    149     Info[ address - lowAddress ].isBranch = true;
     219    uint32_t offset;
     220 
     221    if (determineOffset( address, &offset ) != true)
     222      return;
     223
     224    Info[ offset ].isBranch = true;
    150225  }
    151226
    152227  bool CoverageMapBase::isNop( uint32_t address ) const
    153228  {
    154     if ((address < lowAddress) || (address > highAddress))
    155       return false;
    156     return Info[ address - lowAddress ].isNop;
     229    uint32_t offset;
     230 
     231    if (determineOffset( address, &offset ) != true)
     232      return false;
     233
     234    return Info[ offset ].isNop;
    157235  }
    158236
     
    161239  )
    162240  {
    163     if ((address < lowAddress) || (address > highAddress))
    164       return;
    165     Info[ address - lowAddress ].isNop = true;
     241    uint32_t offset;
     242 
     243    if (determineOffset( address, &offset ) != true)
     244      return;
     245
     246    Info[ offset ].isNop = true;
    166247  }
    167248
    168249  bool CoverageMapBase::isBranch( uint32_t address ) const
    169250  {
    170     if ((address < lowAddress) || (address > highAddress))
    171       return false;
    172     return Info[ address - lowAddress ].isBranch;
     251    uint32_t offset;
     252 
     253    if (determineOffset( address, &offset ) != true)
     254      return false;
     255
     256    return Info[ offset ].isBranch;
    173257  }
    174258
     
    177261  )
    178262  {
    179     if ((address < lowAddress) || (address > highAddress))
    180       return;
    181     Info[ address - lowAddress ].wasTaken = true;
     263    uint32_t offset;
     264 
     265    if (determineOffset( address, &offset ) != true)
     266      return;
     267
     268    Info[ offset ].wasTaken = true;
    182269  }
    183270
     
    186273  )
    187274  {
    188     if ((address < lowAddress) || (address > highAddress))
    189       return;
    190     Info[ address - lowAddress ].wasNotTaken = true;
     275    uint32_t offset;
     276 
     277    if (determineOffset( address, &offset ) != true)
     278      return;
     279
     280    Info[ offset ].wasNotTaken = true;
    191281  }
    192282
    193283  bool CoverageMapBase::wasAlwaysTaken( uint32_t address ) const
    194284  {
    195     if ((address < lowAddress) || (address > highAddress))
    196       return false;
    197     return (Info[ address - lowAddress ].wasTaken &&
    198             !Info[ address - lowAddress ].wasNotTaken);
     285    uint32_t offset;
     286 
     287    if (determineOffset( address, &offset ) != true)
     288      return false;
     289
     290    return (Info[ offset ].wasTaken &&
     291            !Info[ offset ].wasNotTaken);
    199292  }
    200293
    201294  bool CoverageMapBase::wasNeverTaken( uint32_t address ) const
    202295  {
    203     if ((address < lowAddress) || (address > highAddress))
    204       return false;
    205     return (!Info[ address - lowAddress ].wasTaken &&
    206             Info[ address - lowAddress ].wasNotTaken);
     296    uint32_t offset;
     297 
     298    if (determineOffset( address, &offset ) != true)
     299      return false;
     300
     301    return (!Info[ offset ].wasTaken &&
     302            Info[ offset ].wasNotTaken);
    207303  }
    208304
    209305  bool CoverageMapBase::wasNotTaken( uint32_t address ) const
    210306  {
    211     return (Info[ address - lowAddress ].wasNotTaken);
     307    uint32_t offset;
     308 
     309    if (determineOffset( address, &offset ) != true)
     310      return false;
     311
     312    return Info[ offset ].wasNotTaken;
    212313  }
    213314
    214315  bool CoverageMapBase::wasTaken( uint32_t address ) const
    215316  {
    216     return (Info[ address - lowAddress ].wasTaken);
     317    uint32_t offset;
     318 
     319    if (determineOffset( address, &offset ) != true)
     320      return false;
     321
     322    return Info[ offset ].wasTaken;
    217323  }
    218324}
  • covoar/CoverageMapBase.h

    rccbc6aa r898a5e8  
    1414#include <stdint.h>
    1515#include <string>
     16#include <list>
    1617
    1718namespace Coverage {
     
    2526  public:
    2627
     28    /*!
     29     *  This structure identifies the low and high addresses
     30     *  of one range.  Note:: There may be more than one address
     31     *  range per symbol.
     32     */
     33    typedef struct {
     34      /*!
     35       *  This is the low address of the address map range.
     36       */
     37      uint32_t lowAddress;
     38
     39      /*!
     40       *  This is the high address of the address map range.
     41       */
     42      uint32_t highAddress;
     43
     44    } AddressRange_t;
     45
     46    /*
     47     *  This type identifies a list of ranges.
     48     */
     49    typedef std::list< AddressRange_t > AddressRange;
     50
    2751    /*!
    2852     *  This method constructs a CoverageMapBase instance.
     
    4266
    4367    /*!
     68     *  This method adds a address range to the RangeList.
     69     *
     70     *  @param[in]  Low specifies the lowAddress
     71     *  @param[in]  High specifies the highAddress
     72     * 
     73     */
     74    void Add( uint32_t low, uint32_t high );
     75 
     76    /*!
     77     *  This method returns true and sets the offset if
     78     *  the address falls with the bounds of an address range
     79     *  in the RangeList.
     80     *
     81     *  @param[in]  address specifies the address to find
     82     *  @param[out] offset contains the offset from the low
     83     *              address of the address range.
     84     * 
     85     *  @return Returns TRUE if the address range can be found
     86     *   and FALSE if it was not.
     87      */
     88    bool determineOffset( uint32_t address, uint32_t *offset ) const;
     89
     90    /*!
    4491     *  This method prints the contents of the coverage map to stdout.
    4592     */
    4693    void dump( void ) const;
     94
     95    /*!
     96     *  This method will return the low address of the first range in
     97     *  the RangeList.
     98     *
     99     *  @return Returns the low address of the first range in
     100     *  the RangeList.
     101     */
     102    int32_t getFirstLowAddress() const;
     103
     104    /*!
     105     *  This method returns true and sets the address range if
     106     *  the address falls with the bounds of an address range
     107     *  in the RangeList.
     108     *
     109     *  @param[in]  address specifies the address to find
     110     *  @param[out] range contains the high and low addresse for
     111     *              the range
     112     * 
     113     *  @return Returns TRUE if the address range can be found
     114     *   and FALSE if it was not.
     115     */
     116    bool getRange( uint32_t address, AddressRange_t *range ) const;
     117
     118    /*!
     119     *  This method returns the size of the address range.
     120     *
     121     *  @return Returns Size of the address range.
     122     */
     123    uint32_t getSize() const;
     124
    47125
    48126    /*!
     
    66144     *
    67145     *  @return Returns the high address of the coverage map.
    68      */
    69146    uint32_t getHighAddress( void ) const;
     147     */
    70148
    71149    /*!
     
    73151     *
    74152     *  @return Returns the low address of the coverage map.
    75      */
    76153    uint32_t getLowAddress( void ) const;
     154     */
    77155
    78156    /*!
     
    251329
    252330    /*!
     331     *
     332     *  This is a list of address ranges for this symbolic address.
     333     */
     334    AddressRange RangeList;
     335
     336    /*!
     337     * 
     338     *  This variable contains the size of the code block.
     339     */
     340    uint32_t Size;
     341
     342    /*!
    253343     *  This is a dynamically allocated array of data that is
    254344     *  kept for each address.
    255345     */
    256346    perAddressInfo_t* Info;
    257 
    258     /*!
    259      *  This is the low address of the address map range.
    260      */
    261     uint32_t lowAddress;
    262 
    263     /*!
    264      *  This is the high address of the address map range.
    265      */
    266     uint32_t highAddress;
    267 
    268347  };
    269348
  • covoar/CoverageReaderQEMU.cc

    rccbc6aa r898a5e8  
    142142        // Determine if additional branch information is available.
    143143        if ( (entry->op & branchInfo) != 0 ) {
    144           unsigned int a = entry->pc + entry->size - 1;
    145           if ( (entry->pc < aCoverageMap->getLowAddress()) ||
    146                (entry->pc > aCoverageMap->getHighAddress()) ||
    147                (a < aCoverageMap->getLowAddress()) ||
    148                (a > aCoverageMap->getHighAddress()) ) {
     144          uint32_t  offset_e, offset_a;
     145          uint32_t  a = entry->pc + entry->size - 1;
     146          if ((aCoverageMap->determineOffset( a, &offset_a ) != true)  ||
     147             (aCoverageMap->determineOffset( entry->pc, &offset_e ) != true))
     148          {
    149149            fprintf(
    150150              stderr,
    151151              "*** Trace block is inconsistent with coverage map\n"
    152152              "*** Trace block (0x%08x - 0x%08x) for %d bytes\n"
    153               "*** Coverage map (0x%08x - 0x%08x) for %d bytes\n",
     153              "*** Coverage map XXX \n",
    154154              entry->pc,
    155155              a,
    156               entry->size,
    157               aCoverageMap->getLowAddress(),
    158               aCoverageMap->getHighAddress(),
    159               aCoverageMap->getHighAddress() - aCoverageMap->getLowAddress()
    160            );
     156              entry->size
     157            );
    161158          } else {
    162159            while (!aCoverageMap->isStartOfInstruction(a))
  • covoar/DesiredSymbols.cc

    rccbc6aa r898a5e8  
    9090            inputBuffer
    9191          );
     92
     93          delete symInfo;
    9294        }
    9395
     
    628630    uint32_t              sBaseAddress;
    629631    uint32_t              sMapSize;
    630 
     632   
    631633    // Ensure that the symbol is a desired symbol.
    632634    itr = set.find( symbolName );
     
    646648    // are the same size.
    647649    dMapSize = itr->second.stats.sizeInBytes;
    648     sBaseAddress = sourceCoverageMap->getLowAddress();
    649     sMapSize = sourceCoverageMap->getHighAddress() - sBaseAddress + 1;
     650    sBaseAddress = sourceCoverageMap->getFirstLowAddress();
     651    sMapSize = sourceCoverageMap->getSize();
    650652    if (dMapSize != sMapSize) {
    651653
  • covoar/ExecutableInfo.cc

    rccbc6aa r898a5e8  
    9191  )
    9292  {
    93     CoverageMapBase* theMap;
     93    CoverageMapBase                          *theMap;
     94    ExecutableInfo::coverageMaps_t::iterator  itr;
    9495
    95     theMap = coverageMaps.find( symbolName );
    96     if ( theMap == std::map.end() ) {
     96    itr = coverageMaps.find( symbolName );
     97    if ( itr == coverageMaps.end() ) {
    9798      theMap = new CoverageMap( lowAddress, highAddress );
    9899      coverageMaps[ symbolName ] = theMap;
    99100    } else {
     101      theMap = itr->second;
    100102      theMap->Add( lowAddress, highAddress );
    101103    }
  • covoar/SymbolTable.cc

    rccbc6aa r898a5e8  
    3434  )
    3535  {
    36     uint32_t       end = 0;
    37     symbol_entry_t entry;
    38     symbolInfo     symbolData;
     36    uint32_t         end = 0;
     37    symbol_entry_t   entry;
     38    symbolInfo_t     symbolData;
    3939
    4040    // Add an entry to the address map.
     
    4848    symbolData.startingAddress = start;
    4949    symbolData.length = length;
    50     info[ symbol ] = symbolData;
     50     
     51    if ( info[ symbol ].empty() == false ) {
     52      if ( info[symbol ].front().length != length ) {
     53        fprintf(stderr, "ERROR==> Different lengths for the symbol %s\n", symbol.c_str() );
     54        exit( 0 );
     55      }
     56    }
     57   
     58    info[ symbol ].push_back( symbolData );
    5159  }
    5260
     
    7280      return 0;
    7381    else
    74       return ((*it).second.length);
     82      return ((*it).second.front().length);
    7583  }
    7684
  • covoar/SymbolTable.h

    rccbc6aa r898a5e8  
    1515#include <string>
    1616#include <map>
     17#include <list>
    1718
    1819namespace Coverage {
     
    3435      uint32_t startingAddress;
    3536      uint32_t length;
    36     } symbolInfo;
     37    } symbolInfo_t;
     38 
     39   typedef std::list< symbolInfo_t > symbolInfo;
     40 
     41   
    3742
    3843    /*!
Note: See TracChangeset for help on using the changeset viewer.