-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditionedprint.cpp
63 lines (49 loc) · 1.44 KB
/
conditionedprint.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <fstream>
#include <iostream>
#include "pin.H"
ofstream OutFile;
FILE * trace;
//static uint64_t counter = 0;
void docount(uint64_t addr, std::string disassins)
{
std::cout<<std::hex<<addr<<":"<<disassins<<"\n";
}
void Instruction(INS ins, VOID *v)
{
if ((INS_Address(ins) >= 4195510) && (INS_Address(ins) < 4195633))
{
std::cout<<std::hex<<INS_Address(ins)<<" : " << INS_Disassemble(ins).c_str()<<"\n";
}
// Insert a call to docount before every instruction, no arguments are passed
//INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)docount, IARG_ADDRINT,
//INS_Address(ins), IARG_PTR, new string(INS_Disassemble(ins)), IARG_END);
}
KNOB<string> KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool", "o", "mytool.out", "specify output file name");
/*
VOID Fini(INT32 code, VOID *v)
{
// Write to a file since cout and cerr maybe closed by the application
OutFile.setf(ios::showbase);
OutFile << "Count " << count << endl;
OutFile.close();
}
*/
int32_t Usage()
{
cerr << "This is my custom tool" << endl;
cerr << endl << KNOB_BASE::StringKnobSummary() << endl;
return -1;
}
int main(int argc, char * argv[])
{
PIN_InitSymbols();
if (PIN_Init(argc, argv)) return Usage();
OutFile.open(KnobOutputFile.Value().c_str());
PIN_SetSyntaxIntel();
//IMG_AddInstrumentFunction(Image, 0);
INS_AddInstrumentFunction(Instruction, 0);
//PIN_AddFiniFunction(Fini, 0);
// Start the program here
PIN_StartProgram();
return 0;
}