Pin
Macros | Typedefs | Enumerations | Functions | Variables
pin_client.cpp File Reference
#include "level_base.H"
#include "level_core.H"
#include "level_imgio.H"
#include "level_vmclient.H"
#include "level_pinclient.H"
#include <set>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include "my_unistd.H"
#include <sys/syscall.h>
#include <iostream>

Macros

#define EnterPinClientSlaveMode()   CheckPinClientLock(__FUNCTION__)
 
#define ExitPinClientSlaveMode()   CheckPinClientLock(__FUNCTION__)
 
#define LOG_IMAGE(s)   if(ClientInt()->_VmLog) ClientInt()->_VmLog("IMAGE", s);
 
#define LOG_SYM(s)   if(ClientInt()->_VmLog) ClientInt()->_VmLog("SYMBOLS", s);
 
#define LOG_PROBE(s)   if(ClientInt()->_VmLog) ClientInt()->_VmLog("PROBE", s);
 
#define LOG_FETCH_RTN_INS(s)   if(ClientInt()->_VmLog) ClientInt()->_VmLog("FETCH_RTN_INS", s);
 
#define LOG_UNWIND(s)   if(ClientInt()->_VmLog) ClientInt()->_VmLog("UNWIND", s);
 
#define LOG_BUFFER(s)   if(ClientInt()->_VmLog) ClientInt()->_VmLog("BUFFER", s);
 
#define LOG_JIT_PROFILING(s)   if(ClientInt()->_VmLog) ClientInt()->_VmLog("VTUNE_JIT_API", s);
 
#define LOG_VMLOG(s)   if(ClientInt()->_VmLog) ClientInt()->_VmLog("LOG", s);
 
#define LOG_VMWARNING(s)   if(ClientInt()->_VmLog) ClientInt()->_VmLog("WARNING", s);
 

Typedefs

typedef TRACE_CLASS * LEVEL_PINCLIENT::TRACE
 
typedef VOID * LEVEL_PINCLIENT::PIN_CONFIGURATION_INFO
 
typedef COMPLEX_CALLBACKVAL_BASE * LEVEL_PINCLIENT::PIN_CALLBACK
 
typedef VOID(* LEVEL_PINCLIENT::REMOVE_INSTRUMENTATION_CALLBACK) (VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::DETACH_CALLBACK) (VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::DETACH_PROBED_CALLBACK) (VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::ATTACH_PROBED_CALLBACK) (VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::ATTACH_CALLBACK) (VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::APPLICATION_START_CALLBACK) (VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::PREPARE_FOR_FINI_CALLBACK) (VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::FINI_CALLBACK) (INT32 code, VOID *v)
 
typedef size_t(* LEVEL_PINCLIENT::FETCH_CALLBACK) (void *buf, ADDRINT addr, size_t size, EXCEPTION_INFO *pExceptInfo, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::OUT_OF_MEMORY_CALLBACK) (size_t size, VOID *v)
 
typedef ADDRINT(PIN_FAST_ANALYSIS_CALLLEVEL_PINCLIENT::MEMORY_ADDR_TRANS_CALLBACK) (PIN_MEM_TRANS_INFO *memTransInfo, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::SMC_CALLBACK) (ADDRINT traceStartAddress, ADDRINT traceEndAddress, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::FORK_CALLBACK) (THREADID threadid, const CONTEXT *ctxt, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::THREAD_START_CALLBACK) (THREADID threadIndex, CONTEXT *ctxt, INT32 flags, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::THREAD_ATTACH_PROBED_CALLBACK) (VOID *sigmask, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::THREAD_DETACH_PROBED_CALLBACK) (VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::THREAD_ATTACH_CALLBACK) (THREADID threadIndex, CONTEXT *ctxt, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::THREAD_DETACH_CALLBACK) (THREADID threadIndex, const CONTEXT *ctxt, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::THREAD_FINI_CALLBACK) (THREADID threadIndex, const CONTEXT *ctxt, INT32 code, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::CONTEXT_CHANGE_CALLBACK) (THREADID threadIndex, CONTEXT_CHANGE_REASON reason, const CONTEXT *from, CONTEXT *to, INT32 info, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::SYSCALL_ENTRY_CALLBACK) (THREADID threadIndex, CONTEXT *ctxt, SYSCALL_STANDARD std, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::SYSCALL_EXIT_CALLBACK) (THREADID threadIndex, CONTEXT *ctxt, SYSCALL_STANDARD std, VOID *v)
 
