From 092bf04cd2ac4f5cbd632ede174692c20782cbf5 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 6 Apr 2021 15:40:42 -0500 Subject: covoar: Eliminate tabs --- tester/covoar/CoverageReaderTSIM.cc | 16 +- tester/covoar/CoverageWriterTSIM.cc | 4 +- tester/covoar/GcovData.cc | 719 ++++++++++++++++++------------------ tester/covoar/GcovData.h | 80 ++-- tester/covoar/GcovFunctionData.cc | 43 +-- tester/covoar/GcovFunctionData.h | 111 +++--- tester/covoar/ReportsHtml.cc | 6 +- tester/covoar/SymbolTable.cc | 6 +- tester/covoar/SymbolTable.h | 4 +- tester/covoar/Target_riscv.h | 8 +- 10 files changed, 501 insertions(+), 496 deletions(-) diff --git a/tester/covoar/CoverageReaderTSIM.cc b/tester/covoar/CoverageReaderTSIM.cc index d8b738e..03bf7a8 100644 --- a/tester/covoar/CoverageReaderTSIM.cc +++ b/tester/covoar/CoverageReaderTSIM.cc @@ -64,7 +64,7 @@ namespace Coverage { for (i = 0; i < 0x80; i += 4) { unsigned int a; status = ::fscanf( coverageFile, "%x", &cover ); - if (status == EOF || status == 0) { + if (status == EOF || status == 0) { std::cerr << "CoverageReaderTSIM: WARNING! Short line in " << file << " at address 0x" @@ -73,14 +73,14 @@ namespace Coverage { << std::setfill(' ') << std::dec << std::endl; break; - } + } // // Obtain the coverage map containing the address and // mark the address as executed. // - a = baseAddress + i; - aCoverageMap = executableInformation->getCoverageMap( a ); + a = baseAddress + i; + aCoverageMap = executableInformation->getCoverageMap( a ); if ( !aCoverageMap ) continue; if ( cover & 0x01 ) { @@ -89,12 +89,12 @@ namespace Coverage { aCoverageMap->setWasExecuted( a + 2 ); aCoverageMap->setWasExecuted( a + 3 ); if ( cover & 0x08 ) { - aCoverageMap->setWasTaken( a ); - BranchInfoAvailable = true; + aCoverageMap->setWasTaken( a ); + BranchInfoAvailable = true; } if ( cover & 0x10 ) { - aCoverageMap->setWasNotTaken( a ); - BranchInfoAvailable = true; + aCoverageMap->setWasNotTaken( a ); + BranchInfoAvailable = true; } } } diff --git a/tester/covoar/CoverageWriterTSIM.cc b/tester/covoar/CoverageWriterTSIM.cc index a4731a9..62a1f7d 100644 --- a/tester/covoar/CoverageWriterTSIM.cc +++ b/tester/covoar/CoverageWriterTSIM.cc @@ -57,7 +57,7 @@ namespace Coverage { for ( i = 0; i < 0x80; i += 4 ) { cover = ((coverage->wasExecuted( a + i )) ? 1 : 0); status = ::fprintf( coverageFile, "%d ", cover ); - if ( status == EOF || status == 0 ) { + if ( status == EOF || status == 0 ) { ::fclose( coverageFile ); std::ostringstream what; what << "write to " << file @@ -67,7 +67,7 @@ namespace Coverage { << std::setfill(' ') << std::dec << "failed"; throw rld::error( what, "CoverageWriterTSIM::writeFile" ); - } + } } ::fprintf( coverageFile, "\n" ); } diff --git a/tester/covoar/GcovData.cc b/tester/covoar/GcovData.cc index 2c033e5..5175fb3 100644 --- a/tester/covoar/GcovData.cc +++ b/tester/covoar/GcovData.cc @@ -27,7 +27,7 @@ namespace Gcov { GcovData::GcovData() { - numberOfFunctions = 0; + numberOfFunctions = 0; } GcovData::~GcovData() @@ -36,11 +36,11 @@ namespace Gcov { bool GcovData::readGcnoFile( const char* const fileName ) { - int status; - FILE* gcovFile; - char* tempString; - char* tempString2; - char* tempString3; + int status; + FILE* gcovFile; + char* tempString; + char* tempString2; + char* tempString3; if ( strlen(fileName) >= FILE_NAME_LENGTH ){ fprintf( @@ -63,9 +63,9 @@ namespace Gcov { } else { - strcpy( tempString, ".gcda"); // construct gcda file name - strcpy( tempString2, ".txt"); // construct report file name - strcpy( tempString3, ".c"); // construct source file name + strcpy( tempString, ".gcda"); // construct gcda file name + strcpy( tempString2, ".txt"); // construct report file name + strcpy( tempString3, ".c"); // construct source file name } // Debug message @@ -74,16 +74,16 @@ namespace Gcov { // Open the notes file. gcovFile = fopen( gcnoFileName, "r" ); if ( !gcovFile ) { - fprintf( stderr, "Unable to open %s\n", gcnoFileName ); - return false; + fprintf( stderr, "Unable to open %s\n", gcnoFileName ); + return false; } // Read and validate the gcnoPreamble (magic, version, timestamp) from the file status = readFilePreamble( &gcnoPreamble, gcovFile, GCNO_MAGIC ); if ( status <= 0 ){ - fprintf( stderr, "Unable to read %s\n", gcnoFileName ); - fclose( gcovFile ); - return false; + fprintf( stderr, "Unable to read %s\n", gcnoFileName ); + fclose( gcovFile ); + return false; } //Read all remaining frames from file @@ -96,383 +96,383 @@ namespace Gcov { bool GcovData::writeGcdaFile () { - gcov_preamble preamble; - gcov_frame_header header; - FILE* gcdaFile; - functions_iterator_t currentFunction; - arcs_iterator_t currentArc; - uint32_t buffer; - uint32_t countersFound; - uint32_t countersFoundSum; - uint64_t countersSum; - uint64_t countersMax; - uint64_t llBuffer[4096]; // TODO: Use common buffer - gcov_statistics objectStats; - gcov_statistics programStats; - size_t status; - - // Debug message - // fprintf( stderr, "Writing file: %s\n", gcdaFileName); - - // Lets clear counters sumators - countersSum = 0; - countersMax = 0; - countersFoundSum = 0; - - // Open the data file. - gcdaFile = fopen( gcdaFileName, "w" ); - if ( !gcdaFile ) { - fprintf( stderr, "Unable to create %s\n", gcdaFileName ); - return false; - } - - //Form preamble - preamble.magic = GCDA_MAGIC; - preamble.version = gcnoPreamble.version; - preamble.timestamp = gcnoPreamble.timestamp; - - //Write preamble - status = fwrite (&preamble , sizeof( preamble ), 1 , gcdaFile ); - if ( status != 1 ) - fprintf( stderr, "Error while writing gcda preamble to a file %s\n", gcdaFileName ); - - //Write function info and counter counts - for ( - currentFunction = functions.begin(); - currentFunction != functions.end(); - currentFunction++ - ) - { - //Write function announcement frame header (length always equals 2) - header.tag = GCOV_TAG_FUNCTION; - header.length = 2; - status = fwrite (&header, sizeof(header), 1, gcdaFile ); - if ( status != 1 ) - fprintf( stderr, "Error while writing function announcement to a file %s\n", gcdaFileName ); - - //Write function id - buffer = (*currentFunction)->getId(); - status = fwrite (&buffer, sizeof( buffer ), 1, gcdaFile ); - if ( status != 1 ) - fprintf( stderr, "Error while writing function id to a file %s\n", gcdaFileName ); - - //Write function checksum - buffer = (*currentFunction)->getChecksum(); - status = fwrite (&buffer, sizeof( buffer ), 1, gcdaFile ); - if ( status != 1 ) - fprintf( stderr, "Error while writing function checksum to a file %s\n", gcdaFileName ); - - // Determine how many counters there are - // and store their counts in buffer - countersFound = 0; - (*currentFunction)->getCounters( llBuffer, countersFound, countersSum, countersMax ); - countersFoundSum += countersFound; - - //Write info about counters - header.tag = GCOV_TAG_COUNTER; - header.length = countersFound * 2; - status = fwrite (&header, sizeof( header ), 1, gcdaFile ); - if ( status != 1 ) - fprintf( stderr, "Error while writing counter header to a file %s\n", gcdaFileName ); - - status = fwrite (llBuffer, sizeof( uint64_t ), countersFound , gcdaFile ); - if ( status != countersFound ) - fprintf( stderr, "Error while writing counter data to a file %s\n", gcdaFileName ); - } - - // Prepare frame with object file statistics - header.tag = GCOV_TAG_OBJECT_SUMMARY; - header.length = 9; - objectStats.checksum = 0; // TODO: have no idea hov to calculates it :) - objectStats.counters = countersFoundSum; - objectStats.runs = 1; // We are lying for now, we have no means of figuring this out - objectStats.sum = countersSum; // Sum of all counters - objectStats.max = countersMax; // max value for counter on last run, we have no clue - objectStats.sumMax = countersMax; // we have no clue - - // Write data - status = fwrite (&header, sizeof( header ), 1, gcdaFile ); - if ( status != 1 ) - fprintf( stderr, "Error while writing stats header to a file %s\n", gcdaFileName ); - status = fwrite (&objectStats, sizeof( objectStats ), 1, gcdaFile ); - if ( status != 1 ) - fprintf( stderr, "Error while writing object stats to a file %s\n", gcdaFileName ); - - - // Prepare frame with program statistics - header.tag = GCOV_TAG_PROGRAM_SUMMARY; - header.length = 9; - programStats.checksum = 0; // TODO: have no idea hov to calculate it :) - programStats.counters = countersFoundSum; - programStats.runs = 1; // We are lying for now, we have no clue - programStats.sum = countersSum; // Sum of all counters - programStats.max = countersMax; // max value for counter on last run, we have no clue - programStats.sumMax = countersMax; // we have no clue - - // Write data - status = fwrite (&header, sizeof( header ), 1, gcdaFile ); - if ( status != 1 ) - fprintf( stderr, "Error while writing stats header to a file %s\n", gcdaFileName ); - status = fwrite (&programStats, sizeof( programStats ), 1, gcdaFile ); - if ( status != 1 ) - fprintf( stderr, "Error while writing program stats to a file %s\n", gcdaFileName ); - - fclose( gcdaFile ); - - return true; + gcov_preamble preamble; + gcov_frame_header header; + FILE* gcdaFile; + functions_iterator_t currentFunction; + arcs_iterator_t currentArc; + uint32_t buffer; + uint32_t countersFound; + uint32_t countersFoundSum; + uint64_t countersSum; + uint64_t countersMax; + uint64_t llBuffer[4096]; // TODO: Use common buffer + gcov_statistics objectStats; + gcov_statistics programStats; + size_t status; + + // Debug message + // fprintf( stderr, "Writing file: %s\n", gcdaFileName); + + // Lets clear counters sumators + countersSum = 0; + countersMax = 0; + countersFoundSum = 0; + + // Open the data file. + gcdaFile = fopen( gcdaFileName, "w" ); + if ( !gcdaFile ) { + fprintf( stderr, "Unable to create %s\n", gcdaFileName ); + return false; + } + + //Form preamble + preamble.magic = GCDA_MAGIC; + preamble.version = gcnoPreamble.version; + preamble.timestamp = gcnoPreamble.timestamp; + + //Write preamble + status = fwrite (&preamble , sizeof( preamble ), 1 , gcdaFile ); + if ( status != 1 ) + fprintf( stderr, "Error while writing gcda preamble to a file %s\n", gcdaFileName ); + + //Write function info and counter counts + for ( + currentFunction = functions.begin(); + currentFunction != functions.end(); + currentFunction++ + ) + { + //Write function announcement frame header (length always equals 2) + header.tag = GCOV_TAG_FUNCTION; + header.length = 2; + status = fwrite (&header, sizeof(header), 1, gcdaFile ); + if ( status != 1 ) + fprintf( stderr, "Error while writing function announcement to a file %s\n", gcdaFileName ); + + //Write function id + buffer = (*currentFunction)->getId(); + status = fwrite (&buffer, sizeof( buffer ), 1, gcdaFile ); + if ( status != 1 ) + fprintf( stderr, "Error while writing function id to a file %s\n", gcdaFileName ); + + //Write function checksum + buffer = (*currentFunction)->getChecksum(); + status = fwrite (&buffer, sizeof( buffer ), 1, gcdaFile ); + if ( status != 1 ) + fprintf( stderr, "Error while writing function checksum to a file %s\n", gcdaFileName ); + + // Determine how many counters there are + // and store their counts in buffer + countersFound = 0; + (*currentFunction)->getCounters( llBuffer, countersFound, countersSum, countersMax ); + countersFoundSum += countersFound; + + //Write info about counters + header.tag = GCOV_TAG_COUNTER; + header.length = countersFound * 2; + status = fwrite (&header, sizeof( header ), 1, gcdaFile ); + if ( status != 1 ) + fprintf( stderr, "Error while writing counter header to a file %s\n", gcdaFileName ); + + status = fwrite (llBuffer, sizeof( uint64_t ), countersFound , gcdaFile ); + if ( status != countersFound ) + fprintf( stderr, "Error while writing counter data to a file %s\n", gcdaFileName ); + } + + // Prepare frame with object file statistics + header.tag = GCOV_TAG_OBJECT_SUMMARY; + header.length = 9; + objectStats.checksum = 0; // TODO: have no idea hov to calculates it :) + objectStats.counters = countersFoundSum; + objectStats.runs = 1; // We are lying for now, we have no means of figuring this out + objectStats.sum = countersSum; // Sum of all counters + objectStats.max = countersMax; // max value for counter on last run, we have no clue + objectStats.sumMax = countersMax; // we have no clue + + // Write data + status = fwrite (&header, sizeof( header ), 1, gcdaFile ); + if ( status != 1 ) + fprintf( stderr, "Error while writing stats header to a file %s\n", gcdaFileName ); + status = fwrite (&objectStats, sizeof( objectStats ), 1, gcdaFile ); + if ( status != 1 ) + fprintf( stderr, "Error while writing object stats to a file %s\n", gcdaFileName ); + + + // Prepare frame with program statistics + header.tag = GCOV_TAG_PROGRAM_SUMMARY; + header.length = 9; + programStats.checksum = 0; // TODO: have no idea hov to calculate it :) + programStats.counters = countersFoundSum; + programStats.runs = 1; // We are lying for now, we have no clue + programStats.sum = countersSum; // Sum of all counters + programStats.max = countersMax; // max value for counter on last run, we have no clue + programStats.sumMax = countersMax; // we have no clue + + // Write data + status = fwrite (&header, sizeof( header ), 1, gcdaFile ); + if ( status != 1 ) + fprintf( stderr, "Error while writing stats header to a file %s\n", gcdaFileName ); + status = fwrite (&programStats, sizeof( programStats ), 1, gcdaFile ); + if ( status != 1 ) + fprintf( stderr, "Error while writing program stats to a file %s\n", gcdaFileName ); + + fclose( gcdaFile ); + + return true; } bool GcovData::readFrame( - FILE* gcovFile - ) + FILE* gcovFile + ) { - gcov_frame_header header; - char buffer[512]; - uint32_t intBuffer[4096]; - uint32_t tempBlockId; - blocks_iterator_t tempBlockIterator; - int status; - GcovFunctionData* newFunction; - - status = readFrameHeader( &header, gcovFile); - - if ( status <= 0 ){ - // Not printing error message because this - // happenns at the end of each file - return false; - } - - switch (header.tag){ - - case GCOV_TAG_FUNCTION: - - numberOfFunctions++; - newFunction = new GcovFunctionData; - if ( !readFunctionFrame(header, gcovFile, newFunction) ){ - fprintf( stderr, "Error while reading FUNCTION from gcov file...\n" ); - return false; - } - functions.push_back(newFunction); - break; - - case GCOV_TAG_BLOCKS: - - status = fread( &intBuffer, 4, header.length, gcovFile ); - if ( status != (int) header.length){ - fprintf( - stderr, "Error while reading BLOCKS from gcov file...\n" - "Header lenght is %u instead of %u\n", - header.length, - status - ); - return false; - } - - for( uint32_t i = 0; i < header.length; i++ ) - functions.back()->addBlock(i, intBuffer[i], ""); - - break; - - case GCOV_TAG_ARCS: - - status = fread( &intBuffer, 4, header.length, gcovFile ); - if (status != (int) header.length){ - return false; - } - - for ( int i = 1; i < (int) header.length; i += 2 ) - functions.back()->addArc(intBuffer[0], intBuffer[i], intBuffer[i+1]); - - break; - - case GCOV_TAG_LINES: - - status = fread( &intBuffer, 4, 2, gcovFile ); - if (status != 2 || intBuffer[1] != 0){ - fprintf( - stderr, - "Error while reading block id for LINES from gcov file..." - ); - return false; - } - tempBlockId = intBuffer[0]; - header.length -= 2; - - // Find the right block - tempBlockIterator =functions.back()->findBlockById(tempBlockId); - - header.length -= readString(buffer, gcovFile); - functions.back()->setBlockFileName( tempBlockIterator, buffer ); - - status = fread( &intBuffer, 4, header.length, gcovFile ); - if (status != (int) header.length){ - fprintf( stderr, "Error while reading LINES from gcov file..." ); - return false; - } - - else - for (int i = 0; i < (int) (header.length - 2); i++) - functions.back()->addBlockLine( tempBlockIterator, intBuffer[i] ); - - break; - - default: - - fprintf( stderr, "\n\nERROR - encountered unknown *.gcno tag : 0x%x\n", header.tag ); - break; - } - - return true; + gcov_frame_header header; + char buffer[512]; + uint32_t intBuffer[4096]; + uint32_t tempBlockId; + blocks_iterator_t tempBlockIterator; + int status; + GcovFunctionData* newFunction; + + status = readFrameHeader( &header, gcovFile); + + if ( status <= 0 ) { + // Not printing error message because this + // happenns at the end of each file + return false; + } + + switch (header.tag){ + + case GCOV_TAG_FUNCTION: + + numberOfFunctions++; + newFunction = new GcovFunctionData; + if ( !readFunctionFrame(header, gcovFile, newFunction) ){ + fprintf( stderr, "Error while reading FUNCTION from gcov file...\n" ); + return false; + } + functions.push_back(newFunction); + break; + + case GCOV_TAG_BLOCKS: + + status = fread( &intBuffer, 4, header.length, gcovFile ); + if ( status != (int) header.length){ + fprintf( + stderr, "Error while reading BLOCKS from gcov file...\n" + "Header lenght is %u instead of %u\n", + header.length, + status + ); + return false; + } + + for( uint32_t i = 0; i < header.length; i++ ) + functions.back()->addBlock(i, intBuffer[i], ""); + + break; + + case GCOV_TAG_ARCS: + + status = fread( &intBuffer, 4, header.length, gcovFile ); + if (status != (int) header.length){ + return false; + } + + for ( int i = 1; i < (int) header.length; i += 2 ) + functions.back()->addArc(intBuffer[0], intBuffer[i], intBuffer[i+1]); + + break; + + case GCOV_TAG_LINES: + + status = fread( &intBuffer, 4, 2, gcovFile ); + if (status != 2 || intBuffer[1] != 0){ + fprintf( + stderr, + "Error while reading block id for LINES from gcov file..." + ); + return false; + } + tempBlockId = intBuffer[0]; + header.length -= 2; + + // Find the right block + tempBlockIterator =functions.back()->findBlockById(tempBlockId); + + header.length -= readString(buffer, gcovFile); + functions.back()->setBlockFileName( tempBlockIterator, buffer ); + + status = fread( &intBuffer, 4, header.length, gcovFile ); + if (status != (int) header.length){ + fprintf( stderr, "Error while reading LINES from gcov file..." ); + return false; + } + + else + for (int i = 0; i < (int) (header.length - 2); i++) + functions.back()->addBlockLine( tempBlockIterator, intBuffer[i] ); + + break; + + default: + + fprintf( stderr, "\n\nERROR - encountered unknown *.gcno tag : 0x%x\n", header.tag ); + break; + } + + return true; } int GcovData::readString( - char* buffer, //TODO: use global buffer here - FILE* gcovFile + char* buffer, //TODO: use global buffer here + FILE* gcovFile ) { - int status; - int length; + int status; + int length; - status = fread( &length, sizeof(int), 1, gcovFile ); - if (status != 1){ - fprintf( stderr, "ERROR: Unable to read string length from gcov file\n" ); - return -1; - } + status = fread( &length, sizeof(int), 1, gcovFile ); + if (status != 1){ + fprintf( stderr, "ERROR: Unable to read string length from gcov file\n" ); + return -1; + } - status = fread( buffer, length * 4 , 1, gcovFile ); - if (status != 1){ - fprintf( stderr, "ERROR: Unable to read string from gcov file\n" ); - return -1; - } + status = fread( buffer, length * 4 , 1, gcovFile ); + if (status != 1){ + fprintf( stderr, "ERROR: Unable to read string from gcov file\n" ); + return -1; + } - buffer[length * 4] = '\0'; + buffer[length * 4] = '\0'; - return length +1; + return length +1; } int GcovData::readFrameHeader( - gcov_frame_header* header, - FILE* gcovFile - ) + gcov_frame_header* header, + FILE* gcovFile + ) { - int status; - int length; - - length = sizeof(gcov_frame_header); - status = fread( header, length, 1, gcovFile ); - if (status != 1){ - //fprintf( stderr, "ERROR: Unable to read frame header from gcov file\n" ); - return -1; - } + int status; + int length; + + length = sizeof(gcov_frame_header); + status = fread( header, length, 1, gcovFile ); + if (status != 1){ + //fprintf( stderr, "ERROR: Unable to read frame header from gcov file\n" ); + return -1; + } - return length / 4; + return length / 4; } int GcovData::readFilePreamble( - gcov_preamble* preamble, - FILE* gcovFile, - uint32_t desiredMagic + gcov_preamble* preamble, + FILE* gcovFile, + uint32_t desiredMagic ) { - int status; - int length; - - length = sizeof( gcov_preamble ); - status = fread( preamble, sizeof( gcov_preamble), 1, gcovFile ); - if (status <= 0) { - fprintf( stderr, "Error while reading file preamble\n" ); - return -1; - } - - if ( preamble->magic != GCNO_MAGIC ) { - fprintf( stderr, "File is not a valid *.gcno output (magic: 0x%4x)\n", preamble->magic ); - return -1; - } - - return length / 4; + int status; + int length; + + length = sizeof( gcov_preamble ); + status = fread( preamble, sizeof( gcov_preamble), 1, gcovFile ); + if (status <= 0) { + fprintf( stderr, "Error while reading file preamble\n" ); + return -1; + } + + if ( preamble->magic != GCNO_MAGIC ) { + fprintf( stderr, "File is not a valid *.gcno output (magic: 0x%4x)\n", preamble->magic ); + return -1; + } + + return length / 4; } bool GcovData::readFunctionFrame( - gcov_frame_header header, - FILE* gcovFile, - GcovFunctionData* function + gcov_frame_header header, + FILE* gcovFile, + GcovFunctionData* function ) { - char buffer[512]; //TODO: use common buffers - uint32_t intBuffer[4096]; - int status; - - status = fread( &intBuffer, 8, 1, gcovFile ); - if (status != 1){ - fprintf( stderr, "ERROR: Unable to read Function ID & checksum\n" ); - return false; - } - header.length -= 2; - function->setId( intBuffer[0] ); - function->setChecksum( intBuffer[1] ); - - header.length -= readString( buffer, gcovFile ); - function->setFunctionName( buffer ); - header.length -= readString( buffer, gcovFile ); - function->setFileName( buffer ); - status = fread( &intBuffer, 4, header.length, gcovFile ); - if (status <= 0){ - fprintf( stderr, "ERROR: Unable to read Function starting line number\n" ); - return false; - } - function->setFirstLineNumber( intBuffer[0] ); - - return true; + char buffer[512]; //TODO: use common buffers + uint32_t intBuffer[4096]; + int status; + + status = fread( &intBuffer, 8, 1, gcovFile ); + if (status != 1){ + fprintf( stderr, "ERROR: Unable to read Function ID & checksum\n" ); + return false; + } + header.length -= 2; + function->setId( intBuffer[0] ); + function->setChecksum( intBuffer[1] ); + + header.length -= readString( buffer, gcovFile ); + function->setFunctionName( buffer ); + header.length -= readString( buffer, gcovFile ); + function->setFileName( buffer ); + status = fread( &intBuffer, 4, header.length, gcovFile ); + if (status <= 0){ + fprintf( stderr, "ERROR: Unable to read Function starting line number\n" ); + return false; + } + function->setFirstLineNumber( intBuffer[0] ); + + return true; } bool GcovData::writeReportFile() { - functions_iterator_t currentFunction; - uint32_t i = 1; //iterator - FILE* textFile; - - // Debug message - // fprintf( stderr, "Writing file: %s\n", textFileName); - - // Open the data file. - textFile = fopen( textFileName, "w" ); - if ( !textFile ) { - fprintf( stderr, "Unable to create %s\n", textFileName ); - return false; - } - - printGcnoFileInfo( textFile ); - - for ( - currentFunction = functions.begin(); - currentFunction != functions.end(); - currentFunction++ - ) - { - (*currentFunction)->printFunctionInfo( textFile, i ); - (*currentFunction)->printCoverageInfo( textFile, i ); - i++; - } - - fclose ( textFile ); - return true; + functions_iterator_t currentFunction; + uint32_t i = 1; //iterator + FILE* textFile; + + // Debug message + // fprintf( stderr, "Writing file: %s\n", textFileName); + + // Open the data file. + textFile = fopen( textFileName, "w" ); + if ( !textFile ) { + fprintf( stderr, "Unable to create %s\n", textFileName ); + return false; + } + + printGcnoFileInfo( textFile ); + + for ( + currentFunction = functions.begin(); + currentFunction != functions.end(); + currentFunction++ + ) + { + (*currentFunction)->printFunctionInfo( textFile, i ); + (*currentFunction)->printCoverageInfo( textFile, i ); + i++; + } + + fclose ( textFile ); + return true; } void GcovData::printGcnoFileInfo( FILE * textFile ) { - fprintf( - textFile, - "\nFILE:\t\t\t%s\n" - "magic:\t\t\t%x\n" - "version:\t\t%x\n" - "timestamp:\t\t%x\n" - "functions found: \t%u\n\n", - gcnoFileName, - gcnoPreamble.magic, - gcnoPreamble.version, - gcnoPreamble.timestamp, - numberOfFunctions - ); + fprintf( + textFile, + "\nFILE:\t\t\t%s\n" + "magic:\t\t\t%x\n" + "version:\t\t%x\n" + "timestamp:\t\t%x\n" + "functions found: \t%u\n\n", + gcnoFileName, + gcnoPreamble.magic, + gcnoPreamble.version, + gcnoPreamble.timestamp, + numberOfFunctions + ); } void GcovData::writeGcovFile( ) @@ -480,16 +480,17 @@ namespace Gcov { //std::cerr << "Attempting to run gcov for: " << cFileName << std::endl; std::ostringstream command; command << "( cd " << rld::path::dirname (cFileName) - << " && gcov " << rld::path::basename (cFileName) - << " &>> gcov.log)"; + << " && gcov " << rld::path::basename (cFileName) + << " &>> gcov.log)"; //std::cerr << "> " << command << std::endl; system( command.str ().c_str () ); } bool GcovData::processCounters( ) { - functions_iterator_t currentFunction; - bool status = true; + functions_iterator_t currentFunction; + bool status = true; + for ( currentFunction = functions.begin(); currentFunction != functions.end(); diff --git a/tester/covoar/GcovData.h b/tester/covoar/GcovData.h index 3191a45..94f5331 100644 --- a/tester/covoar/GcovData.h +++ b/tester/covoar/GcovData.h @@ -14,46 +14,46 @@ namespace Gcov { -#define GCDA_MAGIC ((uint32_t) 0x67636461 ) /* "gcda" */ -#define GCNO_MAGIC ((uint32_t) 0x67636e6f ) /* "gcno" */ +#define GCDA_MAGIC ((uint32_t) 0x67636461 ) /* "gcda" */ +#define GCNO_MAGIC ((uint32_t) 0x67636e6f ) /* "gcno" */ /* we are using gcc 4.6 release format, coded as "406R" */ #define GCNO_VERSION ((uint32_t) 0x34303652 ) /* GCOV tags */ -#define GCOV_TAG_FUNCTION ((uint32_t)0x01000000) -#define GCOV_TAG_BLOCKS ((uint32_t)0x01410000) -#define GCOV_TAG_ARCS ((uint32_t)0x01430000) -#define GCOV_TAG_LINES ((uint32_t)0x01450000) -#define GCOV_TAG_COUNTER ((uint32_t)0x01a10000) -#define GCOV_TAG_OBJECT_SUMMARY ((uint32_t)0xa1000000) -#define GCOV_TAG_PROGRAM_SUMMARY ((uint32_t)0xa3000000) +#define GCOV_TAG_FUNCTION ((uint32_t)0x01000000) +#define GCOV_TAG_BLOCKS ((uint32_t)0x01410000) +#define GCOV_TAG_ARCS ((uint32_t)0x01430000) +#define GCOV_TAG_LINES ((uint32_t)0x01450000) +#define GCOV_TAG_COUNTER ((uint32_t)0x01a10000) +#define GCOV_TAG_OBJECT_SUMMARY ((uint32_t)0xa1000000) +#define GCOV_TAG_PROGRAM_SUMMARY ((uint32_t)0xa3000000) -typedef std::list functions_t; -typedef std::list::iterator functions_iterator_t; +typedef std::list functions_t; +typedef std::list::iterator functions_iterator_t; struct gcov_preamble { - uint32_t magic; - uint32_t version; - uint32_t timestamp; + uint32_t magic; + uint32_t version; + uint32_t timestamp; }; struct gcov_frame_header { - uint32_t tag; - uint32_t length; + uint32_t tag; + uint32_t length; }; struct gcov_statistics { - uint32_t checksum; // checksum - uint32_t counters; // number of counters - uint32_t runs; // number of runs - uint64_t sum; // sum of all couter values - uint64_t max; // max value on a single run - uint64_t sumMax; // sum of individual runs max values + uint32_t checksum; // checksum + uint32_t counters; // number of counters + uint32_t runs; // number of runs + uint64_t sum; // sum of all couter values + uint64_t max; // max value on a single run + uint64_t sumMax; // sum of individual runs max values }; /*! @class GcovData @@ -111,13 +111,13 @@ struct gcov_statistics private: - uint32_t numberOfFunctions; - gcov_preamble gcnoPreamble; - char gcnoFileName[FILE_NAME_LENGTH]; - char gcdaFileName[FILE_NAME_LENGTH]; - char textFileName[FILE_NAME_LENGTH]; - char cFileName[FILE_NAME_LENGTH]; - functions_t functions; + uint32_t numberOfFunctions; + gcov_preamble gcnoPreamble; + char gcnoFileName[FILE_NAME_LENGTH]; + char gcdaFileName[FILE_NAME_LENGTH]; + char textFileName[FILE_NAME_LENGTH]; + char cFileName[FILE_NAME_LENGTH]; + functions_t functions; /*! @@ -128,7 +128,7 @@ struct gcov_statistics * @return true if read was succesfull, false otherwise */ bool readFrame( - FILE* gcovFile + FILE* gcovFile ); /*! @@ -140,8 +140,8 @@ struct gcov_statistics * @return Returns length of words read (word = 32bit) or -1 if error ocurred */ int readString( - char* buffer, - FILE* gcovFile + char* buffer, + FILE* gcovFile ); /*! @@ -154,8 +154,8 @@ struct gcov_statistics * or -1 if error ocurred */ int readFrameHeader( - gcov_frame_header* header, - FILE* gcovFile + gcov_frame_header* header, + FILE* gcovFile ); /*! @@ -169,9 +169,9 @@ struct gcov_statistics * or -1 if error ocurred */ int readFilePreamble( - gcov_preamble* preamble, - FILE* gcovFile, - const uint32_t desiredMagic + gcov_preamble* preamble, + FILE* gcovFile, + const uint32_t desiredMagic ); /*! @@ -184,9 +184,9 @@ struct gcov_statistics * @return Returns true if operation was succesfull */ bool readFunctionFrame( - gcov_frame_header header, - FILE* gcovFile, - GcovFunctionData* function + gcov_frame_header header, + FILE* gcovFile, + GcovFunctionData* function ); /*! diff --git a/tester/covoar/GcovFunctionData.cc b/tester/covoar/GcovFunctionData.cc index 2e61f88..90b1be0 100644 --- a/tester/covoar/GcovFunctionData.cc +++ b/tester/covoar/GcovFunctionData.cc @@ -46,7 +46,7 @@ namespace Gcov { bool GcovFunctionData::setFunctionName( const char* fcnName ) { - std::string symbolName; + std::string symbolName; symbolName = fcnName; @@ -120,12 +120,12 @@ namespace Gcov { uint64_t &countersMax ) { - arcs_iterator_t currentArc; - int i; + arcs_iterator_t currentArc; + int i; - countersFound = 0; - countersSum = 0; - countersMax = 0; + countersFound = 0; + countersSum = 0; + countersMax = 0; // Locate relevant counters and copy their values i = 0; @@ -169,14 +169,15 @@ namespace Gcov { } void GcovFunctionData::addBlock( - const uint32_t id, - const uint32_t flags, - const char * sourceFileName + const uint32_t id, + const uint32_t flags, + const char * sourceFileName ) { gcov_block_info block; + numberOfBlocks++; - block.id = id; + block.id = id; block.flags = flags; block.numberOfLines = 0; block.counter = 0; @@ -233,7 +234,7 @@ namespace Gcov { uint32_t function_number ) { - uint32_t baseAddress = 0; + uint32_t baseAddress = 0; uint32_t baseSize; uint32_t currentAddress; std::list::iterator instruction; @@ -314,7 +315,7 @@ namespace Gcov { if ( !blocks.empty() ) { blockIterator = blocks.begin(); - while ( blockIterator != blocks.end( ) ){ + while ( blockIterator != blocks.end() ){ if ( blockIterator->id == id) break; blockIterator++; @@ -375,7 +376,7 @@ namespace Gcov { blocks_iterator_t block ) { - std::list::iterator line; + std::list::iterator line; fprintf( textFile, @@ -399,10 +400,10 @@ namespace Gcov { uint32_t baseAddress = 0; uint32_t currentAddress = 0; std::list::iterator instruction; - blocks_iterator_t blockIterator; - blocks_iterator_t blockIterator2; - arcs_iterator_t arcIterator; - arcs_iterator_t arcIterator2; + blocks_iterator_t blockIterator; + blocks_iterator_t blockIterator2; + arcs_iterator_t arcIterator; + arcs_iterator_t arcIterator2; std::list taken; // List of taken counts for branches std::list notTaken; // List of not taken counts for branches @@ -525,7 +526,7 @@ namespace Gcov { //); arcIterator->counter = blockIterator->counter; blockIterator2 = blocks.begin(); - while ( arcIterator->destinationBlock != blockIterator2->id) //TODO: ADD FAILSAFE + while ( arcIterator->destinationBlock != blockIterator2->id) //TODO: ADD FAILSAFE blockIterator2++; blockIterator2->counter += arcIterator->counter; return true; @@ -536,7 +537,7 @@ namespace Gcov { //fprintf( stderr, "DEBUG: Found simple arc %3u -> %3u\n", arcIterator->sourceBlock, arcIterator->destinationBlock ); arcIterator->counter = blockIterator->counter; blockIterator2 = blocks.begin();; - while ( arcIterator->destinationBlock != blockIterator2->id) //TODO: ADD FAILSAFE + while ( arcIterator->destinationBlock != blockIterator2->id) //TODO: ADD FAILSAFE blockIterator2++; blockIterator2->counter += arcIterator->counter; } @@ -547,7 +548,7 @@ namespace Gcov { //fprintf( stderr, "DEBUG: Found fake branching arc %3u -> %3u\n", arcIterator->sourceBlock, arcIterator->destinationBlock ); arcIterator->counter = blockIterator->counter; blockIterator2 = blocks.begin(); - while ( arcIterator->destinationBlock != blockIterator2->id) //TODO: ADD FAILSAFE + while ( arcIterator->destinationBlock != blockIterator2->id) //TODO: ADD FAILSAFE blockIterator2++; blockIterator2->counter += arcIterator->counter; } @@ -564,7 +565,7 @@ namespace Gcov { std::list * notTaken ) { - uint32_t baseAddress = 0; + uint32_t baseAddress = 0; uint32_t currentAddress; std::list::iterator instruction; diff --git a/tester/covoar/GcovFunctionData.h b/tester/covoar/GcovFunctionData.h index 959d8ff..812b45c 100644 --- a/tester/covoar/GcovFunctionData.h +++ b/tester/covoar/GcovFunctionData.h @@ -14,35 +14,35 @@ namespace Gcov { -#define FUNCTION_NAME_LENGTH 64 -#define FILE_NAME_LENGTH 256 +#define FUNCTION_NAME_LENGTH 64 +#define FILE_NAME_LENGTH 256 -#define ON_TREE_ARC_FLAG 0x1 -#define FAKE_ARC_FLAG 0x2 -#define FALLTHROUGH_ARC_FLAG 0x4 +#define ON_TREE_ARC_FLAG 0x1 +#define FAKE_ARC_FLAG 0x2 +#define FALLTHROUGH_ARC_FLAG 0x4 struct gcov_arc_info { - uint32_t sourceBlock; - uint32_t destinationBlock; - uint32_t flags; - uint64_t counter; + uint32_t sourceBlock; + uint32_t destinationBlock; + uint32_t flags; + uint64_t counter; }; struct gcov_block_info { - uint32_t id; - uint32_t flags; - uint32_t numberOfLines; - uint64_t counter; - char sourceFileName[FILE_NAME_LENGTH]; - std::list lines; + uint32_t id; + uint32_t flags; + uint32_t numberOfLines; + uint64_t counter; + char sourceFileName[FILE_NAME_LENGTH]; + std::list lines; }; -typedef std::list arcs_t; -typedef std::list::iterator arcs_iterator_t; -typedef std::list blocks_t; -typedef std::list::iterator blocks_iterator_t; +typedef std::list arcs_t; +typedef std::list::iterator arcs_iterator_t; +typedef std::list blocks_t; +typedef std::list::iterator blocks_iterator_t; /*! @class GcovFunctionData * @@ -55,7 +55,7 @@ typedef std::list::iterator blocks_iterator_t; /*! * This method constructs a GcovFunctionData instance. */ - GcovFunctionData(); + GcovFunctionData(); /*! * This method destructs a GcovFunctionData instance. @@ -68,7 +68,7 @@ typedef std::list::iterator blocks_iterator_t; * @param[in] chk stores the checksum value */ void setChecksum( - const uint32_t chk + const uint32_t chk ); /*! @@ -77,7 +77,7 @@ typedef std::list::iterator blocks_iterator_t; * @param[in] idNumber stores the id value */ void setId( - const uint32_t idNumber + const uint32_t idNumber ); /*! @@ -86,7 +86,7 @@ typedef std::list::iterator blocks_iterator_t; * @param[in] lineNo passes number of the line begining the function */ void setFirstLineNumber( - const uint32_t lineNo + const uint32_t lineNo ); /*! @@ -98,7 +98,7 @@ typedef std::list::iterator blocks_iterator_t; * @return Returns TRUE if the method succeeded and FALSE if it failed. */ bool setFunctionName( - const char* fcnName + const char* fcnName ); /*! @@ -109,7 +109,7 @@ typedef std::list::iterator blocks_iterator_t; * @return Returns TRUE if the method succeeded and FALSE if it failed. */ bool setFileName( - const char* fileName + const char* fileName ); /*! @@ -121,8 +121,8 @@ typedef std::list::iterator blocks_iterator_t; * @return Returns TRUE if the method succeeded and FALSE if it failed. */ void setBlockFileName( - const blocks_iterator_t block, - const char* fileName + const blocks_iterator_t block, + const char* fileName ); /*! @@ -153,7 +153,12 @@ typedef std::list::iterator blocks_iterator_t; * @param[out] countersSum used to return sum counters values * @param[out] countersMax used to return max counter value */ - void getCounters( uint64_t* counterValues, uint32_t &countersFound, uint64_t &countersSum, uint64_t &countersMax ); + void getCounters( + uint64_t* counterValues, + uint32_t &countersFound, + uint64_t &countersSum, + uint64_t &countersMax + ); /*! * This method adds new arc to arc list @@ -162,9 +167,9 @@ typedef std::list::iterator blocks_iterator_t; * @param[in] destination passes destination block number */ void addArc( - uint32_t source, - uint32_t destination, - uint32_t flags + uint32_t source, + uint32_t destination, + uint32_t flags ); /*! @@ -174,8 +179,8 @@ typedef std::list::iterator blocks_iterator_t; * @param[in] line passes the line number */ void addBlockLine( - const blocks_iterator_t block, - const uint32_t line + const blocks_iterator_t block, + const uint32_t line ); /*! @@ -186,7 +191,7 @@ typedef std::list::iterator blocks_iterator_t; * @return Returns iterator to a matching block or NULL for error. */ blocks_iterator_t findBlockById( - const uint32_t id + const uint32_t id ); /*! @@ -197,9 +202,9 @@ typedef std::list::iterator blocks_iterator_t; * @param[in] sourceFileName passes containing file name */ void addBlock( - const uint32_t id, - const uint32_t flags, - const char * sourceFileName + const uint32_t id, + const uint32_t flags, + const char * sourceFileName ); /*! @@ -219,8 +224,8 @@ typedef std::list::iterator blocks_iterator_t; * @param[in] arc passes iterator identifying arc */ void printArcInfo( - FILE * textFile, - arcs_iterator_t arc + FILE * textFile, + arcs_iterator_t arc ); /*! @@ -229,8 +234,8 @@ typedef std::list::iterator blocks_iterator_t; * @param[in] block passes iterator identifying block */ void printBlockInfo( - FILE * textFile, - blocks_iterator_t block + FILE * textFile, + blocks_iterator_t block ); /*! @@ -240,22 +245,22 @@ typedef std::list::iterator blocks_iterator_t; private: - uint32_t id; - uint32_t checksum; - uint32_t firstLineNumber; - uint32_t numberOfBlocks; - uint32_t numberOfArcs; - arcs_t arcs; - blocks_t blocks; - char functionName[FUNCTION_NAME_LENGTH]; - char sourceFileName[FILE_NAME_LENGTH]; + uint32_t id; + uint32_t checksum; + uint32_t firstLineNumber; + uint32_t numberOfBlocks; + uint32_t numberOfArcs; + arcs_t arcs; + blocks_t blocks; + char functionName[FUNCTION_NAME_LENGTH]; + char sourceFileName[FILE_NAME_LENGTH]; /*! * This member contains the unified or merged coverage map * and symbol info for the symbol. */ Coverage::CoverageMapBase* coverageMap; - Coverage::SymbolInformation* symbolInfo; + Coverage::SymbolInformation* symbolInfo; /*! * This method creates list of taken/not taken values @@ -265,8 +270,8 @@ typedef std::list::iterator blocks_iterator_t; * @param[in] notTaken used to return not taken counts list */ bool processBranches( - std::list * taken , - std::list * notTaken + std::list * taken, + std::list * notTaken ); }; diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc index 7137016..fa1ebf6 100644 --- a/tester/covoar/ReportsHtml.cc +++ b/tester/covoar/ReportsHtml.cc @@ -617,9 +617,9 @@ namespace Coverage { for ( unsigned int i=0 ; i < explanation->explanation.size(); i++) { fprintf( - report, - "%s\n", - explanation->explanation[i].c_str() + report, + "%s\n", + explanation->explanation[i].c_str() ); } CloseFile( report ); diff --git a/tester/covoar/SymbolTable.cc b/tester/covoar/SymbolTable.cc index 00062cc..b3a5e58 100644 --- a/tester/covoar/SymbolTable.cc +++ b/tester/covoar/SymbolTable.cc @@ -115,9 +115,9 @@ namespace Coverage { void SymbolTable::dumpSymbolTable( void ) { - symbolInfo symbolTable; - symbolInfoIterator_t symbolIterator; - infoIterator_t infoIterator; + symbolInfo symbolTable; + symbolInfoIterator_t symbolIterator; + infoIterator_t infoIterator; for (infoIterator = info.begin() ; infoIterator != info.end(); infoIterator++) { diff --git a/tester/covoar/SymbolTable.h b/tester/covoar/SymbolTable.h index 4149868..f2899d3 100644 --- a/tester/covoar/SymbolTable.h +++ b/tester/covoar/SymbolTable.h @@ -33,9 +33,7 @@ namespace Coverage { } symbolInfo_t; typedef std::list< symbolInfo_t > symbolInfo; - typedef std::list< symbolInfo_t >::iterator symbolInfoIterator_t; - - + typedef std::list< symbolInfo_t >::iterator symbolInfoIterator_t; /*! * This method constructs a SymbolTable instance. diff --git a/tester/covoar/Target_riscv.h b/tester/covoar/Target_riscv.h index c1cf7ab..64a63d4 100644 --- a/tester/covoar/Target_riscv.h +++ b/tester/covoar/Target_riscv.h @@ -68,7 +68,7 @@ namespace Target { */ bool isNopLine( const char* const line, - int& size + int& size ); /*! @@ -81,15 +81,15 @@ namespace Target { bool isBranch( const char* const instruction - ); + ); - private: + private: }; TargetBase *Target_riscv_Constructor( std::string targetName - ); + ); } #endif -- cgit v1.2.3