Pin
Classes | Public Types | Public Member Functions | List of all members
INSTLIB::ICOUNT Class Reference

#include <icount.H>

Public Types

enum  mode {
  ModeInactive = -1,
  ModeNormal = 0,
  ModeBoth
}
 

Public Member Functions

UINT64 Count (THREADID tid=0) const
 
UINT64 CountWithoutRep (THREADID tid=0) const
 
VOID SetCount (UINT64 count, THREADID tid=0)
 
mode Mode () const
 
VOID Activate (mode m=ModeNormal)
 

Detailed Description

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

#include <iostream>
#include "pin.H"
#include "instlib.H"
KNOB<BOOL> KnobReps(KNOB_MODE_WRITEONCE, "pintool", "reps", "0",
"add count with REP prefixed instructions counted only once");
// This function is called when the application exits
VOID Fini(INT32 code, VOID *v)
{
std::cerr << "Count " << icount.Count() << endl;
if (KnobReps)
std::cerr << "Count (single REPs) " << icount.CountWithoutRep() << endl;
}
// argc, argv are the entire command line, including pin -t <toolname> -- ...
int main(int argc, char * argv[])
{
// Initialize pin
if (PIN_Init(argc, argv))
{
PIN_ERROR("Count executed instructions.\n"
+ KNOB_BASE::StringKnobSummary() + "\n");
}
// Activate instruction counter
if (KnobReps)
else
// Register Fini to be called when the application exits
// Start the program, never returns
return 0;
}

The documentation for this class was generated from the following file: