================ @@ -370,6 +377,61 @@ PerfReaderBase::create(ProfiledBinary *Binary, PerfInputFile &PerfInput, return PerfReader; } +void PerfReaderBase::parseDataAccessPerfTraces( + StringRef DataAccessPerfTraceFile, std::optional<int32_t> PIDFilter) { + std::regex logRegex( + R"(^.*?PERF_RECORD_SAMPLE\(.*?\):\s*(\d+)\/(\d+):\s*(0x[0-9a-fA-F]+)\s+period:\s*\d+\s+addr:\s*(0x[0-9a-fA-F]+)$)"); + + auto BufferOrErr = MemoryBuffer::getFile(DataAccessPerfTraceFile); + std::error_code EC = BufferOrErr.getError(); + if (EC) + exitWithError("Failed to open perf trace file: " + DataAccessPerfTraceFile); + + assert(!SampleCounters.empty() && "Sample counters should not be empty!"); + SampleCounter &Counter = SampleCounters.begin()->second; + line_iterator LineIt(*BufferOrErr.get(), true); + for (; !LineIt.is_at_eof(); ++LineIt) { + StringRef Line = *LineIt; + + MMapEvent MMap; + if (Line.contains("PERF_RECORD_MMAP2")) { + if (PerfScriptReader::extractMMapEventForBinary(Binary, Line, MMap)) { + if (!MMap.MemProtectionFlag.contains("x")) { + Binary->addMMapNonTextEvent(MMap); + } + } + continue; + } + + // Skip lines that do not contain "PERF_RECORD_SAMPLE". + if (!Line.contains("PERF_RECORD_SAMPLE")) { + continue; + } + + std::smatch matches; + const std::string LineStr = Line.str(); + + if (std::regex_search(LineStr.begin(), LineStr.end(), matches, logRegex)) { ---------------- mingmingl-llvm wrote:
done. https://github.com/llvm/llvm-project/pull/148013 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits