Re: [DynInst_API:] oneTimeCode in an exit callback not working


Date: Wed, 27 Jul 2016 09:48:45 -0700
From: Josh Stone <jistone@xxxxxxxxxx>
Subject: Re: [DynInst_API:] oneTimeCode in an exit callback not working
On 07/27/2016 01:56 AM, Martijn wrote:
> 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.

At the time of an exit callback, the process is technically dead.  You
may still be able to examine state, but it won't be able to run any code.


> 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
> 
> 
> _______________________________________________
> Dyninst-api mailing list
> Dyninst-api@xxxxxxxxxxx
> https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
> 

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