added VISUALIZER_DATA_PATH variable

This commit is contained in:
ALEXks
2025-06-04 13:01:50 +03:00
parent db32a3e2b2
commit f53d514a47
5 changed files with 33 additions and 27 deletions

View File

@@ -34,6 +34,7 @@
using namespace std; using namespace std;
extern "C" int parse_file(int argc, char* argv[], char* proj_name); extern "C" int parse_file(int argc, char* argv[], char* proj_name);
extern const char* VISUALIZER_DATA_PATH;
static void findModuleDeclInProject(const string& name, const vector<string>& files, map<string, string>& modDecls) static void findModuleDeclInProject(const string& name, const vector<string>& files, map<string, string>& modDecls)
{ {
@@ -713,7 +714,7 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
if (pathSplit.size() < 2) if (pathSplit.size() < 2)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
if (pathSplit[pathSplit.size() - 2] != "visualiser_data") if (pathSplit[pathSplit.size() - 2] != VISUALIZER_DATA_PATH)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
string fullPath = ""; string fullPath = "";
for (int z = 0; z < pathSplit.size() - 2; ++z) for (int z = 0; z < pathSplit.size() - 2; ++z)
@@ -745,9 +746,9 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
else else
fileNameFixed = (toAdd.substr(0, 2) == "./") ? toAdd.substr(2) : toAdd; fileNameFixed = (toAdd.substr(0, 2) == "./") ? toAdd.substr(2) : toAdd;
const string optPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".opt"; const string optPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".opt";
const string errPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".err"; const string errPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".err";
const string outPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".out"; const string outPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".out";
const string fileText = readFileToStr(toAdd); const string fileText = readFileToStr(toAdd);

View File

@@ -908,7 +908,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
else if (curr_regime == ADD_TEMPL_TO_USE_ONLY) else if (curr_regime == ADD_TEMPL_TO_USE_ONLY)
fixUseOnlyStmt(file, parallelRegions); fixUseOnlyStmt(file, parallelRegions);
else if (curr_regime == GCOV_PARSER) else if (curr_regime == GCOV_PARSER)
parse_gcovfile(file, consoleMode == 1 ? file_name : "./visualiser_data/gcov/" + string(file_name), getObjectForFileFromMap(file_name, gCovInfo), keepFiles); parse_gcovfile(file, consoleMode == 1 ? file_name : string(VISUALIZER_DATA_PATH) + "/gcov/" + file_name, getObjectForFileFromMap(file_name, gCovInfo), keepFiles);
else if(curr_regime == PRIVATE_ARRAYS_EXPANSION) else if(curr_regime == PRIVATE_ARRAYS_EXPANSION)
{ {
auto founded = loopGraph.find(file->filename()); auto founded = loopGraph.find(file->filename());
@@ -960,7 +960,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
vector<string> include_functions; vector<string> include_functions;
createInterTree(file, getObjectForFileFromMap(file_name, intervals), removeNestedIntervals, getObjectForFileFromMap(file_name, SPF_messages)); createInterTree(file, getObjectForFileFromMap(file_name, intervals), removeNestedIntervals, getObjectForFileFromMap(file_name, SPF_messages));
assignCallsToFile(consoleMode == 1 ? file_name : "./visualiser_data/gcov/" + string(file_name), getObjectForFileFromMap(file_name, intervals)); assignCallsToFile(consoleMode == 1 ? file_name : string(VISUALIZER_DATA_PATH) + "/gcov/" + file_name, getObjectForFileFromMap(file_name, intervals));
removeNodes(intervals_threshold, getObjectForFileFromMap(file_name, intervals), include_functions); removeNodes(intervals_threshold, getObjectForFileFromMap(file_name, intervals), include_functions);
} }
else if (curr_regime == INSERT_INTER_TREE) else if (curr_regime == INSERT_INTER_TREE)
@@ -1713,7 +1713,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
} }
else if (curr_regime == GCOV_PARSER) else if (curr_regime == GCOV_PARSER)
{ {
parseTimesDvmStatisticFile((consoleMode == 1) ? string("statistic.txt") : "./visualiser_data/statistic/" + string("statistic.txt"), intervals); parseTimesDvmStatisticFile((consoleMode == 1) ? string("statistic.txt") : string(VISUALIZER_DATA_PATH) + "/statistic/statistic.txt", intervals);
//fixed count, devide by value from PROG_HEDR //fixed count, devide by value from PROG_HEDR
SgStatement* mainUnit = findMainUnit(&project, SPF_messages); SgStatement* mainUnit = findMainUnit(&project, SPF_messages);
@@ -2662,6 +2662,9 @@ int main(int argc, char **argv)
printStackTrace(); printStackTrace();
printf("exception occurred\n"); printf("exception occurred\n");
FILE* outF = fopen((string(VISUALIZER_DATA_PATH) + "error_messages.json").c_str(), "w");
if (outF)
{
json byFileArray = json::array(); json byFileArray = json::array();
for (auto& byFile : SPF_messages) for (auto& byFile : SPF_messages)
{ {
@@ -2680,10 +2683,10 @@ int main(int argc, char **argv)
json allMessages; json allMessages;
allMessages["allMessages"] = byFileArray; allMessages["allMessages"] = byFileArray;
FILE* outF = fopen("dump_messages.json", "w");
fprintf(outF, "%s", allMessages.dump().c_str()); fprintf(outF, "%s", allMessages.dump().c_str());
fclose(outF); fclose(outF);
} }
}
deleteAllAllocatedData(withDel); deleteAllAllocatedData(withDel);

View File

@@ -49,6 +49,7 @@ bool withTemplateInfo = false;
bool inlcudeAllFiles = false; // for pass INSERT_INLCUDES bool inlcudeAllFiles = false; // for pass INSERT_INLCUDES
bool runAsClient = false; // run console project as client for Visualizer bool runAsClient = false; // run console project as client for Visualizer
bool printSymbTable = false; bool printSymbTable = false;
const char* VISUALIZER_DATA_PATH = "visualiser_data";
uint64_t currentAvailMemory = 0; uint64_t currentAvailMemory = 0;
int QUALITY; // quality of conflicts search in graph int QUALITY; // quality of conflicts search in graph

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2422" #define VERSION_SPF "2423"

View File

@@ -67,6 +67,7 @@ using json = nlohmann::json;
extern set<short*> allocated; extern set<short*> allocated;
extern set<int*> allocatedInt; extern set<int*> allocatedInt;
extern bool runAsClient; extern bool runAsClient;
extern const char* VISUALIZER_DATA_PATH;
bool showDebug = false; bool showDebug = false;
static const string interruptEx = "Interrupted by user"; static const string interruptEx = "Interrupted by user";
@@ -298,7 +299,7 @@ static void runPassesForVisualizer(const short *projName, const vector<passes> &
while (passDone == 0) while (passDone == 0)
{ {
FILE* interrupt_old = fopen("INTERRUPT", "r"); FILE* interrupt_old = fopen("INTERRUPT", "r");
FILE* interrupt = fopen("visualiser_data/INTERRUPT", "r"); FILE* interrupt = fopen((string(VISUALIZER_DATA_PATH) + "/INTERRUPT").c_str(), "r");
if (interrupt || interrupt_old) if (interrupt || interrupt_old)
{ {
if (showDebug) if (showDebug)