Example #1
0
void MemoryDebugger::doLookForValue(const s2e::plugins::ExecutionTraceItemHeader &hdr,
                                    const s2e::plugins::ExecutionTraceMemory &item)
{
  /*  if (!(item.flags & EXECTRACE_MEM_WRITE)) {
    if ((m_valueToFind && (item.value != m_valueToFind))) {
        return;
    }
}*/

    printHeader(hdr);
    m_os << " pc=0x" << std::hex << item.pc <<
            " addr=0x" << item.address <<
            " val=0x" << item.value <<
            " size=" << std::dec << (unsigned)item.size <<
            " iswrite=" << (item.flags & EXECTRACE_MEM_WRITE);

    ModuleCacheState *mcs = static_cast<ModuleCacheState*>(m_events->getState(m_cache, &ModuleCacheState::factory));
    const ModuleInstance *mi = mcs->getInstance(hdr.pid, item.pc);
    std::string dbg;
    if (m_library->print(mi, item.pc, dbg, true, true, true)) {
        m_os << " - " << dbg;
    }

     m_os << '\n';

}
Example #2
0
void TbTrace::printDebugInfo(uint64_t pid, uint64_t pc, unsigned tbSize, bool printListing)
{
    ModuleCacheState *mcs = static_cast<ModuleCacheState*>(m_events->getState(m_cache, &ModuleCacheState::factory));
    const ModuleInstance *mi = mcs->getInstance(pid, pc);
    if (!mi) {
        return;
    }
    uint64_t relPc = pc - mi->LoadBase + mi->ImageBase;
    m_output << std::hex << "(" << mi->Name;
    if (relPc != pc) {
       m_output << " 0x" << relPc;
    }
    m_output << ")";

    m_hasModuleInfo = true;

    std::string file = "?", function="?";
    uint64_t line=0;
    if (m_library->getInfo(mi, pc, file, line, function)) {
        size_t pos = file.find_last_of('/');
	if (pos != std::string::npos) {
            file = file.substr(pos+1);
        }

        m_output << " " << file << std::dec << ":" << line << " in " << function;
        m_hasDebugInfo = true;
    }

    if (PrintDisassembly && printListing) {
        m_output << std::endl;
        printDisassembly(mi->Name, relPc, tbSize);
    }
}
Example #3
0
void ForkProfiler::doProfile(
        const s2e::plugins::ExecutionTraceItemHeader &hdr,
        const s2e::plugins::ExecutionTraceFork *te)
{
    ModuleCacheState *mcs = static_cast<ModuleCacheState*>(m_events->getState(m_cache, &ModuleCacheState::factory));

    const ModuleInstance *mi = mcs->getInstance(hdr.pid, te->pc);

    ForkPoint fp;
    fp.pc = te->pc;
    fp.pid = hdr.pid;
    fp.count = 1;
    fp.line = 0;

    m_library->getInfo(mi, te->pc, fp.file, fp.line, fp.function);

    ForkPoints::iterator it = m_forkPoints.find(fp);
    if (it == m_forkPoints.end()) {
        if (mi) {
            fp.module = mi->Name;
            fp.loadbase = mi->LoadBase;
            fp.imagebase = mi->ImageBase;
        } else {
            fp.module = "";
            fp.loadbase = 0;
            fp.imagebase = 0;
        }
        m_forkPoints.insert(fp);
    }else {
        fp = *it;
        m_forkPoints.erase(*it);
        fp.count++;
        m_forkPoints.insert(fp);
    }
}
Example #4
0
void ForkProfiler::doGraph(
        const s2e::plugins::ExecutionTraceItemHeader &hdr,
        const s2e::plugins::ExecutionTraceFork *te)
{
    ModuleCacheState *mcs = static_cast<ModuleCacheState*>(m_events->getState(m_cache, &ModuleCacheState::factory));

    const ModuleInstance *mi = mcs->getInstance(hdr.pid, te->pc);

    Fork f;
    f.id = hdr.stateId;
    f.pid = hdr.pid;
    f.pc = te->pc;
    if (mi) {
        f.module = mi->Name;
        f.relPc = te->pc - mi->LoadBase + mi->ImageBase;
    }else {
        f.relPc = te->pc;
    }

    for (unsigned i=0; i<te->stateCount; ++i) {
        f.children.push_back(te->children[i]);
    }

    m_forks.push_back(f);
}
Example #5
0
void MemoryDebugger::doPageFault(const s2e::plugins::ExecutionTraceItemHeader &hdr,
                                 const s2e::plugins::ExecutionTracePageFault &item)
{
    printHeader(hdr);
    m_os << " pc=0x" << std::hex << item.pc <<
            " addr=0x" << item.address <<
            " iswrite=" << (bool)item.isWrite;

    ModuleCacheState *mcs = static_cast<ModuleCacheState*>(m_events->getState(m_cache, &ModuleCacheState::factory));
    const ModuleInstance *mi = mcs->getInstance(hdr.pid, item.pc);
    std::string dbg;
    if (m_library->print(mi, item.pc, dbg, true, true, true)) {
        m_os << " - " << dbg;
    }

     m_os << '\n';
}
Example #6
0
void Coverage::onItem(unsigned traceIndex,
            const s2e::plugins::ExecutionTraceItemHeader &hdr,
            void *item)
{
    if (hdr.type != s2e::plugins::TRACE_TB_START) {
        return;
    }

    const s2e::plugins::ExecutionTraceTb *te =
            (const s2e::plugins::ExecutionTraceTb*) item;

    ModuleCacheState *mcs = static_cast<ModuleCacheState*>(m_events->getState(m_cache, &ModuleCacheState::factory));

    const ModuleInstance *mi = mcs->getInstance(hdr.pid, te->pc);
    if (!mi) {
        std::cerr << "Could not find module for pc=0x" << std::hex << te->pc << std::endl;
        return;
    }

    BasicBlockCoverage *bbcov = NULL;
    BbCoverageMap::iterator it = m_bbCov.find(mi->Name);
    if (it == m_bbCov.end()) {
        //Look for the file containing the bbs.
        std::string bblist = mi->Name + ".bblist";
        std::string path;
        if (m_library->findLibrary(bblist, path)) {
            BasicBlockCoverage *bb = new BasicBlockCoverage(path, mi->Name);
            m_bbCov[mi->Name] = bb;
            bbcov = bb;
        }
    }else {
        bbcov = (*it).second;
    }

    uint64_t relPc = te->pc - mi->LoadBase + mi->ImageBase;

    if (!bbcov) {
        std::cerr << "The block 0x" << std::hex << relPc << " could not be found in any module. " <<
                "Make sure the path to the lists of basic blocks for module " << mi->Name << " is correct." << std::endl;
        return;
    }

    bbcov->addTranslationBlock(hdr.timeStamp, relPc, relPc+te->size-1);
}
Example #7
0
void ExecutionDebugger::onItem(unsigned traceIndex,
            const s2e::plugins::ExecutionTraceItemHeader &hdr,
            void *item)
{
    if (hdr.type != TRACE_TB_START) {
        return;
    }

    ExecutionTraceTb *tb = (ExecutionTraceTb*) item;

    m_os << " pc=0x" << std::hex << tb->pc <<
            " tpc=0x" << std::hex <<  tb->targetPc ;

    ModuleCacheState *mcs = static_cast<ModuleCacheState*>(m_events->getState(m_cache, &ModuleCacheState::factory));
    const ModuleInstance *mi = mcs->getInstance(hdr.pid, tb->pc);
    std::string dbg;
    if (m_library->print(mi, tb->pc, dbg, true, true, true)) {
        m_os << " - " << dbg;
    }

     m_os << '\n';

}