コード例 #1
0
ファイル: pfprofiler.cpp プロジェクト: xqx12/s2e1.1
void PfProfiler::process()
{
    uint64_t maxMissCount=0, maxMissPath=0;
    uint64_t maxICount=0, maxICountPath=0;
    uint64_t minMissCount=(uint64_t)-1, minMissPath=0;
    uint64_t minICount=(uint64_t)-1, minICountPath=0;

    std::ofstream statsFile;
    statsFile.open(CpOutFile.c_str());

    if (TerminatedPaths) {
        statsFile << "#This report shows data for only those paths that generated a test case" << std::endl;
    }


    PathBuilder pb(&m_Parser);
    m_Parser.parse(m_FileName);

    ModuleCache mc(&pb);
    CacheProfiler cp(&mc, &pb);
    TestCase tc(&pb);
    InstructionCounter ic(&pb);

    pb.processTree();

    unsigned pathNum = 0;

    PathSet paths;
    pb.getPaths(paths);

    PathSet::iterator pit;
    for(pit = paths.begin(); pit != paths.end(); ++pit) {
        statsFile << "========== Path " << pathNum << " ========== "<<std::endl;
        std::cout << std::dec << "Path " << pathNum << std::endl;


        TestCaseState *tcs = static_cast<TestCaseState*>(pb.getState(&tc, *pit));
        InstructionCounterState *ics = static_cast<InstructionCounterState*>(pb.getState(&ic, *pit));

        if (TerminatedPaths) {
            if (!tcs || !tcs->hasInputs()) {
                pathNum++;
                continue;
            }
        }

        if (ics) {
            ics->printCounter(statsFile);
        }else {
            statsFile << "No instruction count in the trace file for the current path" << std::endl;
        }

        if (tcs) {
            tcs->printInputs(statsFile);
        }else {
            statsFile << "No test case in the trace file for the current path" << std::endl;
        }

        TopMissesPerModule tmpm(&m_binaries, &cp);

        tmpm.setFilteredProcess(CPFilterProcess);
        tmpm.setFilteredModule(FilterModule);
        tmpm.setMinMissThreshold(CPMinMissCountFilter);

        tmpm.computeStats(*pit);
        statsFile << "Total misses on this path: " << std::dec << tmpm.getTotalMisses() << std::endl;

        tmpm.printAggregatedStatistics(statsFile);
        tmpm.print(statsFile);

        if (ics) {
            if (ics->getCount() > maxICount) {
                maxICount = ics->getCount();
                maxICountPath = pathNum;
            }

            if (ics->getCount() < minICount) {
                minICount = ics->getCount();
                minICountPath = pathNum;
            }
        }

        if (tmpm.getTotalMisses() > maxMissCount) {
            maxMissCount = tmpm.getTotalMisses();
            maxMissPath = pathNum;
        }

        if (tmpm.getTotalMisses() < minMissCount) {
            minMissCount = tmpm.getTotalMisses();
            minMissPath = pathNum;
        }


        ++pathNum;
        statsFile << std::endl;
    }


    statsFile << "----------------------------------" << std::endl << std::dec;
    statsFile << "Miss count        - Max:" << std::setw(10) << maxMissCount << " (path " << std::setw(10) << maxMissPath << ") ";
    statsFile << "Min:" << std::setw(10)<< minMissCount << "(path " << std::setw(10) << minMissPath << ")" << std::endl;

    statsFile << "Instruction count - Max:" << std::setw(10) << maxICount << " (path "<< std::setw(10) << maxICountPath << ") ";
    statsFile << "Min:"<< std::setw(10) << minICount << "(path " << std::setw(10) << minICountPath << ")" << std::endl;

    return;
}
コード例 #2
0
ファイル: TbTrace.cpp プロジェクト: 0bliv10n/s2e
void TbTraceTool::flatTrace()
{
    PathBuilder pb(&m_parser);
    m_parser.parse(TraceFiles);

    ModuleCache mc(&pb);
    TestCase tc(&pb);

    PathSet paths;
    pb.getPaths(paths);

    cl::list<unsigned>::const_iterator listit;

    if (PathList.empty()) {
        PathSet::iterator pit;
        for (pit = paths.begin(); pit != paths.end(); ++pit) {
            PathList.push_back(*pit);
        }
    }

    //XXX: this is efficient only for short paths or for a small number of
    //path, because complexity is O(n2): we reprocess the prefixes.
    for(listit = PathList.begin(); listit != PathList.end(); ++listit) {
        std::cout << "Processing path " << std::dec << *listit << std::endl;
        PathSet::iterator pit = paths.find(*listit);
        if (pit == paths.end()) {
            std::cerr << "Could not find path with id " << std::dec <<
                    *listit << " in the execution trace." << std::endl;
            continue;
        }

        std::stringstream ss;
        ss << LogDir << "/" << *listit << ".txt";
        std::ofstream traceFile(ss.str().c_str());

        TbTrace trace(&m_binaries, &mc, &pb, traceFile);

        if (!pb.processPath(*listit)) {
            std::cerr << "Could not process path " << std::dec << *listit << std::endl;
            continue;
        }

        traceFile << "----------------------" << std::endl;

        if (trace.hasDebugInfo() == false) {
            traceFile << "WARNING: No debug information for any module in the path " << std::dec << *listit << std::endl;
            traceFile << "WARNING: Make sure you have set the module path properly and the binaries contain debug information."
                    << std::endl << std::endl;
        }

        if (trace.hasModuleInfo() == false) {
            traceFile << "WARNING: No module information for any module in the path " << std::dec << *listit << std::endl;
            traceFile << "WARNING: Make sure to use the ModuleTracer plugin before running this tool."
                    << std::endl << std::endl;
        }

        if (trace.hasItems() == false ) {
            traceFile << "WARNING: No basic blocks in the path " << std::dec << *listit << std::endl;
            traceFile << "WARNING: Make sure to use the TranslationBlockTracer plugin before running this tool. "
                    << std::endl << std::endl;
        }

        TestCaseState *tcs = static_cast<TestCaseState*>(pb.getState(&tc, *pit));
        if (!tcs) {
            traceFile << "WARNING: No test case in the path " << std::dec << *listit << std::endl;
            traceFile << "WARNING: Make sure to use the TestCaseGenerator plugin and terminate the states before running this tool. "
                    << std::endl << std::endl;
        }else {
            tcs->printInputs(traceFile);
        }
    }

}
コード例 #3
0
ファイル: pfprofiler.cpp プロジェクト: xqx12/s2e1.1
void PfProfiler::extractAggregatedData()
{
    std::ofstream statsFile;
    std::string sFile = OutDir + "/pf.stats";
    statsFile.open(sFile.c_str());

    if (TerminatedPaths) {
        statsFile << "#This report shows data for only those paths that generated a test case" << std::endl;
    }

    if (FilterModule.size() > 0) {
        statsFile << "#PageFaults and TlbMisses for module " << FilterModule << std::endl;
    }

    statsFile << "#Path TestCase PageFaults TlbMisses ICount" << std::endl;

    PathBuilder pb(&m_Parser);
    m_Parser.parse(m_FileName);

    TestCase tc(&pb);
    ModuleCache mc(&pb);
    InstructionCounter ic(&pb);
    PageFault pf(&pb, &mc);

    if (FilterModule.size() > 0) {
        pf.setModule(FilterModule);
    }


    pb.processTree();

    PathSet paths;
    pb.getPaths(paths);

    PathSet::iterator pit;

    for(pit = paths.begin(); pit != paths.end(); ++pit) {

        PageFaultState *pfs = static_cast<PageFaultState*>(pb.getState(&pf, *pit));
        TestCaseState *tcs = static_cast<TestCaseState*>(pb.getState(&tc, *pit));
        InstructionCounterState *ics = static_cast<InstructionCounterState*>(pb.getState(&ic, *pit));

        if (TerminatedPaths) {
            if (!tcs || !tcs->hasInputs()) {
                continue;
            }
        }

        statsFile << std::dec << *pit << "\t";

        if (tcs) {
            statsFile << "yes" << "\t";
        }else {
            statsFile << "no" << "\t";
        }

        if (!pfs) {
            statsFile << std::dec << "-" << "\t";
            statsFile << std::dec << "-" << "\t";
        } else {
            statsFile << std::dec << pfs->getPageFaults() << "\t";
            statsFile << pfs->getTlbMisses() << "\t";
        }

        if (!ics) {
            statsFile << std::dec << "-" << "\t";
        } else {
            statsFile << std::dec << ics->getCount() << "\t";
        }

        statsFile << std::endl;

    }
}