341 std::map<u32_t, std::string> eventType2Str =
349 ofstream jsonFile(filePath, ios::out);
354 jsonFile <<
"\"Defects\": [\n";
355 size_t commaCounter =
bugSet.size() - 1;
356 for (
auto bugPtr :
bugSet)
358 cJSON *singleDefect = cJSON_CreateObject();
361 cJSON *bugType = cJSON_CreateString(
363 cJSON_AddItemToObject(singleDefect,
"DefectType", bugType);
365 cJSON *bugLoc = cJSON_Parse(bugPtr->getLoc().c_str());
366 if (bugLoc ==
nullptr)
368 bugLoc = cJSON_CreateObject();
370 cJSON_AddItemToObject(singleDefect,
"Location", bugLoc);
372 cJSON *bugFunction = cJSON_CreateString(
373 bugPtr->getFuncName().c_str());
374 cJSON_AddItemToObject(singleDefect,
"Function", bugFunction);
376 cJSON_AddItemToObject(singleDefect,
"Description",
377 bugPtr->getBugDescription());
380 cJSON *eventList = cJSON_CreateArray();
392 cJSON *singleEvent = cJSON_CreateObject();
394 cJSON *eventType = cJSON_CreateString(
395 eventType2Str[event.getEventType()].c_str());
396 cJSON_AddItemToObject(singleEvent,
"EventType", eventType);
398 cJSON *eventFunc = cJSON_CreateString(
399 event.getFuncName().c_str());
400 cJSON_AddItemToObject(singleEvent,
"Function", eventFunc);
402 cJSON *eventLoc = cJSON_Parse(event.getEventLoc().c_str());
403 if (eventLoc ==
nullptr)
405 eventLoc = cJSON_CreateObject();
407 cJSON_AddItemToObject(singleEvent,
"Location", eventLoc);
409 cJSON *eventDescription = cJSON_CreateString(
410 event.getEventDescription().c_str());
411 cJSON_AddItemToObject(singleEvent,
"Description", eventDescription);
413 cJSON_AddItemToArray(eventList, singleEvent);
416 cJSON_AddItemToObject(singleDefect,
"Events", eventList);
419 char *singleDefectStr = cJSON_Print(singleDefect);
420 jsonFile << singleDefectStr;
421 if (commaCounter != 0)
430 jsonFile <<
"\n],\n";
433 jsonFile <<
"\"Time\": " <<
time <<
",\n";
434 jsonFile <<
"\"Memory\": \"" <<
mem <<
"\",\n";
435 jsonFile <<
"\"Coverage\": " <<
coverage <<
"\n";
static bool classof(const GenericBug *bug)
ClassOf.
static const std::map< GenericBug::BugType, std::string > BugType2Str
std::vector< SVFBugEvent > EventStack