Skip to content

Commit

Permalink
Preparing for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuscede committed Feb 16, 2018
1 parent d63b68b commit 7dd7553
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 9 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion ELF/ElfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <sstream>
#include <map>
#include "ElfReader.h"
#include "../TAFunctions.h"
#include "../Runner/TAFunctions.h"

using namespace std;
using namespace ELFIO;
Expand Down
12 changes: 12 additions & 0 deletions Graph/BFXEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
95 changes: 94 additions & 1 deletion Print/PrintOperation.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// 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 <http://www.gnu.org/licenses/>.
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <ncurses.h>
#include "PrintOperation.h"

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;

Expand All @@ -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;
}
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand All @@ -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;
Expand All @@ -161,6 +240,9 @@ void PrintOperation::printStartProcess(){
}
}

/**
* Prints the end of the process.
*/
void PrintOperation::printEndProcess(){
//If verbose, print a new line.
if (verbose) {
Expand All @@ -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;
Expand Down
22 changes: 21 additions & 1 deletion Print/PrintOperation.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef BFX64_PRINTOPERATION_H
#define BFX64_PRINTOPERATION_H
Expand Down
2 changes: 1 addition & 1 deletion main.cpp → Runner/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <iostream>
#include <boost/program_options.hpp>
#include <vector>
#include "ELF/ElfReader.h"
#include "../ELF/ElfReader.h"

using namespace std;
namespace po = boost::program_options;
Expand Down
13 changes: 13 additions & 0 deletions TAFunctions.cpp → Runner/TAFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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;
Expand All @@ -109,6 +119,9 @@ bool TAFunctions::dumpTAFile(TAGraph* graph){
return graph->removeAllNodes();
}

/**
* Ends the TA file.
*/
void TAFunctions::endTAFile(){
TAFunctions::taDump.close();
}
Expand Down
4 changes: 2 additions & 2 deletions TAFunctions.h → Runner/TAFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#include <sstream>
#include <map>
#include <fstream>
#include "Graph/TAGraph.h"
#include "Print/PrintOperation.h"
#include "../Graph/TAGraph.h"
#include "../Print/PrintOperation.h"

using namespace std;
using namespace boost::filesystem;
Expand Down

0 comments on commit 7dd7553

Please sign in to comment.