/* * Atom instrumentation program * special features: * - change the character string "tested" to be the * name of the procedure you want instrumented -- * only instructions executing within that procedure will * be instrumented * - only data loads & stores are instrumented; not instruction fetches */ #include #include void InstrumentInit(int p1, char **p2) { AddCallProto("OpenFile()"); AddCallProto("DataLoad(VALUE)"); AddCallProto("DataStore(VALUE)"); AddCallProto("CloseFile()"); AddCallProgram(ProgramBefore,"OpenFile"); AddCallProgram(ProgramAfter,"CloseFile"); } Instrument(int argc, char **argv, Obj *obj) { Proc *p; Block *b; Inst *i; for (p = GetFirstObjProc(obj); p != NULL; p = GetNextProc(p)) { { for (b = GetFirstBlock(p); b != NULL; b = GetNextBlock(b)) { for (i = GetFirstInst(b); i != NULL; i = GetNextInst(i)) { if (IsInstType(i,InstTypeLoad)) AddCallInst(i,InstBefore,"DataLoad",EffAddrValue); if (IsInstType(i,InstTypeStore)) AddCallInst(i,InstBefore,"DataStore",EffAddrValue); } } } } }