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;
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)
{
@@ -713,7 +714,7 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
if (pathSplit.size() < 2)
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__);
string fullPath = "";
for (int z = 0; z < pathSplit.size() - 2; ++z)
@@ -745,9 +746,9 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
else
fileNameFixed = (toAdd.substr(0, 2) == "./") ? toAdd.substr(2) : toAdd;
const string optPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".opt";
const string errPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".err";
const string outPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".out";
const string optPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".opt";
const string errPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".err";
const string outPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".out";
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)
fixUseOnlyStmt(file, parallelRegions);
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)
{
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;
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);
}
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)
{
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
SgStatement* mainUnit = findMainUnit(&project, SPF_messages);
@@ -2662,27 +2662,30 @@ int main(int argc, char **argv)
printStackTrace();
printf("exception occurred\n");
json byFileArray = json::array();
for (auto& byFile : SPF_messages)
FILE* outF = fopen((string(VISUALIZER_DATA_PATH) + "error_messages.json").c_str(), "w");
if (outF)
{
json inFile;
inFile["file"] = byFile.first;
json messages = json::array();
for (auto& message : byFile.second)
json byFileArray = json::array();
for (auto& byFile : SPF_messages)
{
message.print(byFile.first);
messages.push_back(message.toJson());
}
inFile["messages"] = messages;
byFileArray.push_back(inFile);
}
json allMessages;
allMessages["allMessages"] = byFileArray;
json inFile;
inFile["file"] = byFile.first;
FILE* outF = fopen("dump_messages.json", "w");
fprintf(outF, "%s", allMessages.dump().c_str());
fclose(outF);
json messages = json::array();
for (auto& message : byFile.second)
{
message.print(byFile.first);
messages.push_back(message.toJson());
}
inFile["messages"] = messages;
byFileArray.push_back(inFile);
}
json allMessages;
allMessages["allMessages"] = byFileArray;
fprintf(outF, "%s", allMessages.dump().c_str());
fclose(outF);
}
}
deleteAllAllocatedData(withDel);

View File

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

View File

@@ -1,3 +1,3 @@
#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<int*> allocatedInt;
extern bool runAsClient;
extern const char* VISUALIZER_DATA_PATH;
bool showDebug = false;
static const string interruptEx = "Interrupted by user";
@@ -298,7 +299,7 @@ static void runPassesForVisualizer(const short *projName, const vector<passes> &
while (passDone == 0)
{
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 (showDebug)