本文整理汇总了C++中FILTER::SelectTrace方法的典型用法代码示例。如果您正苦于以下问题:C++ FILTER::SelectTrace方法的具体用法?C++ FILTER::SelectTrace怎么用?C++ FILTER::SelectTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FILTER
的用法示例。
在下文中一共展示了FILTER::SelectTrace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Trace
/*
Instrumentation function;
Track the trace, the usage of the code in the bbls and the bbl exits
*/
VOID Trace(TRACE trace, VOID *v)
{
if (!filter.SelectTrace(trace))
return;
/* Add trace to db */
Trace_Info(TRACE_Address(trace),
TRACE_NumBbl(trace),
TRACE_NumIns(trace));
/* Inc. trace execution count */
TRACE_InsertCall(trace, IPOINT_BEFORE,
(AFUNPTR) Trace_Info,
IARG_ADDRINT, TRACE_Address(trace),
IARG_UINT32, TRACE_NumBbl(trace),
IARG_UINT32, TRACE_NumIns(trace),
IARG_END);
USIZE accum_code_size = 0;
for (BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl = BBL_Next(bbl))
{
accum_code_size += BBL_Size(bbl);
/* Add bbl to db */
Bbl_Info(BBL_Address(bbl),
BBL_NumIns(bbl),
TRACE_Address(trace),
BBL_Size(bbl),
accum_code_size);
INS ins = BBL_InsTail(bbl);
if (INS_IsBranchOrCall(ins) || INS_IsRet(ins))
{
/* Inc. bbl exit count */
INS_InsertCall(ins, IPOINT_TAKEN_BRANCH,
(AFUNPTR) BblExit_Info,
IARG_ADDRINT, BBL_Address(bbl),
IARG_ADDRINT, TRACE_Address(trace),
IARG_END);
}
}
/* Trace falloff in the case the bbl is too big and does not
necessarily end with a bbl terminating op */
INS ins = BBL_InsTail(TRACE_BblTail(trace));
if (! INS_IsBranchOrCall(ins))
{
/* Inc. trace falloff exit count */
INS_InsertCall(ins, IPOINT_BEFORE,
(AFUNPTR) TraceFall_Info,
IARG_ADDRINT, TRACE_Address(trace),
IARG_END);
}
}
示例2: Trace
// Call every time a basic block is hit
VOID Trace(TRACE trace, VOID *v) {
// Use filtering to select traces. See filter.H in $PIN_ROOT/source/tools/InstLib
// for the possible options that can be used as a filter
// I typically use the -filter_no_shared_libs option. Make sure that you
// specify the tool before using this flag
// (e.g., $PIN_ROOT/pin -t bb_trace.so -filter_no_shared_libs -- EXE ARGS) -JL
if (!filter.SelectTrace(trace))
return;
for (BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl = BBL_Next(bbl))
{
BBL_InsertCall(bbl, IPOINT_BEFORE, (AFUNPTR)printip, IARG_INST_PTR,
IARG_UINT32, BBL_NumIns(bbl), IARG_UINT32, BBL_NumIns(bbl), IARG_END);
}
}
示例3: Trace
/*
* Insert code to write data to a thread-specific buffer for instructions
* that access memory.
*/
VOID Trace(TRACE trace, VOID *v)
{
if (!filter.SelectTrace(trace))
return;
TRACE_InsertCall(trace, IPOINT_BEFORE, AFUNPTR(traceAddr),IARG_FAST_ANALYSIS_CALL, IARG_REG_VALUE, thread_ctx_ptr, IARG_END);
ADDRINT trace_addr = TRACE_Address(trace);
for(BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl=BBL_Next(bbl))
{
INS ins = BBL_InsTail(bbl); //Last instruction of bbl
if (INS_IsBranchOrCall(ins) || INS_IsRet(ins))
{
INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)setCJMP,
IARG_CALL_ORDER, CALL_ORDER_FIRST,
IARG_FAST_ANALYSIS_CALL,
IARG_REG_VALUE, thread_ctx_ptr,
IARG_ADDRINT, trace_addr,
IARG_BRANCH_TAKEN,
IARG_RETURN_REGS, ScratchReg,
IARG_END);
// thread_ctx_t *temp = reinterpret_cast<thread_ctx_t *>(thread_ctx_ptr);
INS_InsertFillBuffer(ins, IPOINT_TAKEN_BRANCH, bufId,
IARG_REG_VALUE, ScratchReg, offsetof(struct TRACEREF, traceId),
// IARG_UINT32, TraceCount, offsetof(struct TRACEREF, traceCount),
IARG_END);
/*
INS_InsertFillBuffer(ins, IPOINT_TAKEN_BRANCH, bufId,
// IARG_ADDRINT, ((TRACE_Address(trace) & 0x00ffffff)<<8), offsetof(struct TRACEREF, traceId),
IARG_REG_VALUE, ScratchReg, offsetof(struct TRACEREF, traceId),
// IARG_UINT32, TraceCount, offsetof(struct TRACEREF, traceCount),
IARG_END);
*/
/*
INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR) setCJMP,
IARG_FAST_ANALYSIS_CALL,
IARG_BRANCH_TAKEN,
IARG_END);
INS_InsertFillBuffer(ins, IPOINT_TAKEN_BRANCH, bufId, IARG_ADDRINT, ((TraceAddr & 0x00ffffff)<<8|BBNumber), offsetof(struct TRACEREF, traceId), IARG_END);
*/
}
}
}
示例4: Trace
// Pin calls this function every time a new basic block is encountered
// It inserts a call to docount
VOID Trace(TRACE trace, VOID *v)
{
if (!filter.SelectTrace(trace))
return;
TRACE_InsertCall(trace, IPOINT_BEFORE, AFUNPTR(print2), IARG_FAST_ANALYSIS_CALL, IARG_ADDRINT, TRACE_Address(trace), IARG_END);
// Visit every basic block in the trace
for (BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl = BBL_Next(bbl))
{
INS ins = BBL_InsTail(bbl); //Last instruction of bbl
if (INS_IsBranchOrCall(ins) || INS_IsRet(ins))
{
INS_InsertIfCall(ins, IPOINT_BEFORE, (AFUNPTR) setCJMP,
IARG_FAST_ANALYSIS_CALL,
IARG_BRANCH_TAKEN,
IARG_END);
//IPOINT_TAKEN_BRANCH
INS_InsertThenCall(ins, IPOINT_BEFORE, (AFUNPTR) print, IARG_END);
}
}
}
示例5: Trace
VOID Trace(TRACE trace, VOID * val)
{
if (!filter.SelectTrace(trace))
return;
for (BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl = BBL_Next(bbl))
{
for (INS ins = BBL_InsHead(bbl); INS_Valid(ins); ins = INS_Next(ins))
{
out << hex << setw(8) << INS_Address(ins) << " ";
RTN rtn = TRACE_Rtn(trace);
if (RTN_Valid(rtn))
{
IMG img = SEC_Img(RTN_Sec(rtn));
if (IMG_Valid(img)) {
out << IMG_Name(img) << ":" << RTN_Name(rtn) << " " ;
}
}
out << INS_Disassemble(ins) << endl;
}
}
}
示例6: Trace
/*
* Insert code to write data to a thread-specific buffer for instructions
* that access memory.
*/
VOID Trace(TRACE trace, VOID *v)
{
if (!filter.SelectTrace(trace))
return;
TRACE_InsertCall(trace, IPOINT_BEFORE, AFUNPTR(traceAddr), IARG_FAST_ANALYSIS_CALL, IARG_ADDRINT, TRACE_Address(trace), IARG_END);
for(BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl=BBL_Next(bbl))
{
INS ins = BBL_InsTail(bbl); //Last instruction of bbl
/* if (INS_IsDirectBranch(ins) && INS_Category(ins) == XED_CATEGORY_COND_BR)
{
INS_InsertFillBuffer(ins, IPOINT_BEFORE, bufId,
IARG_ADDRINT,INS_NextAddress(ins), offsetof(struct TRACEREF, pc),
// IARG_ADDRINT, memOp, offsetof(struct TRACEREF, ea),
// IARG_UINT32, refSize, offsetof(struct TRACEREF, size),
IARG_BOOL, TRUE, offsetof(struct TRACEREF, direct),
IARG_END);
}
else if( INS_IsIndirectBranchOrCall(ins) )
{
INS_InsertFillBuffer(ins, IPOINT_BEFORE, bufId,
IARG_ADDRINT,INS_NextAddress(ins), offsetof(struct TRACEREF, pc),
// IARG_ADDRINT, memOp, offsetof(struct TRACEREF, ea),
// IARG_UINT32, refSize, offsetof(struct TRACEREF, size),
IARG_BOOL, FALSE, offsetof(struct TRACEREF, direct),
IARG_END);
} */
if (INS_IsBranchOrCall(ins) || INS_IsRet(ins))
{
INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR) setCJMP,
IARG_FAST_ANALYSIS_CALL,
IARG_BRANCH_TAKEN,
IARG_END);
if (BranchTaken)
{
UINT32 addr_postfix = TraceAddr & 0x00ffffff;
UINT32 trace_id = (addr_postfix<<8) | FLIP;
if(trace_id != PreviousTraceID)
{
if (TraceCount > 1)
{
INS_InsertFillBuffer(ins, IPOINT_BEFORE, bufId,
IARG_ADDRINT,PreviousTraceID, offsetof(struct TRACEREF, traceId),
IARG_UINT32,(TraceCount-1), offsetof(struct TRACEREF, traceCount),
IARG_END);
TraceCount=1;
}
INS_InsertFillBuffer(ins, IPOINT_BEFORE, bufId,
IARG_ADDRINT,trace_id, offsetof(struct TRACEREF, traceId),
IARG_UINT32,TraceCount, offsetof(struct TRACEREF, traceCount),
IARG_END);
PreviousTraceID = trace_id;
} // end of "if(trace_id != PreviousTraceID)"
else
{
TraceCount++;
}
TraceAddr=0;
MASK=0;
FLIP=0;
BranchTaken=0;
}
示例7: Trace
/*
* Insert code to write data to a thread-specific buffer for instructions
* that access memory.
*/
VOID Trace(TRACE trace, VOID *v)
{
if (!filter.SelectTrace(trace))
return;
// TRACE_InsertCall(trace, IPOINT_BEFORE, AFUNPTR(traceAddr), IARG_FAST_ANALYSIS_CALL, IARG_ADDRINT, TRACE_Address(trace), IARG_END);
/*
BBL bbl = TRACE_BblHead(trace);
if (BBL_Valid(bbl))
{
INS ins = BBL_InsHead(bbl);
if(INS_Valid(ins))
{
INS_InsertFillBuffer(ins, IPOINT_BEFORE, bufId,
IARG_ADDRINT, TRACE_Address(trace), offsetof(struct TRACEREF, traceId),
// IARG_UINT32, TraceCount, offsetof(struct TRACEREF, traceCount),
IARG_END);
}
}
*/
for(BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl=BBL_Next(bbl))
{
INS ins = BBL_InsTail(bbl); //Last instruction of bbl
/*
if(INS_Valid(ins))
{
INS_InsertFillBuffer(ins, IPOINT_BEFORE, bufId, IARG_ADDRINT, BBL_Address(bbl), offsetof(struct TRACEREF, traceId), IARG_END);
}
*/
if (likely(INS_IsDirectBranch(ins) && INS_Category(ins) == XED_CATEGORY_COND_BR))
{
//INS_InsertFillBuffer(ins, IPOINT_BEFORE, bufId, IARG_ADDRINT, (BBL_Address(bbl) & 0x0fffffff <<4), offsetof(struct TRACEREF, traceId), IARG_END);
ADDRINT DirectBranchTarget = INS_DirectBranchOrCallTargetAddress(ins);
INS_InsertFillBuffer(ins, IPOINT_TAKEN_BRANCH, bufId, IARG_ADDRINT, DirectBranchTarget, offsetof(struct TRACEREF, traceId), IARG_END);
ADDRINT DirectBranchFallThrough = INS_NextAddress(ins);
INS_InsertFillBuffer(ins, IPOINT_AFTER, bufId, IARG_ADDRINT, DirectBranchFallThrough, offsetof(struct TRACEREF, traceId), IARG_END);
}
else if(unlikely(INS_IsIndirectBranchOrCall(ins)))
//INS_InsertFillBuffer(ins, IPOINT_BEFORE, bufId, IARG_ADDRINT, ((BBL_Address(bbl) & 0x0fffffff <<4)|0x1), offsetof(struct TRACEREF, traceId), IARG_END);
INS_InsertFillBuffer(ins, IPOINT_BEFORE, bufId, IARG_BRANCH_TARGET_ADDR, offsetof(struct TRACEREF, traceId), IARG_END);
}
/*
for(BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl=BBL_Next(bbl))
{
INS ins = BBL_InsTail(bbl); //Last instruction of bbl
if (INS_IsBranchOrCall(ins) || INS_IsRet(ins))
{
INS_InsertIfCall(ins, IPOINT_BEFORE, (AFUNPTR) setCJMP,
IARG_FAST_ANALYSIS_CALL,
IARG_BRANCH_TAKEN,
IARG_END);
INS_InsertFillBufferThen(ins, IPOINT_BEFORE, bufId,
IARG_ADDRINT, TraceId, offsetof(struct TRACEREF, traceId),
// IARG_UINT32, TraceCount, offsetof(struct TRACEREF, traceCount),
IARG_END);
}
}
*/
}