#include <debugger-shell.H>
Public Member Functions | |
virtual VOID | InsertBreakpointBefore (INS ins, BBL bbl, CALL_ORDER order, const std::string &message)=0 |
virtual VOID | InsertBreakpointAfter (INS ins, BBL bbl, IPOINT ipoint, CALL_ORDER order, const std::string &message)=0 |
virtual | ~ICUSTOM_INSTRUMENTOR ()=0 |
Most tools do not need to override the default instrumentation, so most tools need not use this interface.
|
Destroys the custom instrumentor object.
|
|
The debugger shell calls this method to insert a "then" instrumentation call to an analysis routine that stops at a debugger breakpoint _after_ an instruction. The default instrumentation looks like this. Tools that implement this method should insert similar instrumentation:
VOID InsertBreakpointAfter(INST ins, BBL bbl, IPOINT ipoint, CALL_ORDER order, const std::string &message) { INS_InsertThenCall(ins, ipoint, (AFUNPTR)TriggerBreakpointAfter, IARG_CALL_ORDER, order, IARG_CONTEXT, IARG_INST_PTR, IARG_THREAD_ID, IARG_PTR, message.c_str(), IARG_END); } VOID TriggerBreakpointAfter(CONTEXT *ctxt, ADDRINT pc, THREADID tid, const char *message) { std::ostringstream os; os << message << "\n"; os << "Breakpoint triggered after instruction at 0x" << std::hex << pc; PIN_ApplicationBreakpoint(ctxt, tid, FALSE, os.str()); }
|
|
The debugger shell calls this method to insert a "then" instrumentation call to an analysis routine that stops at a debugger breakpoint _before_ an instruction. The default instrumentation looks like this. Tools that implement this method should insert similar instrumentation:
VOID InsertBreakpointBefore(INST ins, BBL bbl, CALL_ORDER order, const std::string &message) { INS_InsertThenCall(ins, IPOINT_BEFORE, (AFUNPTR)TriggerBreakpointBefore, IARG_CALL_ORDER, order, IARG_CONTEXT, IARG_THREAD_ID, IARG_UINT32, static_cast<UINT32>(RegSkipOne), IARG_PTR, message.c_str(), IARG_END); } VOID TriggerBreakpointBefore(CONTEXT *ctxt, THREADID tid, UINT32 regSkipOne, const char *message) { ADDRINT skipPc = PIN_GetContextReg(ctxt, static_cast<REG>(regSkipOne)); ADDRINT pc = PIN_GetContextReg(ctxt, REG_INST_PTR); if (skipPc == pc) return PIN_SetContextReg(ctxt, static_cast<REG>(regSkipOne), pc); PIN_ApplicationBreakpoint(ctxt, tid, FALSE, message); } See the method ISHELL::GetSkipOneRegister() for the register number to use for RegSkipOne.
|