From 7dd75539a08164abd471383e656d6ea83db6f394 Mon Sep 17 00:00:00 2001 From: Bryan Muscedere Date: Thu, 15 Feb 2018 23:56:03 -0500 Subject: [PATCH] Preparing for release. --- CMakeLists.txt | 6 +- ELF/ElfReader.cpp | 2 +- Graph/BFXEdge.cpp | 12 +++ Print/PrintOperation.cpp | 95 ++++++++++++++++++++++- Print/PrintOperation.h | 22 +++++- main.cpp => Runner/Driver.cpp | 2 +- TAFunctions.cpp => Runner/TAFunctions.cpp | 13 ++++ TAFunctions.h => Runner/TAFunctions.h | 4 +- 8 files changed, 147 insertions(+), 9 deletions(-) rename main.cpp => Runner/Driver.cpp (99%) rename TAFunctions.cpp => Runner/TAFunctions.cpp (97%) rename TAFunctions.h => Runner/TAFunctions.h (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6ef9f0..98de154 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ add_definitions( set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(SOURCE_FILES - main.cpp + Runner/Driver.cpp ELF/ElfReader.cpp ELF/ElfReader.h Graph/TAGraph.cpp @@ -26,8 +26,8 @@ set(SOURCE_FILES Graph/BFXNode.h Graph/BFXEdge.cpp Graph/BFXEdge.h - TAFunctions.h - TAFunctions.cpp + Runner/TAFunctions.h + Runner/TAFunctions.cpp Print/PrintOperation.cpp Print/PrintOperation.h Print/ProgressBar.c Print/ProgressBar.h) add_executable(bfx64 ${SOURCE_FILES}) diff --git a/ELF/ElfReader.cpp b/ELF/ElfReader.cpp index a53e7a9..9f965d2 100644 --- a/ELF/ElfReader.cpp +++ b/ELF/ElfReader.cpp @@ -30,7 +30,7 @@ #include #include #include "ElfReader.h" -#include "../TAFunctions.h" +#include "../Runner/TAFunctions.h" using namespace std; using namespace ELFIO; diff --git a/Graph/BFXEdge.cpp b/Graph/BFXEdge.cpp index f5794ae..be0a7ca 100644 --- a/Graph/BFXEdge.cpp +++ b/Graph/BFXEdge.cpp @@ -42,6 +42,12 @@ BFXEdge::BFXEdge(BFXNode* src, BFXNode* dst, EdgeType type){ this->type = type; } +/** + * Creates a new edge for low memory mode. + * @param src The source to add. + * @param dst The destination node. + * @param type The type of edge to add. + */ BFXEdge::BFXEdge(string src, string dst, EdgeType type){ this->lowMem = true; this->sourceID = src; @@ -96,11 +102,17 @@ BFXEdge::EdgeType BFXEdge::getType(){ return type; } +/** + * Gets the source ID. + */ string BFXEdge::getSrcID(){ if (lowMem) return sourceID; return src->getID(); } +/** + * Gets the destination ID. + */ string BFXEdge::getDstID(){ if (lowMem) return destinationID; return dst->getID(); diff --git a/Print/PrintOperation.cpp b/Print/PrintOperation.cpp index 6467b92..b2be3db 100644 --- a/Print/PrintOperation.cpp +++ b/Print/PrintOperation.cpp @@ -1,6 +1,26 @@ +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// PrintOperation.h // -// Created by bmuscede on 12/02/17. +// Created By: Bryan J Muscedere +// Date: 12/02/17 // +// Performs operations for printing. +// +// Copyright (C) 2017, Bryan J. Muscedere +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +///////////////////////////////////////////////////////////////////////////////////////////////////////// #include #include @@ -8,6 +28,11 @@ using namespace std; +/** + * Sets up a printer to print status. + * @param verbose Whether we're in verbose mode. + * @param numFiles The number of files to process. + */ PrintOperation::PrintOperation(bool verbose, int numFiles){ this->verbose = verbose; @@ -18,30 +43,56 @@ PrintOperation::PrintOperation(bool verbose, int numFiles){ bar = nullptr; } +/** + * Destructor + */ PrintOperation::~PrintOperation() { } +/** + * Sets the number of files. + * @param numFiles The number of files to process. + */ void PrintOperation::setNumFiles(int numFiles){ this->numFiles = numFiles; } +/** + * Gets the number of files. + * @return The number of files. + */ int PrintOperation::getNumFiles(){ return numFiles; } +/** + * Gets the current file number. + * @return + */ int PrintOperation::getCurFileNum(){ return curFile; } +/** + * Print that a file was found. + * @param fileName The file that was found. + */ void PrintOperation::printFileFound(string fileName) { if (!verbose) return; cout << "Found: " << fileName << endl; } +/** + * Prints any desired line. + * @param line The line to print. + */ void PrintOperation::printLine(std::string line){ cout << line << endl; } +/** + * Notifies that file search is started. + */ void PrintOperation::printStartFileSearch() { if (!verbose) cout << "Searching for object files..." << flush; } @@ -65,6 +116,11 @@ void PrintOperation::printFileProcess(string fileName) { cout << outputMessage; } +/** + * Prints the current file info. + * @param bitType The bit number. + * @param endianness The endianness. + */ void PrintOperation::printFileProcessSub(PrintOperation::Bit bitType, PrintOperation::Endian endianness) { if (!verbose) { printFileProcessNVerbose(); @@ -95,6 +151,10 @@ void PrintOperation::printFileProcessSub(PrintOperation::Bit bitType, PrintOpera cout << msg << endl; } +/** + * Prints the current progress. + * @param opType The current operation. + */ void PrintOperation::printFileProcessSub(PrintOperation::Operation opType) { if (!verbose && (opType != INVALID || opType != PURGE)) { printFileProcessNVerbose(); @@ -120,24 +180,40 @@ void PrintOperation::printFileProcessSub(PrintOperation::Operation opType) { } } +/** + * Prints that files are being resolved. + */ void PrintOperation::printResolving() { cout << "Resolving all undefined references..."; } +/** + * Prints that files are done being resolved. + */ void PrintOperation::printDoneResolving() { cout << "done!" << endl << endl; } +/** + * Print that file isn't found + * @param fileName The file not found. + */ void PrintOperation::printFileNotFound(string fileName) { cerr << "The file " << fileName << " does not exist!" << endl; cerr << "Please supply a valid file name." << endl; } +/** + * Prints that no files were found. + */ void PrintOperation::printNoFiles() { cerr << "No object files supplied to the program!" << endl << "The program will now exit without performing analysis." << endl; } +/** + * Prints that files are done being searched. + */ void PrintOperation::printDoneFileSearch(){ //Check what we do. if (verbose) { @@ -149,6 +225,9 @@ void PrintOperation::printDoneFileSearch(){ cout << "done!" << endl << endl; } +/** + * Prints that the process is starting. + */ void PrintOperation::printStartProcess(){ //Do nothing for verbose. if (verbose) return; @@ -161,6 +240,9 @@ void PrintOperation::printStartProcess(){ } } +/** + * Prints the end of the process. + */ void PrintOperation::printEndProcess(){ //If verbose, print a new line. if (verbose) { @@ -173,15 +255,26 @@ void PrintOperation::printEndProcess(){ cout << endl; } +/** + * Prints success message. + * @param fileName File being outputted. + */ void PrintOperation::printTASuccess(std::string fileName){ cout << "TA file successfully written to " << fileName << "!" << endl; } +/** + * Prints failure message. + * @param fileName File being outputted. + */ void PrintOperation::printTAFailure(std::string fileName){ cout << "TA file could not be written to " << fileName << "!" << endl; cout << "Check appropriate file permissions." << endl; } +/** + * Prints the current file process. + */ void PrintOperation::printFileProcessNVerbose() { //Check the progress bar. if (bar == nullptr) return; diff --git a/Print/PrintOperation.h b/Print/PrintOperation.h index 25bea73..f438a44 100644 --- a/Print/PrintOperation.h +++ b/Print/PrintOperation.h @@ -1,6 +1,26 @@ +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// PrintOperation.h // -// Created by bmuscede on 12/02/17. +// Created By: Bryan J Muscedere +// Date: 12/02/17 // +// Performs operations for printing. +// +// Copyright (C) 2017, Bryan J. Muscedere +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +///////////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef BFX64_PRINTOPERATION_H #define BFX64_PRINTOPERATION_H diff --git a/main.cpp b/Runner/Driver.cpp similarity index 99% rename from main.cpp rename to Runner/Driver.cpp index ce8f65c..20bb333 100644 --- a/main.cpp +++ b/Runner/Driver.cpp @@ -28,7 +28,7 @@ #include #include #include -#include "ELF/ElfReader.h" +#include "../ELF/ElfReader.h" using namespace std; namespace po = boost::program_options; diff --git a/TAFunctions.cpp b/Runner/TAFunctions.cpp similarity index 97% rename from TAFunctions.cpp rename to Runner/TAFunctions.cpp index fef6837..24870f5 100644 --- a/TAFunctions.cpp +++ b/Runner/TAFunctions.cpp @@ -79,6 +79,11 @@ bool TAFunctions::generateTAFile(string outputPath, TAGraph* graph){ return true; } +/** + * Starts the TA generation. + * @param outputPath The output path to add. + * @return Whether the output was successful. + */ bool TAFunctions::startTAGeneration(string outputPath){ //Create file pointer. TAFunctions::taDump.open (outputPath.c_str()); @@ -93,6 +98,11 @@ bool TAFunctions::startTAGeneration(string outputPath){ return true; } +/** + * Dumps TA file to disk for low memory. + * @param graph The graph to dump. + * @return Whether it was successful. + */ bool TAFunctions::dumpTAFile(TAGraph* graph){ //Processes the schema up to this point. TAFunctions::taDump << "FACT TUPLE :" << endl; @@ -109,6 +119,9 @@ bool TAFunctions::dumpTAFile(TAGraph* graph){ return graph->removeAllNodes(); } +/** + * Ends the TA file. + */ void TAFunctions::endTAFile(){ TAFunctions::taDump.close(); } diff --git a/TAFunctions.h b/Runner/TAFunctions.h similarity index 97% rename from TAFunctions.h rename to Runner/TAFunctions.h index 20ec50c..fb255c3 100644 --- a/TAFunctions.h +++ b/Runner/TAFunctions.h @@ -33,8 +33,8 @@ #include #include #include -#include "Graph/TAGraph.h" -#include "Print/PrintOperation.h" +#include "../Graph/TAGraph.h" +#include "../Print/PrintOperation.h" using namespace std; using namespace boost::filesystem;