Re: [DynInst_API:] oneTimeCode() and exit callbacks


Date: Mon, 04 Mar 2013 14:05:38 -0600
From: David Smith <dsmith@xxxxxxxxxx>
Subject: Re: [DynInst_API:] oneTimeCode() and exit callbacks
On 02/27/2013 02:04 PM, Andrew Bernat wrote:
> On Feb 25, 2013, at 4:43 PM, David Smith <dsmith@xxxxxxxxxx
> <mailto:dsmith@xxxxxxxxxx>> wrote:
>>
>> Ah, that question makes more sense. Yes, in the exit callback
>> proc->isStopped() returns false.
> 
> That's not right... 
> 
> Can you set the environment variables DYNINST_DEBUG_PROCCONTROL and
> DYNINST_DEBUG_SIGNAL to 1 and re-run, stopping at the point where the
> process does not report stopped? That's clearly a bug. 

To take systemtap out of the picture, here's a very small test program
that runs "whoami" with a exit callback. In the exit callback, isStopped
always returns 0.

====
# g++ -g -o exit_test -I/usr/include/dyninst exit_test.cxx
-L/usr/lib64/dyninst -ldyninstAPI
# DYNINSTAPI_RT_LIB=/usr/lib64/dyninst/libdyninstAPI_RT.so ./exit_test
dsmith
In exit_callback, isStopped = 0
====

I had trouble saving the output produced by the debug environment
variables, but you should be able to run this small test program with
them enabled to see what is going on.

Thanks for the help.

-- 
David Smith
dsmith@xxxxxxxxxx
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)
#include <cstdlib>
#include <ostream>
#include <BPatch.h>
#include <BPatch_thread.h>

using namespace std;

void
exit_callback(BPatch_thread *thread, BPatch_exitType type)
{
    BPatch_process* process = thread->getProcess();
    clog << "In exit_callback, isStopped = " << process->isStopped() << endl;
}

int
main(int argc, const char *argv[])
{
    const char *new_argv[] = { "whoami", NULL };
    BPatch patch;

    BPatch_process *app = patch.processCreate("/usr/bin/whoami", &new_argv[0]);
    patch.registerExitCallback(exit_callback);

    app->continueExecution();
    while (!app->isTerminated()) {
	patch.waitForStatusChange();
    }
}
[← Prev in Thread] Current Thread [Next in Thread→]