typedef BOOL(* LEVEL_PINCLIENT::INTERCEPT_SIGNAL_CALLBACK) (THREADID tid, INT32 sig, CONTEXT *ctxt, BOOL hasHandler, const EXCEPTION_INFO *pExceptInfo, VOID *v)
 
typedef VOID *(* LEVEL_PINCLIENT::TRACE_BUFFER_CALLBACK) (BUFFER_ID id, THREADID tid, const CONTEXT *ctxt, VOID *buf, UINT64 numElements, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::INS_INSTRUMENT_CALLBACK) (INS ins, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::TRACE_INSTRUMENT_CALLBACK) (TRACE trace, VOID *v)
 
typedef VOID(* LEVEL_PINCLIENT::RTN_INSTRUMENT_CALLBACK) (RTN rtn, VOID *v)
 

Enumerations

enum  LEVEL_PINCLIENT::PROBE_MODE {
  PROBE_MODE_DEFAULT = 0,
  PROBE_MODE_ALLOW_RELOCATION = (1<<0)
}
 
enum  LEVEL_PINCLIENT::SMC_ENABLE_DISABLE_TYPE {
  SMC_ENABLE,
  SMC_DISABLE
}
 
enum  LEVEL_PINCLIENT::FPOINT {
  LEVEL_PINCLIENT::FPOINT_BEFORE,
  LEVEL_PINCLIENT::FPOINT_AFTER_IN_PARENT,
  LEVEL_PINCLIENT::FPOINT_AFTER_IN_CHILD
}
 
enum  LEVEL_PINCLIENT::ATTACH_STATUS {
  LEVEL_PINCLIENT::ATTACH_INITIATED,
  LEVEL_PINCLIENT::ATTACH_FAILED_DETACH
}
 

Functions

GLOBALCONST PIN_CALLBACK LEVEL_PINCLIENT::PIN_CALLBACK_INVALID (0)
 
VOID LEVEL_PINCLIENT::PIN_LockClient ()
 
VOID LEVEL_PINCLIENT::PIN_UnlockClient ()
 
VOID LEVEL_PINCLIENT::PIN_WriteErrorMessage (const char *msg, INT32 type, PIN_ERR_SEVERITY_TYPE severity, INT32 num,...)
 
AFUNPTR LEVEL_PINCLIENT::RTN_Replace (RTN replacedRtn, AFUNPTR replacementFun)
 
AFUNPTR LEVEL_PINCLIENT::RTN_ReplaceSignature (RTN replacedRtn, AFUNPTR replacementFun,...)
 
AFUNPTR LEVEL_PINCLIENT::RTN_ReplaceProbed (RTN replacedRtn, AFUNPTR replacementFun)
 
AFUNPTR LEVEL_PINCLIENT::RTN_ReplaceProbedEx (RTN replacedRtn, PROBE_MODE mode, AFUNPTR replacementFun)
 
VOID LEVEL_PINCLIENT::PIN_CallApplicationFunction (const CONTEXT *ctxt, THREADID tid, CALLINGSTD_TYPE cstype, AFUNPTR origFunPtr, CALL_APPLICATION_FUNCTION_PARAM *param,...)
 
BOOL LEVEL_PINCLIENT::INS_IsAddedForFunctionReplacement (INS ins)
 
VOID LEVEL_PINCLIENT::CALLBACK_SetExecutionOrder (PIN_CALLBACK callback, CALL_ORDER order)
 
CALL_ORDER LEVEL_PINCLIENT::CALLBACK_GetExecutionOrder (PIN_CALLBACK callback)
 
