[PATCH v1 05/13] Remove dynamicLibrary global variable
Ryan Long
ryan.long at oarcorp.com
Sun Aug 1 23:23:39 UTC 2021
- Replaced dynamicLibrary in app_common with local variables
- Changed data type to string
- Changed conditionals to reflect this
---
tester/covoar/ExecutableInfo.cc | 10 +++++-----
tester/covoar/ExecutableInfo.h | 6 +++---
tester/covoar/TraceConverter.cc | 5 +++--
tester/covoar/app_common.cc | 1 -
tester/covoar/app_common.h | 1 -
tester/covoar/covoar.cc | 9 +++++----
6 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc
index a6184e7..9c3031e 100644
--- a/tester/covoar/ExecutableInfo.cc
+++ b/tester/covoar/ExecutableInfo.cc
@@ -18,18 +18,18 @@
namespace Coverage {
ExecutableInfo::ExecutableInfo(
- const char* const theExecutableName,
- const char* const theLibraryName,
- bool verbose
+ const char* const theExecutableName,
+ const std::string& theLibraryName,
+ bool verbose
) : fileName(theExecutableName),
loadAddress(0)
{
- if (theLibraryName != nullptr)
+ if ( !theLibraryName.empty() )
libraryName = theLibraryName;
if (verbose) {
std::cerr << "Loading executable " << theExecutableName;
- if (theLibraryName != nullptr)
+ if ( !theLibraryName.empty() )
std::cerr << " (" << theLibraryName << ')';
std::cerr << std::endl;
}
diff --git a/tester/covoar/ExecutableInfo.h b/tester/covoar/ExecutableInfo.h
index 1f977a0..851a59d 100644
--- a/tester/covoar/ExecutableInfo.h
+++ b/tester/covoar/ExecutableInfo.h
@@ -43,9 +43,9 @@ namespace Coverage {
* @param[in] verbose specifies whether to be verbose with output
*/
ExecutableInfo(
- const char* const theExecutableName,
- const char* const theLibraryName = NULL,
- bool verbose = false
+ const char* const theExecutableName,
+ const std::string& theLibraryName = "",
+ bool verbose = false
);
/*!
diff --git a/tester/covoar/TraceConverter.cc b/tester/covoar/TraceConverter.cc
index 89e0736..c997702 100644
--- a/tester/covoar/TraceConverter.cc
+++ b/tester/covoar/TraceConverter.cc
@@ -91,6 +91,7 @@ int main(
rld::process::tempfile err( ".err" );
Coverage::ObjdumpProcessor objdumpProcessor;
bool verbose = false;
+ std::string dynamicLibrary;
setup_signals();
@@ -130,13 +131,13 @@ int main(
// Create toolnames.
TargetInfo = Target::TargetFactory( cpuname );
- if (dynamicLibrary)
+ if ( !dynamicLibrary.empty() )
executableInfo = new Coverage::ExecutableInfo( executable, dynamicLibrary );
else
executableInfo = new Coverage::ExecutableInfo( executable );
// If a dynamic library was specified, determine the load address.
- if (dynamicLibrary)
+ if ( !dynamicLibrary.empty() )
executableInfo->setLoadAddress(
objdumpProcessor.determineLoadAddress( executableInfo )
);
diff --git a/tester/covoar/app_common.cc b/tester/covoar/app_common.cc
index 9dfe81e..587af1a 100644
--- a/tester/covoar/app_common.cc
+++ b/tester/covoar/app_common.cc
@@ -60,7 +60,6 @@ Coverage::DesiredSymbols* SymbolsToAnalyze = NULL;
const char* outputDirectory = ".";
bool BranchInfoAvailable = false;
Target::TargetBase* TargetInfo = NULL;
-const char* dynamicLibrary = NULL;
const char* projectName = NULL;
char inputBuffer[MAX_LINE_LENGTH];
char inputBuffer2[MAX_LINE_LENGTH];
diff --git a/tester/covoar/app_common.h b/tester/covoar/app_common.h
index ac66eda..6cb8577 100644
--- a/tester/covoar/app_common.h
+++ b/tester/covoar/app_common.h
@@ -16,7 +16,6 @@ extern Coverage::DesiredSymbols* SymbolsToAnalyze;
extern const char* outputDirectory;
extern bool BranchInfoAvailable;
extern Target::TargetBase* TargetInfo;
-extern const char* dynamicLibrary;
extern const char* projectName;
#define MAX_LINE_LENGTH 512
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index 9c88b00..3894867 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -177,6 +177,7 @@ int covoar(
Coverage::Explanations allExplanations;
Coverage::ObjdumpProcessor objdumpProcessor;
bool verbose = false;
+ std::string dynamicLibrary;
//
// Process command line options.
@@ -303,13 +304,13 @@ int covoar(
// If there was at least one coverage file, create the
// executable information.
if (!coverageFileNames.empty()) {
- if (dynamicLibrary) {
+ if ( !dynamicLibrary.empty() ) {
executableInfo = new Coverage::ExecutableInfo(
singleExecutable, dynamicLibrary, verbose
);
} else {
executableInfo = new Coverage::ExecutableInfo(
- singleExecutable, nullptr, verbose
+ singleExecutable, "", verbose
);
}
@@ -333,7 +334,7 @@ int covoar(
<< std::endl;
} else {
executableInfo = new Coverage::ExecutableInfo(
- argv[i], nullptr, verbose
+ argv[i], "", verbose
);
executablesToAnalyze.push_back( executableInfo );
coverageFileNames.push_back( coverageFileName );
@@ -373,7 +374,7 @@ int covoar(
<< std::endl;
// If a dynamic library was specified, determine the load address.
- if (dynamicLibrary) {
+ if ( !dynamicLibrary.empty() ) {
exe->setLoadAddress( objdumpProcessor.determineLoadAddress( exe ) );
}
--
1.8.3.1
More information about the devel
mailing list