本文整理汇总了C++中IMG_AddInstrumentFunction函数的典型用法代码示例。如果您正苦于以下问题:C++ IMG_AddInstrumentFunction函数的具体用法?C++ IMG_AddInstrumentFunction怎么用?C++ IMG_AddInstrumentFunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IMG_AddInstrumentFunction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
// Initialize pin & symbol manager
PIN_InitSymbols();
if( PIN_Init(argc,argv) )
{
return Usage();
}
// Write to a file since cout and cerr maybe closed by the application
TraceFile.open(KnobOutputFile.Value().c_str());
TraceFile << hex;
TraceFile.setf(ios::showbase);
// Register Image to be called to instrument functions.
IMG_AddInstrumentFunction(Image, 0);
// RTN_AddInstrumentFunction(Routine, 0);
// Register ImageUnload to be called when an image is unloaded
// IMG_AddUnloadFunction(ImageUnload, 0);
// Register Fini to be called when the application exits
PIN_AddFiniFunction(Fini, 0);
// Never returns
PIN_StartProgram();
return 0;
}
示例2: main
int main(INT32 argc, CHAR **argv)
{
// Initialize the pin lock
InitLock(&lock);
// Initialize pin
if (PIN_Init(argc, argv)) return Usage();
PIN_InitSymbols();
out = fopen(KnobOutputFile.Value().c_str(), "w");
// Register ImageLoad to be called when each image is loaded.
IMG_AddInstrumentFunction(ImageLoad, 0);
// Register Analysis routines to be called when a thread begins/ends
PIN_AddThreadStartFunction(ThreadStart, 0);
PIN_AddThreadFiniFunction(ThreadFini, 0);
// Register Fini to be called when the application exits
PIN_AddFiniFunction(Fini, 0);
// Never returns
PIN_StartProgram();
return 0;
}
示例3: main
int main(int argc, char * argv[])
{
PIN_InitSymbols();
if (PIN_Init(argc, argv))
return 1;
Stat.open(STAT_FILE);
TraceFile.open(TRACE_FILE);
RetFile.open(RET_FILE);
PIN_InitLock(&lock);
tls_key = PIN_CreateThreadDataKey(0);
// Register ThreadStart to be called when a thread starts.
PIN_AddThreadStartFunction(ThreadStart, 0);
TRACE_AddInstrumentFunction(Trace, 0);
IMG_AddInstrumentFunction(ImageLoad, 0);
INS_AddInstrumentFunction(Instruction, 0);
PIN_AddFiniFunction(Fini, 0);
PIN_StartProgram();
return 0;
}
示例4: main
int main( int argc, char *argv[] ) {
if ( PIN_Init( argc, argv ) ) {
return Usage();
}
PIN_InitSymbols();
initRcdcSim();
IMG_AddInstrumentFunction( instrumentImage, NULL );
TRACE_AddInstrumentFunction( instrumentTrace, NULL );
cerr << " Before this function\n";
//INS_AddInstrumentFunction(Instruction, 0);
cerr << " After this function\n";
PIN_AddThreadStartFunction( threadBegin, NULL );
PIN_AddThreadFiniFunction( threadEnd, NULL );
PIN_AddContextChangeFunction( beforeSignal, NULL );
PIN_AddSyscallEntryFunction( beforeSyscall, NULL );
PIN_AddSyscallExitFunction( afterSyscall, NULL );
PIN_AddFiniUnlockedFunction( pinFini, NULL );
if ( !CODECACHE_ChangeMaxInsPerTrace( 4096 * 1024 ) ) {
fprintf( stderr, "TLSProf::CODECACHE_ChangeMaxInsPerTrace failed.\n" );
}
THREADID tid = PIN_SpawnInternalThread( ioThread, NULL, 0, &s_IOThreadId );
assert( tid != INVALID_THREADID );
PIN_StartProgram();
return 0;
}
示例5: main
int main(int argc, char *argv[])
{
PIN_InitSymbols();
if( PIN_Init(argc,argv) )
{
return Usage();
}
TraceFile.open(KnobOutputFile.Value().c_str());
TraceFile << hex;
TraceFile.setf(ios::showbase);
cout << hex;
cout.setf(ios::showbase);
IMG_AddInstrumentFunction(Image, 0);
PIN_AddFiniFunction(Fini, 0);
// Never returns
PIN_StartProgram();
return 0;
}
示例6: main
int main(int argc, char *argv[])
{
int log_taint = 0;
for (int i = 3; i < argc; i++) {
if(!strcmp(argv[i], "--main-module")) {
set_main_module();
log_info("Whitelisted the main module\n");
}
else if(!strcmp(argv[i], "--range")) {
ADDRINT start = strtoul(argv[++i], NULL, 16);
ADDRINT end = strtoul(argv[++i], NULL, 16);
add_instrument_range(start, end);
log_info("Whitelisted range 0x%08x..0x%08x\n", start, end);
}
else if(!strcmp(argv[i], "--ins")) {
log_info("Whitelisted mnemonic(s): %s\n", argv[++i]);
add_instrument_instruction(argv[i]);
}
else if(!strcmp(argv[i], "--inside")) {
ADDRINT start = strtoul(argv[++i], NULL, 16);
ADDRINT end = strtoul(argv[++i], NULL, 16);
add_instrument_inside(start, end);
log_info("Whitelisted inside sequence 0x%08x..0x%08x\n",
start, end);
}
else if(!strcmp(argv[i], "--module")) {
add_instrument_module(argv[++i]);
log_info("Whitelisted modules containing: %s\n", argv[i]);
}
}
PIN_Init(argc, argv);
PIN_InitSymbols();
registers_init();
taint_init(log_taint);
taint_source_enable("getc");
taint_source_enable("scanf");
IMG_AddInstrumentFunction(&module_range_handler, NULL);
IMG_AddInstrumentFunction(&taint_sources_handler, NULL);
INS_AddInstrumentFunction(&insns, NULL);
PIN_StartProgram();
return 0;
}
示例7: main
int main(int argc, char * argv[])
{
// Initialize symbol processing
PIN_InitSymbols();
// Initialize pin
if (PIN_Init(argc, argv)) return Usage();
logging = ! KnobReplay.Value();
if (logging)
{
trace = fopen("record_imageload_rec.out", "w");
imgLog = fopen("imageload.log", "w");
IMG_AddInstrumentFunction(LogImageLoad, 0);
IMG_AddUnloadFunction (LogImageUnload, 0);
}
else
{ // Replaying
trace = fopen("record_imageload_play.out", "w");
imgLog = fopen("imageload.log", "r");
// We will handle image load operations.
PIN_SetReplayMode (REPLAY_MODE_IMAGEOPS);
// And then we replay the first two image load ops before we start the program.
// We do this even before adding the image instrumentation callback, that should still work,
// Pin should defer these and replay them inside PIN_StartProgram.
ReplayImageEntry();
ReplayImageEntry();
INS_AddInstrumentFunction (InstrumentInstruction, 0);
}
// These Trace functions demonstrate that the events are happening, they are the client...
IMG_AddInstrumentFunction(TraceImageLoad, 0);
IMG_AddUnloadFunction (TraceImageUnload, 0);
// Register Fini to be called when the application exits
PIN_AddFiniFunction(Fini, 0);
// Start the program, never returns
PIN_StartProgram();
return 0;
}
示例8: main
int main( int argc, char **argv ){
PIN_InitSymbols();
if( PIN_Init(argc,argv) ) {
return Usage();
}
//out_file.open(KnobOutputFile.Value().c_str(), fstream::out);
stringstream ss(KnobThreadCount.Value());
ss >> total_threads;
char *out_file_name = new char[BUF_SIZE];
out_file = new fstream*[total_threads];
for (INT32 i = 0; i < total_threads; i++) {
sprintf(out_file_name, "%s.%d", KnobOutputFile.Value().c_str(), i);
//cout<< out_file_name << endl;
out_file[i] = new fstream(out_file_name, fstream::out);
}
stringstream ss_count(KnobSampleRate.Value());
ss_count >> sample_counter;
cout << "::PINTOOL:: sample per " << sample_counter << " inst" << endl;
string stdinFile = KnobStdinFile.Value();
if(stdinFile.size() > 0) {
assert(freopen(stdinFile.c_str(), "rt", stdin));
}
string isSeqProgram = KnobSeqProgram.Value();
if(isSeqProgram.size() > 0) {
SeqProgram = true;
}
CacheUtil::getInstance().initialize();
CacheCore::getInstance().initialize(total_threads);
if(!SeqProgram) {
PIN_AddThreadStartFunction(ThreadBegin,0);
PIN_AddThreadFiniFunction(ThreadEnd,0);
}
/* initialize random seed: */
srand (time(NULL));
IMG_AddInstrumentFunction(Image, 0);
PIN_AddFiniFunction(Fini, 0);
PIN_StartProgram();
}
示例9: main
int main(int argc, char **argv)
{
PIN_InitSymbols();
if ( PIN_Init(argc, argv) )
return -1;
IMG_AddInstrumentFunction(process_loaded_image, 0);
PIN_StartProbedProgram();
}
示例10: main
int main(int argc, char * argv[])
{
PIN_Init(argc, argv);
PIN_InitSymbols();
IMG_AddInstrumentFunction(InstrumentImage, 0);
PIN_AddFiniFunction(AtApplicationEnd, 0);
PIN_StartProgram();
return 0;
}
示例11: main
int main(int argc, char * argv[])
{
PIN_Init(argc, argv);
PIN_InitSymbols();
IMG_AddInstrumentFunction(OnImage, 0);
PIN_StartProgram();
return 0;
}
示例12: main
int main(int argc, char** argv)
{
PIN_InitSymbols();
if(PIN_Init(argc,argv))
{
return Usage();
}
// Set up the events
initialize_events();
if(!KnobDisableLibraryTracing.Value())
{
printf("Enabling library tracing.\n");
/* Enable library tracing. */
IMG_AddInstrumentFunction(library_loaded_function, 0);
IMG_AddUnloadFunction(library_unloaded_function, 0);
}
if(KnobEnableInitialMonitoring.Value())
{
printf("Enabling tracing on initialization.\n");
event_monitoring_set(true);
}
if(KnobEnableMonitoring.Value())
{
long start = KnobRegionStart.Value();
long end = KnobRegionEnd.Value();
const char* library_name = KnobRegionName.Value().c_str();
printf("Library name: %s\n", library_name);
printf("0x%lx 0x%lx\n", start, end);
region_t *r = (region_t*)malloc(sizeof(region_t));
r->start = (void*)start;
r->end = (void*)end;
strncpy(r->library_name, library_name, 260);
printf("Added %s\n", r->library_name);
add_region_to_monitoring(r);
event_snapshot_set(true);
region_monitoring_enabled = true;
}
// Add instrumentation. It handles both regions and instruction monitoring so must be enabled
INS_AddInstrumentFunction(instruction_trace, 0);
// Start up the program to investigate.
PIN_StartProgram();
return 0;
}
示例13: main
//! The pintool's entry point
int main(int argc, char *argv[]) {
PIN_InitSymbols();
PIN_SetSyntaxIntel();
if(PIN_Init(argc, argv))
return Usage();
/* Init the Triton module */
triton::bindings::python::inittriton();
/* Define Triton architecure */
if (sizeof(void*) == QWORD_SIZE)
tracer::pintool::api.setArchitecture(triton::arch::ARCH_X86_64);
else
tracer::pintool::api.setArchitecture(triton::arch::ARCH_X86);
/* During the execution provide concrete values only if Triton needs them - cf #376, #632 and #645 */
tracer::pintool::api.addCallback(tracer::pintool::context::needConcreteRegisterValue);
tracer::pintool::api.addCallback(tracer::pintool::context::needConcreteMemoryValue);
/* Image callback */
IMG_AddInstrumentFunction(IMG_Instrumentation, nullptr);
/* Instruction callback */
TRACE_AddInstrumentFunction(TRACE_Instrumentation, nullptr);
/* End instrumentation callback */
PIN_AddFiniFunction(callbackFini, nullptr);
/* Syscall entry callback */
PIN_AddSyscallEntryFunction(callbackSyscallEntry, nullptr);
/* Syscall exit callback */
PIN_AddSyscallExitFunction(callbackSyscallExit, nullptr);
/* Signals callback */
PIN_InterceptSignal(SIGHUP, callbackSignals, nullptr);
PIN_InterceptSignal(SIGINT, callbackSignals, nullptr);
PIN_InterceptSignal(SIGQUIT, callbackSignals, nullptr);
PIN_InterceptSignal(SIGILL, callbackSignals, nullptr);
PIN_InterceptSignal(SIGABRT, callbackSignals, nullptr);
PIN_InterceptSignal(SIGFPE, callbackSignals, nullptr);
PIN_InterceptSignal(SIGKILL, callbackSignals, nullptr);
PIN_InterceptSignal(SIGSEGV, callbackSignals, nullptr);
PIN_InterceptSignal(SIGPIPE, callbackSignals, nullptr);
PIN_InterceptSignal(SIGALRM, callbackSignals, nullptr);
PIN_InterceptSignal(SIGTERM, callbackSignals, nullptr);
PIN_InterceptSignal(SIGBUS, callbackSignals, nullptr);
/* Exec the Pin's python bindings */
tracer::pintool::initBindings(argc, argv);
tracer::pintool::execScript(KnobPythonModule.Value().c_str());
return 0;
}
示例14: main
int main(INT32 argc, CHAR **argv)
{
PIN_Init(argc, argv);
PIN_InitSymbols();
INS_AddInstrumentFunction(Instruction, 0);
IMG_AddInstrumentFunction(ImageLoad, 0);
PIN_StartProgram();
return 0;
}
示例15: main
int main(int argc, char *argv[])
{
if( PIN_Init(argc,argv) )
return Usage();
// Next call is needed, otherwise we can't find routines by name
PIN_InitSymbols();
outFile = KnobOutputFile.Value().empty() ? &cout : new std::ofstream(KnobOutputFile.Value().c_str());
IMG_AddInstrumentFunction(ImageLoad, 0);
PIN_StartProgram(); // Never returns
return 0;
}