CONTROLLER


Modules

 CONTROLLER_LENGTH
 CONTROLLER_START_ADDRESS
 CONTROLLER_STOP_ADDRESS
 CONTROLLER_FINI
 CONTROLLER_SKIP
 CONTROLLER_UNIFORM
 CONTROLLER_INIT
 CONTROLLER_PINPOINT
 CONTROLLER_MULTI
 CONTROLLER_STATS_EVENT_ADDRESS

Typedefs

typedef VOID(* INSTLIB::CONTROL_HANDLER )(CONTROL_EVENT, VOID *, CONTEXT *, VOID *, THREADID tid)

Enumerations

enum  INSTLIB::CONTROL_EVENT {
  CONTROL_INVALID,
  INSTLIB::CONTROL_START,
  INSTLIB::CONTROL_STOP
}

Detailed Description

It is often desirable to use instrumentation to observe an interval of the execution of a program. Controllers are used to detect the beginning or end of an interval. Some of the methods are instruction counts, or the nth time an address or symbol is executed.

A controller is usually an ALARM with some coordination for stop and start and some built in command line switches.

The example below can be found in InstLibExamples/control.cpp

#include <iostream>

#include "pin.H"
#include "instlib.H"

using namespace INSTLIB;

// Track the number of instructions executed
ICOUNT icount;

// Contains knobs and instrumentation to recognize start/stop points
CONTROL control(false, "controller_");

VOID Handler(CONTROL_EVENT ev, VOID * v, CONTEXT * ctxt, VOID * ip, THREADID tid)
{
    std::cout << "ip: " << ip << " " << icount.Count() ;
#if defined(TARGET_IA32) || defined(TARGET_IA32E)
    std::cout << " [ with REP iterations " << icount.CountWithREP() << "] ";
#endif
    switch(ev)
    {
      case CONTROL_START:
        std::cout << "Start" << endl;
        break;

      case CONTROL_STOP:
        std::cout << "Stop" << endl;
        break;

      default:
        ASSERTX(false);
        break;
    }
}
    
INT32 Usage()
{
    cerr <<
        "This pin tool demonstrates use of CONTROL to identify start/stop points in a program\n"
        "\n";

    cerr << KNOB_BASE::StringKnobSummary() << endl;
    return -1;
}

// argc, argv are the entire command line, including pin -t <toolname> -- ...
int main(int argc, char * argv[])
{
    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }

    icount.Activate();
    
    // Activate alarm, must be done before PIN_StartProgram
    control.CheckKnobs(Handler, 0);

    // Start the program, never returns
    PIN_StartProgram();
    
    return 0;
}



Typedef Documentation

typedef VOID(* INSTLIB::CONTROL_HANDLER)(CONTROL_EVENT, VOID *, CONTEXT *, VOID *, THREADID tid)
 

Type for generic event handler


Enumeration Type Documentation

enum INSTLIB::CONTROL_EVENT
 

Event that is passed to handler when controller detects the beginning or end of an interval

Enumerator:
CONTROL_START  Beginning of interval.
CONTROL_STOP  End of interval.


Generated on Thu May 15 03:23:41 2008 for Pin by  doxygen 1.4.6