From 8f55c13a0cf3d3e3c97072b2eeb9bba53c8f7ab2 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Tue, 27 May 2025 18:10:24 +0300 Subject: [PATCH] added dumping messages to json --- src/Sapfor.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index c424b3c..5f5f93d 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -64,6 +64,7 @@ #include "DvmhRegions/LoopChecker.h" #include "DvmhRegions/ReadWriteAnalyzer.h" #include "Utils/utils.h" +#include "Utils/json.hpp" #include "Distribution/Array.h" #include "VisualizerCalls/get_information.h" @@ -107,6 +108,7 @@ using namespace std; using std::chrono::high_resolution_clock; using std::chrono::duration_cast; using std::chrono::milliseconds; +using json = nlohmann::json; int PASSES_DONE[EMPTY_PASS]; bool PASSES_DONE_INIT = false; @@ -2658,9 +2660,28 @@ int main(int argc, char **argv) { printStackTrace(); printf("exception occurred\n"); + + json byFileArray = json::array(); for (auto& byFile : SPF_messages) + { + json inFile; + inFile["file"] = byFile.first; + + 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["allMessage"] = byFileArray; + + FILE* outF = fopen("dump_messages.json", "w"); + fprintf(outF, "%s", allMessages.dump().c_str()); + fclose(outF); } deleteAllAllocatedData(withDel);