Пример #1
0
bool
query_function_entry(void *addr)
{
    FunctionSet::iterator it = function_entries.find(addr);

    if (it == function_entries.end()) return false;
    else return true;
}
Пример #2
0
void
entries_in_range(void *start, void *end, vector<void *> &result)
{
#ifdef DEBUG_ENTRIES_IN_RANGE
    printf("function entries for range [%p, %p]\n", start, end);
#endif
    FunctionSet::iterator it = function_entries.find(start);
    for (; it != function_entries.end(); it++) {
        void *addr = (*it).first;
        if (addr > end) return;
#ifdef DEBUG_ENTRIES_IN_RANGE
        printf("  %p\n", addr);
#endif
        result.push_back(addr);
    }
}
Пример #3
0
void
add_function_entry(void *addr, const string *comment, bool isvisible,
                   int call_count)
{
    FunctionSet::iterator it = function_entries.find(addr);

    if (it == function_entries.end()) {
        new_function_entry(addr, comment ? new string(*comment) : NULL,
                           isvisible, call_count);
    } else {
        Function *f = (*it).second;
        if (comment) {
            f->AppendComment(comment);
        } else if (f->comment) {
            f->isvisible = true;
        }
        f->call_count += call_count;
    }
}
Пример #4
0
bool TraceMem::TraceMemPass::runOnModule(Module &M) {
    FunctionSet fAdded;

    trace_read = dyn_cast<Function>(M.getOrInsertFunction("trace_readi32",
            Type::getInt32Ty(M.getContext()),
            Type::getInt32Ty(M.getContext()),
            Type::getInt32PtrTy(M.getContext()),
            NULL));
    trace_write = dyn_cast<Function>(M.getOrInsertFunction("trace_writei32",
            Type::getVoidTy(M.getContext()),
            Type::getInt32Ty(M.getContext()),
            Type::getInt32PtrTy(M.getContext()),
            Type::getInt32Ty(M.getContext()),
            NULL));

    seq = 0;

    // Process each function
    for (auto i = M.begin(), ie = M.end(); i != ie; ++i) {
        auto func = i;
        auto it = fAdded.find(func);
        if (it == fAdded.end()) {
            fAdded.insert(func);

            if (func->size()) {
                analyzeFunction(func);
                ++num_functions_analyzed;
            } else {
                ++num_functions_skipped;
            }
        }
    }

    num_instructions_analyzed = fAnalyzedInstructions.size();

    return true;
}
Пример #5
0
bool contains_function_entry(void *address)
{
    FunctionSet::iterator it = function_entries.find(address);
    if (it != function_entries.end()) return true;
    else return false;
}