MCPcopy Create free account
hub / github.com/aras-p/ClangBuildAnalyzer / SaveBuildEvents

Function SaveBuildEvents

src/BuildEvents.cpp:592–629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590const uint32_t kFileMagic = 0x43424130; // 'CBA0'
591
592bool SaveBuildEvents(BuildEventsParser* parser, const std::string& fileName)
593{
594 FILE* f = fopen(fileName.c_str(), "wb");
595 if (f == nullptr)
596 {
597 printf("%sERROR: failed to save to file '%s'%s\n", col::kRed, fileName.c_str(), col::kReset);
598 return false;
599 }
600
601 BufferedWriter w(f);
602
603 w.Write(kFileMagic);
604 int64_t eventsCount = parser->resultEvents.size();
605 w.Write(eventsCount);
606 for(const auto& e : parser->resultEvents)
607 {
608 int32_t eType = (int32_t)e.type;
609 w.Write(eType);
610 w.Write(e.ts);
611 w.Write(e.dur);
612 w.Write(e.detailIndex.idx);
613 w.Write(e.parent.idx);
614 int64_t childCount = e.children.size();
615 w.Write(childCount);
616 w.Write(e.children.data(), childCount * sizeof(e.children[0]));
617 }
618
619 int64_t namesCount = parser->resultNames.size();
620 w.Write(namesCount);
621 for(const auto& n : parser->resultNames)
622 {
623 uint32_t nSize = (uint32_t)n.size();
624 w.Write(nSize);
625 w.Write(n.data(), nSize);
626 }
627
628 return true;
629}
630
631bool LoadBuildEvents(const std::string& fileName, BuildEvents& outEvents, BuildNames& outNames)
632{

Callers 1

ProcessJsonFilesFunction · 0.85

Calls 2

WriteMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected