[DynInst_API:] Fwd: Instrumentation of snippet for dynamic target


Date: Sun, 23 Mar 2014 18:52:03 -0700
From: Jiten Pathy <jpathy@xxxxxxxxxxxxxxxxxxxx>
Subject: [DynInst_API:] Fwd: Instrumentation of snippet for dynamic target
Hello,
The problem at hand is to do some operation on the dynamic target at
basic block exit.
I tried to use the following to test dynamic target:

BPatch_dynamicTargetExpr dt;
appBin->insertSnippet(dt, *((*bb)->findExitPoint()), BPatch_callBefore);

Doesn't work:
[../dyninstAPI/src/ast.C:1868] ERROR: failure to generate operand


With some snippets it does save and restore of all registers including
xmm registers(doesn't do liveness analysis?)
So is there a way to insert raw bytes(opcodes?) at a point.
 I tried to use PatchAPI, but probably i am doing it wrong?
the following didn't work for me:

class MySnippet : public Snippet {
        public:
                virtual bool generate(Point *pt, Buffer &buf) {
                        buf.copy((void*)"AAAAAAAAAAAAAAAAAAA", 20);
                        return true;
                }
};

auto pmgr = convert(appImage);
Patcher patcher(pmgr);

auto pb = convert(*bb);
auto pt = pmgr->findPoint(Location::Instruction(pb, pb->last()),
Point::PreInsn);
if (pt != NULL) {
    MySnippet::Ptr snippet = MySnippet::create(new MySnippet);
    patcher.add(PushBackCommand::create(pt, snippet));
}

patcher.commit();
appBin->writeFile(outBinary);

Any help would be appreciated.
[← Prev in Thread] Current Thread [Next in Thread→]