1 / 11

PIN AOTI Extension CGO’04 Tutorial 3/21/04 Vijay Janapa Reddi, University of Colorado

PIN AOTI Extension CGO’04 Tutorial 3/21/04 Vijay Janapa Reddi, University of Colorado. What is AOTI?. A head O f T ime I nstrumentation ATOM model Not execution driven instrumentation Does not affect current PIN environment. Dynamic vs. Static Instrumentation. Dynamic Run time

aelwen
Download Presentation

PIN AOTI Extension CGO’04 Tutorial 3/21/04 Vijay Janapa Reddi, University of Colorado

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PINAOTI ExtensionCGO’04 Tutorial3/21/04Vijay Janapa Reddi, University of Colorado

  2. What is AOTI? • Ahead Of Time Instrumentation • ATOM model • Not execution driven instrumentation • Does not affect current PIN environment

  3. Dynamic vs. Static Instrumentation • Dynamic • Run time • Instrument every instruction • Account only instructions that are executed • Static • Load time • Instrument every instruction • Account every instructionexecuted/unexecuted

  4. Dynamic Static 1’ 1 1 1’ 2 2 3’ 3 3 2’ 4’ 4 5’ 5 4 5 2’ 6’ 6 6 7’ Code Cache 7’ 7 7 Code Cache Dynamic vs. Static Instrumentation

  5. Dynamic counts VOID Fini(int n, VOID *v) { cout << dec << "(AOTI) brCount: " << brAOTI << endl; cout << dec << "(NORM) brCount: " << brNORM << endl; } VOID inc_brAOTI() { brAOTI++; } VOID inc_brNORM() { brNORM++; } VOID static(PIN_IMAGE *image, PROC head, VOID *v) { for (PROC proc = head; proc != PROC_Invalid(); proc = PROC_Next(proc)) for (INS ins = PROC_FirstIns(proc); ins != INS_INVALID(); ins = INS_Next(ins)) if (INS_Category(ins) == TYPE_CAT_BRANCH) PIN_InsertCall(IPOINT_BEFORE, ins, (AFUNPTR)inc_brAOTI, IARG_END); } VOID dynamic(INS ins, VOID *v) { if (INS_Category(ins) == TYPE_CAT_BRANCH) PIN_InsertCall(IPOINT_BEFORE, ins, (AFUNPTR)inc_brNORM, IARG_END); } int main(int argc, char *argv[]) { PIN_AddInstrumentImageFunction(static, 0); PIN_AddInstrumentInstructionFunction(dynamic, 0); PIN_AddFiniFunction(Fini, 0); PIN_StartProgram(); } (Static) brCount : 101969 (Dynamic) brCount : 101969

  6. Static counts VOID Fini(int n, VOID *v) { cout << dec << "(AOTI) brCount: " << brAOTI << endl; cout << dec << "(NORM) brCount: " << brNORM << endl; } VOID static(PIN_IMAGE *image, PROC head, VOID *v) { for (PROC proc = head; proc != PROC_Invalid(); proc = PROC_Next(proc)) for (INS ins = PROC_FirstIns(proc); ins != INS_INVALID(); ins = INS_Next(ins)) if (INS_Category(ins) == TYPE_CAT_BRANCH) brAOTI++; } VOID dynamic(INS ins, VOID *v) { if (INS_Category(ins) == TYPE_CAT_BRANCH) brNORM++; } int main(int argc, char *argv[]) { PIN_AddInstrumentImageFunction(static, 0); PIN_AddInstrumentInstructionFunction(dynamic, 0); PIN_AddFiniFunction(Fini, 0); PIN_StartProgram(); } (Static) brCount : 36279 (Dynamic) brCount : 1308

  7. AOTI API • PIN_AddInstrumentImageFunction(VOID (*fun)(PIN_IMAGE *, PROC head, VOID *), VOID *val) • Name of AOTI instrumentation function • PROC_First(VOID) • The first procedure in the current image • PROC_Next(PROC curr_sym) • The next procedure following the current procedure • PROC_Name(PROC curr_sym) • The current procedure name • PROC_FirstIns(PROC sym) • The first instruction in the current procedure symbol • PROC_Invalid() • Check to see if we have reached the end of the current procedure

  8. PROC Address Range MakeInsRange AOTI Backend design Extract Elf Info. Extract Symbol .o/.so/.a Load Next Image AddInstrumentImageFunction’s

  9. Advantages • Ability to see every instruction in images • Example: • Profiling • AOTI facilitates easy profiling at procedure/instruction level • Code coverage analysis • Function • Call

  10. Disadvantages • No basic blocks • Longer execution runtime • More demand on memory

  11. Future of PIN • XPin • A visual program analysis tool supporting PIN

More Related