PIN_CALLBACK LEVEL_PINCLIENT::TRACE_AddInstrumentFunction (TRACE_INSTRUMENT_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::INS_AddInstrumentFunction (INS_INSTRUMENT_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddFiniFunction (FINI_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddPrepareForFiniFunction (PREPARE_FOR_FINI_CALLBACK fun, VOID *val)
 
VOID LEVEL_PINCLIENT::PIN_AddFetchFunction (FETCH_CALLBACK fun, VOID *val)
 
size_t LEVEL_PINCLIENT::PIN_FetchCode (void *copyBuf, const VOID *address, size_t maxSize, EXCEPTION_INFO *pExceptInfo)
 
VOID LEVEL_PINCLIENT::PIN_AddOutOfMemoryFunction (OUT_OF_MEMORY_CALLBACK fun, VOID *val)
 
VOID LEVEL_PINCLIENT::PIN_AddMemoryAddressTransFunction (MEMORY_ADDR_TRANS_CALLBACK fun, VOID *val)
 
VOID LEVEL_PINCLIENT::TRACE_AddSmcDetectedFunction (SMC_CALLBACK fun, VOID *val)
 
MEMORY_ADDR_TRANS_CALLBACK LEVEL_PINCLIENT::PIN_GetMemoryAddressTransFunction ()
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddDetachFunction (DETACH_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddDetachFunctionProbed (DETACH_PROBED_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddThreadStartFunction (THREAD_START_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddThreadAttachProbedFunction (THREAD_ATTACH_PROBED_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddThreadAttachFunction (THREAD_ATTACH_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddThreadDetachProbedFunction (THREAD_DETACH_PROBED_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddThreadDetachFunction (THREAD_DETACH_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddApplicationStartFunction (APPLICATION_START_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddThreadFiniFunction (THREAD_FINI_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddContextChangeFunction (CONTEXT_CHANGE_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddSyscallEntryFunction (SYSCALL_ENTRY_CALLBACK fun, VOID *val)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddSyscallExitFunction (SYSCALL_EXIT_CALLBACK fun, VOID *val)
 
BOOL LEVEL_PINCLIENT::PIN_InterceptSignal (INT32 sig, INTERCEPT_SIGNAL_CALLBACK fun, VOID *val)
 
BOOL LEVEL_PINCLIENT::PIN_UnblockSignal (INT32 sig, BOOL enable)
 
VOID LEVEL_PINCLIENT::PIN_SetSmcSupport (SMC_ENABLE_DISABLE_TYPE enable_disable)
 
PIN_CALLBACK LEVEL_PINCLIENT::PIN_AddForkFunction (FPOINT point, FORK_CALLBACK fun, VOID *val)
 
VOID LEVEL_PINCLIENT::PIN_RemoveInstrumentation ()
 
VOID LEVEL_PINCLIENT::PIN_RemoveInstrumentationInRange (ADDRINT start, ADDRINT end)
 
VOID LEVEL_PINCLIENT::PIN_RemoveFiniFunctions ()
 
VOID LEVEL_PINCLIENT::PIN_Detach ()
 
ATTACH_STATUS LEVEL_PINCLIENT::PIN_Attach (ATTACH_CALLBACK fun, VOID *val)
 
VOID LEVEL_PINCLIENT::PIN_DetachProbed ()
 
ATTACH_STATUS LEVEL_PINCLIENT::PIN_AttachProbed (ATTACH_PROBED_CALLBACK fun, VOID *val)
 
VOID LEVEL_PINCLIENT::INS_InsertPredicatedCall (INS ins, IPOINT ipoint, AFUNPTR funptr,...)
 
VOID LEVEL_PINCLIENT::INS_InsertCall (INS ins, IPOINT action, AFUNPTR funptr,...)
 
VOID LEVEL_PINCLIENT::INS_InsertIfCall (INS ins, IPOINT action, AFUNPTR funptr,...)
 
VOID LEVEL_PINCLIENT::INS_InsertThenCall (INS ins, IPOINT action, AFUNPTR funptr,...)
 
VOID LEVEL_PINCLIENT::INS_InsertIfPredicatedCall (INS ins, IPOINT action, AFUNPTR funptr,...)
 
VOID LEVEL_PINCLIENT::INS_InsertThenPredicatedCall (INS ins, IPOINT action, AFUNPTR funptr,...)
 
PIN_CONFIGURATION_INFO LEVEL_PINCLIENT::PIN_CreateDefaultConfigurationInfo ()
 
VOID LEVEL_PINCLIENT::PIN_SetAllowedConcurrentCallbacks (PIN_CONFIGURATION_INFO options, PIN_CALLBACK_TYPE callbackType)
 
VOID LEVEL_PINCLIENT::PIN_StartProgram (PIN_CONFIGURATION_INFO options=PIN_CreateDefaultConfigurationInfo())
 
VOID LEVEL_PINCLIENT::PIN_StartProgramProbed ()
 
const std::string & LEVEL_PINCLIENT::PIN_Version ()
 
BOOL LEVEL_PINCLIENT::PIN_Init (INT32 argc, CHAR **argv)
 
VOID LEVEL_PINCLIENT::TRACE_InsertCall (TRACE trace, IPOINT action, AFUNPTR funptr,...)
 
VOID LEVEL_PINCLIENT::TRACE_InsertIfCall (TRACE trace, IPOINT action, AFUNPTR funptr,...)
 
VOID LEVEL_PINCLIENT::TRACE_InsertThenCall (TRACE trace, IPOINT action, AFUNPTR funptr,...)
 
BBL LEVEL_PINCLIENT::TRACE_BblHead (TRACE trace)
 
BBL LEVEL_PINCLIENT::TRACE_BblTail (TRACE trace)
 
ADDRINT LEVEL_PINCLIENT::TRACE_Address (TRACE trace)
 
USIZE LEVEL_PINCLIENT::TRACE_Size (TRACE trace)
 
RTN LEVEL_PINCLIENT::TRACE_Rtn (TRACE trace)
 
BOOL LEVEL_PINCLIENT::TRACE_HasFallThrough (TRACE trace)
 
UINT32 LEVEL_PINCLIENT::TRACE_NumBbl (TRACE trace)
 
UINT32 LEVEL_PINCLIENT::TRACE_NumIns (TRACE trace)
 
VOID LEVEL_PINCLIENT::BBL_InsertCall (BBL bbl, IPOINT action, AFUNPTR funptr,...)
 
VOID LEVEL_PINCLIENT::BBL_InsertIfCall (BBL bbl, IPOINT action, AFUNPTR funptr,...)
 
VOID LEVEL_PINCLIENT::BBL_InsertThenCall (BBL bbl, IPOINT action, AFUNPTR funptr,...)
 
BOOL LEVEL_PINCLIENT::BBL_HasFallThrough (BBL bbl)
 
BOOL LEVEL_PINCLIENT::PIN_SupportsProcessorState (PROCESSOR_STATE state)
 
BOOL LEVEL_PINCLIENT::PIN_ContextContainsState (CONTEXT *ctxt, PROCESSOR_STATE state)
 
VOID LEVEL_PINCLIENT::PIN_SetContextRegval (CONTEXT *ctxt, REG reg, const UINT8 *val)
 
VOID LEVEL_PINCLIENT::PIN_GetContextRegval (const CONTEXT *ctxt, REG reg, UINT8 *val)
 
VOID LEVEL_PINCLIENT::PIN_SetContextReg (CONTEXT *ctxt, REG reg, ADDRINT val)
 
ADDRINT LEVEL_PINCLIENT::PIN_GetContextReg (const CONTEXT *ctxt, REG reg)
 
VOID LEVEL_PINCLIENT::PIN_SetContextFPState (CONTEXT *ctxt, const FPSTATE *fpstate)
 
VOID LEVEL_PINCLIENT::PIN_GetContextFPState (const CONTEXT *ctxt, FPSTATE *fpstate)
 
REGSET LEVEL_PINCLIENT::PIN_GetFullContextRegsSet ()
 
VOID LEVEL_PINCLIENT::PIN_SaveContext (const CONTEXT *ctxtFrom, CONTEXT *ctxtTo)
 
VOID LEVEL_PINCLIENT::PIN_ExecuteAt (const CONTEXT *ctxt)
 
VOID LEVEL_PINCLIENT::PIN_SetSyscallArgument (CONTEXT *ctxt, SYSCALL_STANDARD std, UINT32 argNum, ADDRINT val)
 
ADDRINT LEVEL_PINCLIENT::PIN_GetSyscallArgument (const CONTEXT *ctxt, SYSCALL_STANDARD std, UINT32 argNum)
 
VOID LEVEL_PINCLIENT::PIN_SetSyscallNumber (CONTEXT *ctxt, SYSCALL_STANDARD std, ADDRINT val)
 
ADDRINT LEVEL_PINCLIENT::PIN_GetSyscallNumber (const CONTEXT *ctxt, SYSCALL_STANDARD std)
 
ADDRINT LEVEL_PINCLIENT::PIN_GetSyscallReturn (const CONTEXT *ctxt, SYSCALL_STANDARD std)
 
ADDRINT LEVEL_PINCLIENT::PIN_GetSyscallErrno (const CONTEXT *ctxt, SYSCALL_STANDARD std)
 
VOID LEVEL_PINCLIENT::PIN_SetPhysicalContextReg (PHYSICAL_CONTEXT *pPhysCtxt, REG reg, ADDRINT val)
 
ADDRINT LEVEL_PINCLIENT::PIN_GetPhysicalContextReg (const PHYSICAL_CONTEXT *pPhysCtxt, REG reg)
 
VOID LEVEL_PINCLIENT::PIN_SetPhysicalContextFPState (PHYSICAL_CONTEXT *pPhysCtxt, const VOID *fpstate)
 
VOID LEVEL_PINCLIENT::PIN_GetPhysicalContextFPState (const PHYSICAL_CONTEXT *pPhysCtxt, VOID *fpstate)
 
VOID LEVEL_PINCLIENT::PIN_RaiseException (const CONTEXT *ctxt, THREADID tid, const EXCEPTION_INFO *pExceptInfo)
 
VOID LEVEL_PINCLIENT::INS_RewriteMemoryOperand (INS ins, UINT32 memindex, REG reg)
 
VOID LEVEL_PINCLIENT::INS_InsertIndirectJump (INS ins, IPOINT ipoint, REG reg)
 
VOID LEVEL_PINCLIENT::INS_InsertDirectJump (INS ins, IPOINT ipoint, ADDRINT tgt)
 
REG LEVEL_PINCLIENT::PIN_ClaimToolRegister ()
 
CHAR * LEVEL_PINCLIENT::PIN_VmFullPath ()
 
const CHAR * LEVEL_PINCLIENT::PIN_ToolFullPath ()
 
NORETURN VOID LEVEL_PINCLIENT::PIN_ExitProcess (INT32 exitCode)
 
INT LEVEL_PINCLIENT::PIN_GetPid ()
 
VOID LEVEL_PINCLIENT::INS_Delete (INS ins)
 
VOID LEVEL_PINCLIENT::IARGLIST_AddArguments (IARGLIST args,...)
 
IARGLIST LEVEL_PINCLIENT::IARGLIST_Alloc ()
 
VOID LEVEL_PINCLIENT::IARGLIST_Free (IARGLIST args)
 
size_t LEVEL_PINCLIENT::PIN_SafeCopy (VOID *dst, const VOID *src, size_t size)
 
size_t LEVEL_PINCLIENT::PIN_SafeCopyEx (VOID *dst, const VOID *src, size_t size, EXCEPTION_INFO *pExceptInfo)
 
VOID LEVEL_PINCLIENT::INS_InsertFillBuffer (INS ins, IPOINT action, BUFFER_ID id,...)
 
VOID LEVEL_PINCLIENT::INS_InsertFillBufferPredicated (INS ins, IPOINT action, BUFFER_ID id,...)
 
VOID LEVEL_PINCLIENT::INS_InsertFillBufferThen (INS ins, IPOINT action, BUFFER_ID id,...)
 
BUFFER_ID LEVEL_PINCLIENT::PIN_DefineTraceBuffer (size_t recordSize, UINT32 numPages, TRACE_BUFFER_CALLBACK fun, VOID *val)
 
VOID * LEVEL_PINCLIENT::PIN_AllocateBuffer (BUFFER_ID id)
 
VOID LEVEL_PINCLIENT::PIN_DeallocateBuffer (BUFFER_ID id, VOID *buf)
 
BOOL LEVEL_PINCLIENT::PIN_IsActionPending (THREADID tid)
 
UINT32 LEVEL_PINCLIENT::PIN_GetInitialThreadCount ()
 
VOID * LEVEL_PINCLIENT::PIN_GetBufferPointer (CONTEXT *const ctxt, BUFFER_ID id)
 
BOOL LEVEL_PINCLIENT::PIN_CheckReadAccess (VOID *addr)
 
BOOL LEVEL_PINCLIENT::PIN_CheckWriteAccess (VOID *addr)
 
ADDRINT LEVEL_PINCLIENT::PIN_GetAuxVectorValue (ADDRINT type, bool *found)
 

Variables

LOCALVAR CONDINSTSTATE LEVEL_PINCLIENT::condInstStateForIns = CONDINST_NORMAL
 
LOCALVAR PREDICATE LEVEL_PINCLIENT::insLastIfPredicate = PREDICATE_ALWAYS_TRUE
 
LOCALVAR CONDINSTSTATE LEVEL_PINCLIENT::condInstStateForTrace = CONDINST_NORMAL
 

Detailed Description

Client side interface to pin vm.