[DynInst_API:] oneTimeCode in an exit callback not working


Date: Wed, 27 Jul 2016 10:56:48 +0200
From: Martijn <martijn@xxxxxxxxxxxxxxxxx>
Subject: [DynInst_API:] oneTimeCode in an exit callback not working
Hello,

I am trying to use proc->oneTimeCode inside an exit callback. The one time code adds a function call to finalize stuff in my instrumentation library.

The exit callback nicely gets called at the end of the mutee, but the oneTimeCode does not call my finalize function. I tested the same oneTimeCode function call outside the exit callback and that works fine.

My code in short (borrowed from the retee example in the dyninst manual), simplified to a puts() call:

static void exitCallback(BPatch_thread* thread, BPatch_exitType) {
ÂÂÂ BPatch_process* proc = thread->getProcess();
ÂÂÂ BPatch_image* image = proc->getImage();

ÂÂÂ std::vector<BPatch_snippet*> args;
ÂÂÂ BPatch_constExpr stringArg("Exiting mutee");
ÂÂÂ args.push_back(&stringArg);
ÂÂÂ std::vector<BPatch_function*> putsFuncs;
ÂÂÂ image->findFunction("puts", putsFuncs);
ÂÂÂ BPatch_funcCallExpr putsCall(*putsFuncs[0], args);

ÂÂÂ proc->oneTimeCode(putsCall);
ÂÂÂ proc->continueExecution();
}

int main(int argc, char* argv[]) {
ÂÂÂ BPatch_process* proc = bpatch.processCreate(argv[1], (const char**)(argv + 1));

ÂÂÂ bpatch.registerExitCallback(exitCallback);

ÂÂÂ proc->continueExecution();
ÂÂÂ while(!proc->isTerminated())
ÂÂÂÂÂÂÂ bpatch.waitForStatusChange();

ÂÂÂ return EXIT_SUCCESS;
}

I am running this on Ubuntu 16.04 desktop, using g++ 5.3.1, and the latest dyninst master (head at commit 895d3fa) from github.
The mutee is a simple C hello world program, compiled with gcc -g.
A full example and makefile to build and run is attached.

Any input to where I go wrong is greatly appreciated!

Cheers,
ÂÂÂ Martijn

Attachment: onetimecode.tgz
Description: GNU Zip compressed data

[← Prev in Thread] Current Thread [Next in Thread→]