moved messages to Json, some refactoring
This commit is contained in:
@@ -2046,7 +2046,7 @@ static void findFunctionsToInclude(bool needToAddErrors)
|
|||||||
SPF_messages[byFile.first].push_back(message);
|
SPF_messages[byFile.first].push_back(message);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (message.type != ERROR)
|
if (message.getType() != ERROR)
|
||||||
SPF_messages[byFile.first].push_back(message);
|
SPF_messages[byFile.first].push_back(message);
|
||||||
else
|
else
|
||||||
lastErrors[byFile.first].push_back(message);
|
lastErrors[byFile.first].push_back(message);
|
||||||
@@ -2659,25 +2659,8 @@ int main(int argc, char **argv)
|
|||||||
printStackTrace();
|
printStackTrace();
|
||||||
printf("exception occurred\n");
|
printf("exception occurred\n");
|
||||||
for (auto& byFile : SPF_messages)
|
for (auto& byFile : SPF_messages)
|
||||||
{
|
|
||||||
for (auto& message : byFile.second)
|
for (auto& message : byFile.second)
|
||||||
{
|
message.print(byFile.first);
|
||||||
string toPrint = "";
|
|
||||||
for (int z = 0; z < message.engMessage.size(); ++z)
|
|
||||||
toPrint += message.engMessage[z];
|
|
||||||
string type;
|
|
||||||
if (message.type == WARR)
|
|
||||||
type = "WARR";
|
|
||||||
else if (message.type == ERROR)
|
|
||||||
type = "ERROR";
|
|
||||||
else if (message.type == NOTE)
|
|
||||||
type = "NOTE";
|
|
||||||
else
|
|
||||||
type = "UNKN";
|
|
||||||
|
|
||||||
printf("%s - [#%d: %s: line %d]: %s\n", type.c_str(), message.group, byFile.first.c_str(), message.line, toPrint.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAllAllocatedData(withDel);
|
deleteAllAllocatedData(withDel);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "json.hpp"
|
||||||
|
|
||||||
#ifdef __SPF
|
#ifdef __SPF
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -164,18 +166,40 @@ public:
|
|||||||
engMessage.erase(engMessage.begin() + engMessage.size() - 1);
|
engMessage.erase(engMessage.begin() + engMessage.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring toString() const
|
nlohmann::json toJson() const
|
||||||
{
|
{
|
||||||
std::wstring retVal = L"|";
|
nlohmann::json resVal;
|
||||||
retVal += std::to_wstring((int)type) + L" ";
|
|
||||||
retVal += std::to_wstring(line) + L" ";
|
resVal["line"] = line;
|
||||||
retVal += std::to_wstring(group);
|
resVal["group"] = group;
|
||||||
retVal += L"|" + value;
|
resVal["value"] = std::string(value.begin(), value.end());
|
||||||
return retVal;
|
return resVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getString() const { return std::string(engMessage.begin(), engMessage.end()); }
|
typeMessage getType() const { return type; }
|
||||||
public:
|
int getLine() const { return line; }
|
||||||
|
|
||||||
|
void print(const std::string& file) const
|
||||||
|
{
|
||||||
|
std::string toPrint = "";
|
||||||
|
for (int z = 0; z < engMessage.size(); ++z)
|
||||||
|
toPrint += engMessage[z];
|
||||||
|
|
||||||
|
std::string typeStr;
|
||||||
|
if (type == WARR)
|
||||||
|
typeStr = "WARR";
|
||||||
|
else if (type == ERROR)
|
||||||
|
typeStr = "ERROR";
|
||||||
|
else if (type == NOTE)
|
||||||
|
typeStr = "NOTE";
|
||||||
|
else
|
||||||
|
typeStr = "UNKN";
|
||||||
|
|
||||||
|
printf("%s - [#%d: %s: line %d]: %s\n", typeStr.c_str(), group, file.c_str(), line, toPrint.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto getUniqKey() const { return std::make_tuple(type, group, line, value); }
|
||||||
|
private:
|
||||||
typeMessage type;
|
typeMessage type;
|
||||||
int group;
|
int group;
|
||||||
int line;
|
int line;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "../DynamicAnalysis/gcov_info.h"
|
#include "../DynamicAnalysis/gcov_info.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
|
#include "json.hpp"
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
#include "acc_analyzer.h"
|
#include "acc_analyzer.h"
|
||||||
@@ -42,6 +43,7 @@ using std::set;
|
|||||||
using std::vector;
|
using std::vector;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::wstring;
|
using std::wstring;
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
#if __cplusplus >= 201703L
|
#if __cplusplus >= 201703L
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
@@ -427,7 +429,7 @@ static map<string, vector<Messages>> removeCopies(map<string, vector<Messages>>
|
|||||||
map<tuple<typeMessage, int, int, wstring>, const Messages*> uniq;
|
map<tuple<typeMessage, int, int, wstring>, const Messages*> uniq;
|
||||||
for (auto& message : byFile.second)
|
for (auto& message : byFile.second)
|
||||||
{
|
{
|
||||||
auto key = make_tuple(message.type, message.group, message.line, message.value);
|
auto key = message.getUniqKey();
|
||||||
/*string tmp = "";
|
/*string tmp = "";
|
||||||
for (auto& s : message.toString())
|
for (auto& s : message.toString())
|
||||||
tmp += (char)s;
|
tmp += (char)s;
|
||||||
@@ -460,7 +462,7 @@ static void convertGlobalMessagesBuffer(short *&result, int *&resultSize)
|
|||||||
bool waschanged = false;
|
bool waschanged = false;
|
||||||
for (auto &message : byFile.second)
|
for (auto &message : byFile.second)
|
||||||
{
|
{
|
||||||
if (message.line > 0)
|
if (message.getLine() > 0)
|
||||||
newVal.push_back(message);
|
newVal.push_back(message);
|
||||||
else
|
else
|
||||||
waschanged = true;
|
waschanged = true;
|
||||||
@@ -470,22 +472,30 @@ static void convertGlobalMessagesBuffer(short *&result, int *&resultSize)
|
|||||||
byFile.second = newVal;
|
byFile.second = newVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring val = L"";
|
json allMessages = json::array();
|
||||||
val += std::to_wstring(copySPF_messages.size());
|
for (auto& byFile : copySPF_messages)
|
||||||
for (auto it = copySPF_messages.begin(); it != copySPF_messages.end(); ++it)
|
|
||||||
{
|
{
|
||||||
val += L"|" + to_wstring(it->first.c_str()) + L"|" + std::to_wstring(it->second.size());
|
json inFile;
|
||||||
for (int k = 0; k < it->second.size(); ++k)
|
inFile["file"] = byFile.first;
|
||||||
val += it->second[k].toString();
|
|
||||||
|
json array = json::array();
|
||||||
|
for (auto& message : byFile.second)
|
||||||
|
{
|
||||||
|
json msg = message.toJson();
|
||||||
|
array.push_back(msg);
|
||||||
|
}
|
||||||
|
inFile["messages"] = array;
|
||||||
|
allMessages.push_back(inFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned len = (unsigned)val.size();
|
json all;
|
||||||
result = new short[len + 1];
|
all["allMessages"] = allMessages;
|
||||||
allocated.insert(result);
|
|
||||||
|
|
||||||
result[len] = '\0';
|
const string str = all.dump();
|
||||||
for (unsigned i = 0; i < len; ++i)
|
const unsigned len = (unsigned)str.size();
|
||||||
result[i] = val[i];
|
|
||||||
|
copyStringToShort(result, str);
|
||||||
|
allocated.insert(result);
|
||||||
|
|
||||||
resultSize = new int[1];
|
resultSize = new int[1];
|
||||||
resultSize[0] = (int)len;
|
resultSize[0] = (int)len;
|
||||||
@@ -1686,4 +1696,16 @@ set<string> fillDistributedArrays(const DataDirective& dataDirectives,
|
|||||||
for (auto& elem : ret)
|
for (auto& elem : ret)
|
||||||
distrArrays.insert(shortName ? elem->GetShortName() : elem->GetName());
|
distrArrays.insert(shortName ? elem->GetShortName() : elem->GetName());
|
||||||
return distrArrays;
|
return distrArrays;
|
||||||
|
}
|
||||||
|
|
||||||
|
void copyStringToShort(short*& result, const string& resVal, bool withEnd)
|
||||||
|
{
|
||||||
|
result = new short[resVal.size() + 1];
|
||||||
|
allocated.insert(result);
|
||||||
|
|
||||||
|
for (int i = 0; i < resVal.size(); ++i)
|
||||||
|
result[i] = resVal[i];
|
||||||
|
|
||||||
|
if (withEnd)
|
||||||
|
result[resVal.size()] = (short)'\0';
|
||||||
}
|
}
|
||||||
@@ -96,3 +96,5 @@ std::vector<std::string> splitAndArgvCreate(const std::string& options);
|
|||||||
|
|
||||||
std::set<DIST::Array*> fillDistributedArraysD(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false);
|
std::set<DIST::Array*> fillDistributedArraysD(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false);
|
||||||
std::set<std::string> fillDistributedArrays(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false, bool shortName = false);
|
std::set<std::string> fillDistributedArrays(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false, bool shortName = false);
|
||||||
|
|
||||||
|
void copyStringToShort(short*& result, const std::string& resVal, bool withEnd = true);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2421"
|
#define VERSION_SPF "2422"
|
||||||
|
|||||||
@@ -218,18 +218,6 @@ static bool tryOpenProjectFile(const char *project)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copyStringToShort(short *&result, const string &resVal, bool withEnd = true)
|
|
||||||
{
|
|
||||||
result = new short[resVal.size() + 1];
|
|
||||||
allocated.insert(result);
|
|
||||||
|
|
||||||
for (int i = 0; i < resVal.size(); ++i)
|
|
||||||
result[i] = resVal[i];
|
|
||||||
|
|
||||||
if (withEnd)
|
|
||||||
result[resVal.size()] = (short)'\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
volatile int passDone = 0;
|
volatile int passDone = 0;
|
||||||
static volatile int rethrow = 0;
|
static volatile int rethrow = 0;
|
||||||
static void runPassesLoop(const vector<passes> &passesToRun, const char *prName, const char *folderNameChar)
|
static void runPassesLoop(const vector<passes> &passesToRun, const char *prName, const char *folderNameChar)
|
||||||
|
|||||||
Reference in New Issue
Block a user