Dynamic Probe Class Library

Dynamic Probe Class Library Programming Guide


Chapter 12. Disconnecting from target application processes

When an analysis tool connects to a target application process, the DPCL system establishes a connection between the analysis tool process and the target application process. The DPCL system also creates the environment within the process that allows the analysis tool to insert and remove instrumentation probes. If the analysis tool actually creates one or more target application processes (using the Process::bcreate, Process::create, PoeAppl::bcreate, or PoeAppl::create functions as described in Starting the target application), the analysis tool will automatically be connected to the process(es). If the analysis tool did not create the process(es), however, it must explicitly connect in order to install and execute probes within the process(es). It does this using the Process::connect, Process::bconnect, Application::connect, or Application::bconnect functions as described in Connecting to the target application.

It is important to note that, once connected to a target application process, the analysis tool does not need to explicitly disconnect from that process. When either the analysis tool process or the target application process terminates, the connection will, of course, be broken. There are times, however, when an analysis tool may want to explicitly disconnect from processes. For example, if an analysis tool was done examining one set of processes, it may wish to disconnect from that set of processes before connecting to another.

Disconnecting from a process not only removes the connection to the process, but also removes any probes that the analysis tool has installed in the process. To disconnect from a single process, the analysis tool code can use the asynchronous function Process::disconnect or its blocking equivalent Process::bdisconnect. To disconnect from processes on an application-wide basis (for all Process objects managed by an Application object), the analysis tool can use the functions Application::disconnect or Application::bdisconnect.

Table 51. Disconnecting from one or more target application processes
To disconnect: From a single process (Process object) From multiple processes (all of the Process objects managed by an Application object)
Using the asynchronous function disconnect
AisStatus sts = p->disconnect(disconnect_cb, 

          GCBTagType(0));

  check_status("p->disconnect(disconnect_cb, 

          GCBTagType(0))", sts);

 

 

//

// callback to be called after the 

// disconnect completes

//

void disconnect_cb(GCBSysType sys, 

          GCBTagType tag, GCBObjType obj, 

          GCBMsgType msg)

{

 

      // code within callback routine

      // can check the status of the

      // operation and respond to its

      // completion by, for example,

      // continuing with other work 

 

}


AisStatus sts = a->disconnect(disconnect_cb, 

          GCBTagType(0));

  check_status("a->disconnect(disconnect_cb, 

          GCBTagType(0))", sts);

 

 

//

// callback to be called after the 

// disconnect completes

//

void disconnect_cb(GCBSysType sys, 

          GCBTagType tag, GCBObjType obj, 

          GCBMsgType msg)

{

 

      // code within callback routine

      // can check the status of the

      // operation and respond to its

      // completion by, for example,

      // continuing with other work 

 

}


Using the blocking function bdisconnect
sts = P.bdisconnect();

  check_status("P.bdisconnect()", sts);

  printf("  %s: disconnected from pid:%d\n", 

          toolname,  P.get_pid());


sts = A.bdisconnect();

    check_status("A.bdisconnect()", sts);

    printf("  %s: disconnected from A\n", 

            toolname);


For more information on the Process::disconnect, Process::bdisconnect, Application::disconnect, or Application::bdisconnect functions, refer to their UNIX man pages or their entries in the DPCL Class Reference.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]