69 const auto endpoint = [](
const BoundedInt& value)
71 if (value.is_infinity())
72 return cJSON_CreateString(value.is_plus_infinity() ?
"+oo" :
"-oo");
73 return cJSON_CreateNumber(value.getNumeral());
75 cJSON *bugDescription = cJSON_CreateObject();
81 cJSON_AddItemToObject(bugDescription,
"AllocLowerBound", allocLB);
82 cJSON_AddItemToObject(bugDescription,
"AllocUpperBound", allocUB);
83 cJSON_AddItemToObject(bugDescription,
"AccessLowerBound", accessLB);
84 cJSON_AddItemToObject(bugDescription,
"AccessUpperBound", accessUB);
86 return bugDescription;
145 cJSON *bugDescription = cJSON_CreateObject();
146 cJSON *pathInfo = cJSON_CreateArray();
148 for(
auto eventIt =
bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
150 cJSON *newBranch = cJSON_CreateObject();
151 cJSON *branchLoc = cJSON_Parse((*eventIt).getEventLoc().c_str());
152 if(branchLoc ==
nullptr) branchLoc = cJSON_CreateObject();
154 cJSON *branchCondition = cJSON_CreateString((*eventIt).getEventDescription().c_str());
156 cJSON_AddItemToObject(newBranch,
"BranchLoc", branchLoc);
157 cJSON_AddItemToObject(newBranch,
"BranchCond", branchCondition);
159 cJSON_AddItemToArray(pathInfo, newBranch);
162 cJSON_AddItemToObject(bugDescription,
"ConditionalFreePath", pathInfo);
164 return bugDescription;
183 cJSON *bugDescription = cJSON_CreateObject();
185 cJSON *pathInfo = cJSON_CreateArray();
187 for(
auto eventIt =
bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
189 cJSON *newBranch = cJSON_CreateObject();
190 cJSON *branchLoc = cJSON_Parse((*eventIt).getEventLoc().c_str());
191 if(branchLoc ==
nullptr) branchLoc = cJSON_CreateObject();
192 cJSON *branchCondition = cJSON_CreateString((*eventIt).getEventDescription().c_str());
194 cJSON_AddItemToObject(newBranch,
"BranchLoc", branchLoc);
195 cJSON_AddItemToObject(newBranch,
"BranchCond", branchCondition);
197 cJSON_AddItemToArray(pathInfo, newBranch);
199 cJSON_AddItemToObject(bugDescription,
"DoubleFreePath", pathInfo);
201 return bugDescription;
232 cJSON *bugDescription = cJSON_CreateObject();
234 cJSON *pathInfo = cJSON_CreateArray();
237 for(
auto eventIt =
bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
239 cJSON *newBranch = cJSON_CreateObject();
240 cJSON *branchLoc = cJSON_Parse((*eventIt).getEventLoc().c_str());
241 if(branchLoc ==
nullptr) branchLoc = cJSON_CreateObject();
242 cJSON *branchCondition = cJSON_CreateString((*eventIt).getEventDescription().c_str());
244 cJSON_AddItemToObject(newBranch,
"BranchLoc", branchLoc);
245 cJSON_AddItemToObject(newBranch,
"BranchCond", branchCondition);
247 cJSON_AddItemToArray(pathInfo, newBranch);
249 cJSON_AddItemToObject(bugDescription,
"ConditionalFileClosePath", pathInfo);
251 return bugDescription;
356 std::map<u32_t, std::string> eventType2Str =
364 ofstream jsonFile(filePath, ios::out);
369 jsonFile <<
"\"Defects\": [\n";
370 size_t commaCounter =
bugSet.size() - 1;
371 for (
auto bugPtr :
bugSet)
373 cJSON *singleDefect = cJSON_CreateObject();
376 cJSON *bugType = cJSON_CreateString(
378 cJSON_AddItemToObject(singleDefect,
"DefectType", bugType);
380 cJSON *bugLoc = cJSON_Parse(bugPtr->getLoc().c_str());
381 if (bugLoc ==
nullptr)
383 bugLoc = cJSON_CreateObject();
385 cJSON_AddItemToObject(singleDefect,
"Location", bugLoc);
387 cJSON *bugFunction = cJSON_CreateString(
388 bugPtr->getFuncName().c_str());
389 cJSON_AddItemToObject(singleDefect,
"Function", bugFunction);
391 cJSON_AddItemToObject(singleDefect,
"Description",
392 bugPtr->getBugDescription());
395 cJSON *eventList = cJSON_CreateArray();
407 cJSON *singleEvent = cJSON_CreateObject();
409 cJSON *eventType = cJSON_CreateString(
410 eventType2Str[event.getEventType()].c_str());
411 cJSON_AddItemToObject(singleEvent,
"EventType", eventType);
413 cJSON *eventFunc = cJSON_CreateString(
414 event.getFuncName().c_str());
415 cJSON_AddItemToObject(singleEvent,
"Function", eventFunc);
417 cJSON *eventLoc = cJSON_Parse(event.getEventLoc().c_str());
418 if (eventLoc ==
nullptr)
420 eventLoc = cJSON_CreateObject();
422 cJSON_AddItemToObject(singleEvent,
"Location", eventLoc);
424 cJSON *eventDescription = cJSON_CreateString(
425 event.getEventDescription().c_str());
426 cJSON_AddItemToObject(singleEvent,
"Description", eventDescription);
428 cJSON_AddItemToArray(eventList, singleEvent);
431 cJSON_AddItemToObject(singleDefect,
"Events", eventList);
434 char *singleDefectStr = cJSON_Print(singleDefect);
435 jsonFile << singleDefectStr;
436 if (commaCounter != 0)
445 jsonFile <<
"\n],\n";
448 jsonFile <<
"\"Time\": " <<
time <<
",\n";
449 jsonFile <<
"\"Memory\": \"" <<
mem <<
"\",\n";
450 jsonFile <<
"\"Coverage\": " <<
coverage <<
"\n";