summaryrefslogtreecommitdiffstats
path: root/covoar
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2010-05-25 19:14:48 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2010-05-25 19:14:48 +0000
commite7bb58acb2bd0be85e7f65fdfc8b9e61134c9212 (patch)
tree9c8040f2d0b21a678317bea78a80ea111005826f /covoar
parent2010-05-25 Jennifer.Averett <Jennifer.Averett@OARcorp.com> (diff)
downloadrtems-testing-e7bb58acb2bd0be85e7f65fdfc8b9e61134c9212.tar.bz2
2010-05-25 Jennifer Averett <Jennifer.Averett@OARcorp.com>
* DesiredSymbols.cc, Explanations.cc, ObjdumpProcessor.cc, TraceReaderLogQEMU.cc, app_common.cc, app_common.h: Added a inputBuffer to app_common and modified all fgets calls to use this buffer. This will allow for a size increase if necessary.
Diffstat (limited to 'covoar')
-rw-r--r--covoar/ChangeLog7
-rw-r--r--covoar/DesiredSymbols.cc30
-rw-r--r--covoar/Explanations.cc32
-rw-r--r--covoar/ObjdumpProcessor.cc147
-rw-r--r--covoar/TraceReaderLogQEMU.cc13
-rw-r--r--covoar/app_common.cc1
-rw-r--r--covoar/app_common.h3
7 files changed, 59 insertions, 174 deletions
diff --git a/covoar/ChangeLog b/covoar/ChangeLog
index 1773440..c3317c2 100644
--- a/covoar/ChangeLog
+++ b/covoar/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-25 Jennifer Averett <Jennifer.Averett@OARcorp.com>
+
+ * DesiredSymbols.cc, Explanations.cc, ObjdumpProcessor.cc,
+ TraceReaderLogQEMU.cc, app_common.cc, app_common.h: Added a
+ inputBuffer to app_common and modified all fgets calls to use this
+ buffer. This will allow for a size increase if necessary.
+
2010-05-25 Jennifer.Averett <Jennifer.Averett@OARcorp.com>
* ObjdumpProcessor.cc, TargetBase.cc, TargetBase.h: Removed nm and
diff --git a/covoar/DesiredSymbols.cc b/covoar/DesiredSymbols.cc
index 7050daa..cff224c 100644
--- a/covoar/DesiredSymbols.cc
+++ b/covoar/DesiredSymbols.cc
@@ -34,8 +34,6 @@ namespace Coverage {
const char* const symbolsFile
)
{
- #define MAX_LINE_LENGTH 512
- char buffer[MAX_LINE_LENGTH];
char* cStatus;
bool done = false;
FILE* sFile;
@@ -70,36 +68,35 @@ namespace Coverage {
// Skip blank lines between symbols
do {
- buffer[0] = '\0';
- cStatus = fgets( buffer, MAX_LINE_LENGTH, sFile );
+ inputBuffer[0] = '\0';
+ cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, sFile );
if ( cStatus == NULL ) {
done = true;
}
else {
- buffer[ strlen(buffer) - 1] = '\0';
+ inputBuffer[ strlen(inputBuffer) - 1] = '\0';
line++;
}
- } while ( !done && (buffer[0] == '\0') );
+ } while ( !done && (inputBuffer[0] == '\0') );
// Have we already seen this one?
if ( !done ) {
- if (set.find( buffer ) != set.end()) {
+ if (set.find( inputBuffer ) != set.end()) {
fprintf(
stderr,
"File: %s, Line %d: Duplicate symbol: %s\n",
symbolsFile,
line,
- buffer
+ inputBuffer
);
}
// Add this to the set of symbols.
else {
- set[ buffer ] = *symInfo;
+ set[ inputBuffer ] = *symInfo;
}
}
}
- #undef MAX_LINE_LENGTH
}
void DesiredSymbols::preprocess( void )
@@ -380,7 +377,6 @@ namespace Coverage {
)
{
char* base;
- char buffer[512];
char* cStatus;
char command[512];
std::string fileName;
@@ -455,7 +451,7 @@ namespace Coverage {
ritr != theRanges->set.end();
ritr++ ) {
- cStatus = fgets( buffer, 512, tmpfile );
+ cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, tmpfile );
if ( cStatus == NULL ) {
fprintf(
stderr,
@@ -464,15 +460,15 @@ namespace Coverage {
);
exit( -1 );
}
- buffer[ strlen(buffer) - 1] = '\0';
+ inputBuffer[ strlen(inputBuffer) - 1] = '\0';
// Use only the base filename without directory path.
- realpath( buffer, rpath );
+ realpath( inputBuffer, rpath );
base = basename( rpath );
ritr->lowSourceLine = std::string( base );
- cStatus = fgets( buffer, 512, tmpfile );
+ cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, tmpfile );
if ( cStatus == NULL ) {
fprintf(
stderr,
@@ -481,10 +477,10 @@ namespace Coverage {
);
exit( -1 );
}
- buffer[ strlen(buffer) - 1] = '\0';
+ inputBuffer[ strlen(inputBuffer) - 1] = '\0';
// Use only the base filename without directory path.
- realpath( buffer, rpath );
+ realpath( inputBuffer, rpath );
base = basename( rpath );
ritr->highSourceLine = std::string( base );
diff --git a/covoar/Explanations.cc b/covoar/Explanations.cc
index 03867c0..49bb5e0 100644
--- a/covoar/Explanations.cc
+++ b/covoar/Explanations.cc
@@ -15,6 +15,7 @@
#include <unistd.h>
#include "Explanations.h"
+#include "app_common.h"
namespace Coverage {
@@ -32,7 +33,6 @@ namespace Coverage {
{
#define MAX_LINE_LENGTH 512
FILE *explain;
- char buffer[MAX_LINE_LENGTH];
char *cStatus;
Explanation *e;
int line = 1;
@@ -55,33 +55,33 @@ namespace Coverage {
// Read the starting line of this explanation and
// skip blank lines between
do {
- buffer[0] = '\0';
- cStatus = fgets( buffer, MAX_LINE_LENGTH, explain );
+ inputBuffer[0] = '\0';
+ cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain );
if (cStatus == NULL) {
goto done;
}
- buffer[ strlen(buffer) - 1] = '\0';
+ inputBuffer[ strlen(inputBuffer) - 1] = '\0';
line++;
- } while ( buffer[0] == '\0' );
+ } while ( inputBuffer[0] == '\0' );
// Have we already seen this one?
- if (set.find( buffer ) != set.end()) {
+ if (set.find( inputBuffer ) != set.end()) {
fprintf(
stderr,
"ERROR: Explanations::load - line %d "
"contains a duplicate explanation (%s)\n",
line,
- buffer
+ inputBuffer
);
exit( -1 );
}
// Add the starting line and file
- e->startingPoint = std::string(buffer);
+ e->startingPoint = std::string(inputBuffer);
e->found = false;
// Get the classification
- cStatus = fgets( buffer, MAX_LINE_LENGTH, explain );
+ cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain );
if (cStatus == NULL) {
fprintf(
stderr,
@@ -91,14 +91,14 @@ namespace Coverage {
);
exit( -1 );
}
- buffer[ strlen(buffer) - 1] = '\0';
- e->classification = buffer;
+ inputBuffer[ strlen(inputBuffer) - 1] = '\0';
+ e->classification = inputBuffer;
line++;
// Get the explanation
while (1) {
- cStatus = fgets( buffer, MAX_LINE_LENGTH, explain );
- // fprintf( stderr, "%d - %s\n", line, buffer );
+ cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain );
+ // fprintf( stderr, "%d - %s\n", line, inputBuffer );
if (cStatus == NULL) {
fprintf(
stderr,
@@ -108,15 +108,15 @@ namespace Coverage {
);
exit( -1 );
}
- buffer[ strlen(buffer) - 1] = '\0';
+ inputBuffer[ strlen(inputBuffer) - 1] = '\0';
line++;
const char delimiter[4] = "+++";
- if (!strncmp( buffer, delimiter, 3 )) {
+ if (!strncmp( inputBuffer, delimiter, 3 )) {
break;
}
// XXX only taking last line. Needs to be a vector
- e->explanation.push_back( buffer );
+ e->explanation.push_back( inputBuffer );
}
// Add this to the set of Explanations
diff --git a/covoar/ObjdumpProcessor.cc b/covoar/ObjdumpProcessor.cc
index 8416fd9..9637f10 100644
--- a/covoar/ObjdumpProcessor.cc
+++ b/covoar/ObjdumpProcessor.cc
@@ -132,7 +132,6 @@ namespace Coverage {
{
#define METHOD "ERROR: ObjdumpProcessor::determineLoadAddress - "
FILE* loadAddressFile = NULL;
- char buffer[ 512 ];
char* cStatus;
uint32_t offset;
@@ -140,124 +139,6 @@ namespace Coverage {
if (!theExecutable->hasDynamicLibrary())
return 0;
-#if 0
- static FILE* gdbCommands = NULL;
- int items;
- uint32_t loadAddress;
- FILE* objdumpFile = NULL;
- int status;
- char terminator;
-
-
- //
- // Invoke gdb to determine the physical load address
- // of the .text section.
- //
-
- // Create a gdb input commands file.
- if (!gdbCommands) {
-
- gdbCommands = fopen( "gdbCommands", "w" );
- if (!gdbCommands) {
- fprintf(
- stderr,
- "ERROR: ObjdumpProcessor::determineLoadAddress - "
- "unable to create gdbCommands\n"
- );
- exit( -1 );
- }
-
- fprintf(
- gdbCommands,
- "set pagination off\n"
- "b main\n"
- "r\n"
- "info sharedlibrary\n"
- "quit\n"
- );
-
- fclose( gdbCommands );
- }
-
- // Invoke gdb.
- sprintf(
- buffer,
- "gdb -x gdbCommands %s | grep %s | cut -d ' ' -f1 > %s",
- (theExecutable->getFileName()).c_str(),
- (theExecutable->getLibraryName()).c_str(),
- "library_addr.tmp"
- );
-
- status = system( buffer );
- if (status) {
- fprintf(
- stderr,
- "ERROR: ObjdumpProcessor::determineLoadAddress - "
- "command (%s) failed with %d\n",
- buffer,
- status
- );
- exit( -1 );
- }
-
- // Read load address.
- loadAddressFile = fopen( "library_addr.tmp", "r" );
- if (!loadAddressFile) {
- fprintf(
- stderr,
- "ERROR: ObjdumpProcessor::determineLoadAddress - "
- "unable to open library_addr.tmp\n"
- );
- exit( -1 );
- }
-
- cStatus = fgets( buffer, 512, loadAddressFile );
- items = sscanf(
- buffer, "%x", &loadAddress
- );
-
- fclose( loadAddressFile );
- unlink( "library_addr.tmp" );
-
- //
- // Partially process an objdump of the library to determine the first
- // symbol's offset from the physical load address of the library.
- //
-
- // Obtain the objdump file.
- objdumpFile = getFile( theExecutable->getLibraryName() );
-
- // Process the objdump file.
- while ( 1 ) {
-
- // Get a line.
- cStatus = fgets( buffer, 512, objdumpFile );
- if (cStatus == NULL) {
- fprintf(
- stderr,
- "ERROR: ObjdumpProcessor::determineLoadAddress - "
- "no symbol found in objdump file\n"
- );
- exit( -1 );
- }
-
- // Look for the start of a symbol's objdump and extract
- // address and symbol (i.e. address <symbolname>:).
- items = sscanf(
- buffer,
- "%x <%*[^>]>%c",
- &offset, &terminator
- );
-
- // If all items found, we have found the first symbol's objdump.
- if ((items == 2) && (terminator == ':')) {
- break;
- }
- }
-
- return (loadAddress - offset);
-# endif
-#if 1
std::string dlinfoName = theExecutable->getFileName();
uint32_t address;
char inLibName[128];
@@ -275,7 +156,7 @@ namespace Coverage {
while ( 1 ) {
// Get a line.
- cStatus = fgets( buffer, 512, loadAddressFile );
+ cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, loadAddressFile );
if (cStatus == NULL) {
fprintf(
stderr,
@@ -286,7 +167,7 @@ namespace Coverage {
fclose( loadAddressFile );
exit( -1 );
}
- sscanf( buffer, "%s %x", inLibName, &offset );
+ sscanf( inputBuffer, "%s %x", inLibName, &offset );
std::string tmp = inLibName;
if ( tmp.find( Library ) != tmp.npos ) {
// fprintf( stderr, "%s - 0x%08x\n", inLibName, offset );
@@ -297,7 +178,7 @@ namespace Coverage {
fclose( loadAddressFile );
return address;
-#endif
+
#undef METHOD
}
@@ -417,7 +298,6 @@ namespace Coverage {
ExecutableInfo* const executableInformation
)
{
- char buffer[ 512 ];
char* cStatus;
int items;
FILE* objdumpFile;
@@ -434,15 +314,15 @@ namespace Coverage {
while ( 1 ) {
// Get the line.
- cStatus = fgets( buffer, 512, objdumpFile );
+ cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, objdumpFile );
if (cStatus == NULL) {
break;
}
- buffer[ strlen(buffer) - 1] = '\0';
+ inputBuffer[ strlen(inputBuffer) - 1] = '\0';
// See if it is the dump of an instruction.
items = sscanf(
- buffer,
+ inputBuffer,
"%x%c",
&offset, &terminator
);
@@ -460,7 +340,6 @@ namespace Coverage {
ExecutableInfo* const executableInformation
)
{
- char buffer[ 512 ];
char* cStatus;
std::string currentSymbol = "";
uint32_t endAddress;
@@ -486,7 +365,7 @@ namespace Coverage {
while ( 1 ) {
// Get the line.
- cStatus = fgets( buffer, 512, objdumpFile );
+ cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, objdumpFile );
if (cStatus == NULL) {
// If we are currently processing a symbol, finalize it.
@@ -511,9 +390,9 @@ namespace Coverage {
break;
}
- buffer[ strlen(buffer) - 1] = '\0';
+ inputBuffer[ strlen(inputBuffer) - 1] = '\0';
- lineInfo.line = buffer;
+ lineInfo.line = inputBuffer;
lineInfo.address = 0xffffffff;
lineInfo.isInstruction = false;
lineInfo.isNop = false;
@@ -523,7 +402,7 @@ namespace Coverage {
// Look for the start of a symbol's objdump and extract
// offset and symbol (i.e. offset <symbolname>:).
items = sscanf(
- buffer,
+ inputBuffer,
"%x <%[^>]>%c",
&offset, symbol, &terminator1
);
@@ -563,7 +442,7 @@ namespace Coverage {
// See if it is the dump of an instruction.
items = sscanf(
- buffer,
+ inputBuffer,
"%x%c\t%*[^\t]%c",
&instructionOffset, &terminator1, &terminator2
);
@@ -575,8 +454,8 @@ namespace Coverage {
lineInfo.address =
executableInformation->getLoadAddress() + instructionOffset;
lineInfo.isInstruction = true;
- lineInfo.isNop = isNop( buffer, lineInfo.nopSize );
- lineInfo.isBranch = isBranchLine( buffer );
+ lineInfo.isNop = isNop( inputBuffer, lineInfo.nopSize );
+ lineInfo.isBranch = isBranchLine( inputBuffer );
}
// Always save the line.
diff --git a/covoar/TraceReaderLogQEMU.cc b/covoar/TraceReaderLogQEMU.cc
index 0864b05..d91c16b 100644
--- a/covoar/TraceReaderLogQEMU.cc
+++ b/covoar/TraceReaderLogQEMU.cc
@@ -59,7 +59,6 @@ namespace Trace {
int status;
FILE* logFile;
int result;
- char buffer[120];
//
// Verify that the log file has a non-zero size.
@@ -105,9 +104,9 @@ namespace Trace {
//
// Read First Start Address
//
- fgets(buffer, 120, logFile );
+ fgets(inputBuffer, MAX_LINE_LENGTH, logFile );
result = sscanf(
- buffer,
+ inputBuffer,
"0x%08lx: %s %s\n",
&first.address,
first.instruction,
@@ -125,9 +124,9 @@ namespace Trace {
// Read until we get to the last instruction in the block.
do {
- fgets(buffer, 120, logFile );
+ fgets(inputBuffer, MAX_LINE_LENGTH, logFile );
result = sscanf(
- buffer,
+ inputBuffer,
"0x%08lx: %s %s\n",
&last.address,
last.instruction,
@@ -141,9 +140,9 @@ namespace Trace {
done = true;
nextExecuted = last;
} else {
- fgets(buffer, 120, logFile );
+ fgets(inputBuffer, MAX_LINE_LENGTH, logFile );
result = sscanf(
- buffer,
+ inputBuffer,
"0x%08lx: %s %s\n",
&nextExecuted.address,
nextExecuted.instruction,
diff --git a/covoar/app_common.cc b/covoar/app_common.cc
index 33dacf8..47b69b0 100644
--- a/covoar/app_common.cc
+++ b/covoar/app_common.cc
@@ -34,6 +34,7 @@ bool BranchInfoAvailable = false;
Target::TargetBase* TargetInfo = NULL;
const char* dynamicLibrary = NULL;
const char* projectName = NULL;
+char inputBuffer[MAX_LINE_LENGTH];
bool FileIsNewer(
diff --git a/covoar/app_common.h b/covoar/app_common.h
index b90ee07..04a5c5b 100644
--- a/covoar/app_common.h
+++ b/covoar/app_common.h
@@ -21,6 +21,9 @@ extern Target::TargetBase* TargetInfo;
extern const char* dynamicLibrary;
extern const char* projectName;
+#define MAX_LINE_LENGTH 512
+extern char inputBuffer[MAX_LINE_LENGTH];
+
bool FileIsNewer( const char *f1, const char *f2 );
bool FileIsReadable( const char *f1 );