added json for call graph
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/json.hpp"
|
||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
@@ -37,6 +38,8 @@ using std::cout;
|
||||
using std::endl;
|
||||
using std::stack;
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
//TODO: improve parameter checking
|
||||
@@ -2592,4 +2595,71 @@ void setInlineAttributeToCalls(const map<string, FuncInfo*>& allFunctions,
|
||||
}
|
||||
}
|
||||
|
||||
static json convertToJson(const FuncInfo* currFunc) {
|
||||
json func;
|
||||
|
||||
if (currFunc)
|
||||
{
|
||||
func["funcName"] = currFunc->funcName;
|
||||
func["line"] = currFunc->linesNum.first;
|
||||
func["lineEnd"] = currFunc->linesNum.second;
|
||||
func["isMain"] = (int)currFunc->isMain;
|
||||
func["needToInline"] = (int)currFunc->needToInline;
|
||||
func["doNotInline"] = (int)currFunc->doNotInline;
|
||||
func["doNotAnalyze"] = (int)currFunc->doNotAnalyze;
|
||||
|
||||
json func_pars = json::array();
|
||||
|
||||
for (int z = 0; z < currFunc->funcParams.countOfPars; ++z)
|
||||
{
|
||||
json par;
|
||||
par["inoutType"] = currFunc->funcParams.inout_types[z];
|
||||
par["identificator"] = currFunc->funcParams.identificators[z];
|
||||
par["parameterT"] = string(paramNames[currFunc->funcParams.parametersT[z]]);
|
||||
|
||||
func_pars.push_back(par);
|
||||
}
|
||||
|
||||
func["params"] = func_pars;
|
||||
|
||||
json calls_from = json::array();
|
||||
for (const auto& call_from : currFunc->callsFromDetailed)
|
||||
{
|
||||
json call;
|
||||
call["line"] = call_from.detailCallsFrom.second;
|
||||
call["funcName"] = call_from.detailCallsFrom.first;
|
||||
|
||||
calls_from.push_back(call);
|
||||
}
|
||||
func["callsFrom"] = calls_from;
|
||||
}
|
||||
return func;
|
||||
}
|
||||
|
||||
json convertToJson(const map<string, vector<FuncInfo*>>& funcsByFileMap) {
|
||||
json loopsByFile = json::array();
|
||||
|
||||
for (auto& byFile : funcsByFileMap)
|
||||
{
|
||||
json func;
|
||||
const string& file = byFile.first;
|
||||
|
||||
json func_array = json::array();
|
||||
for (auto& func : byFile.second)
|
||||
{
|
||||
auto conv = convertToJson(func);
|
||||
if (!conv.empty())
|
||||
func_array.push_back(conv);
|
||||
}
|
||||
|
||||
func["file"] = file;
|
||||
func["functions"] = func_array;
|
||||
|
||||
loopsByFile.push_back(func);
|
||||
}
|
||||
|
||||
json allFuncs;
|
||||
allFuncs["allFunctions"] = loopsByFile;
|
||||
return allFuncs;
|
||||
}
|
||||
#undef DEBUG
|
||||
|
||||
Reference in New Issue
Block a user