cs8803SC_lecture19

cs8803SC_lecture19 - CS8803SC Software and Hardware...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS8803SC Software and Hardware Cooperative Computing Pin Advance/Sim Points/Pin Points Prof. Hyesoon Kim School of Computer Science Georgia Institute of Technology Lab #3 (due 4/15) • Building a tool for project • Part 1) Modifying programs to estimate error bounds • Part 2) Collect memory address traces to calculate coherent memory addresses + Sim Points • Today: Advanced Pin (Most slides are from ISCA’06 tutorial) • Lab 3 will be posted by the end of this week.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Modifying Program Behavior • Pin allows you not only observing but also changing program behavior • Ways to change program behavior: – Add/delete instructions – Change register values – Change memory values – Change control flow Example: Emulation of Loads sub $0x11c,%esp mov 0xc(%ebp),%eax add $0x128, %eax mov 0x8(%ebp),%edi xor %eax, %edi
Background image of page 2
3 Example: Emulation of Loads sub $0x11c,%esp mov 0xc(%ebp),%eax add $0x128, %eax mov 0x8(%ebp),%edi xor %eax, %edi EmulateLoad(%ebp+0xc, %eax) EmulateLoad(%ebp+0x8, %edi) Emulation of Loads $ pin -t emuload -- /bin/ls Emulate loading from addr 0xbfffe188 Emulate loading from addr 0x40016ae0 Emulate loading from addr 0x40016c74 Emulate loading from addr 0x40016c7c Emulate loading from addr 0x40016c84 _insprofiler.C imageload imageload.out insprofiler.C proccount.C atrace.C
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 When Do You Use? • Change the semantics of Instruction • Could emulate new instructions • Compiler can insert some hint instructions and then emulate the architectural behavior at run-time SimpleExamples/emuload.C #include <stdio.h> #include "pin.H" #include "pin_isa.H" #include <iostream> // Move from memory to register ADDRINT DoLoad(ADDRINT * addr) { cout << "Emulate loading from addr " << addr << endl; return *addr; } VOID EmulateLoad(INS ins, VOID* v) { if (INS_Opcode(ins) == XEDICLASS_MOV && INS_IsMemoryRead(ins) && // op0 <- *op1 INS_InsertCall(ins, IPOINT_BEFORE, AFUNPTR(DoLoad), IARG_MEMORYREAD_EA, IARG_RETURN_REGS, INS_OperandReg(ins, 0), IARG_END); INS_Delete(ins); } } int main(int argc, char * argv[]) { PIN_Init(argc, argv); INS_AddInstrumentFunction(EmulateLoad, 0); PIN_StartProgram(); return 0; } check if ins is a load pass the load data address to DoLoad() use DoLoad()’s return value to modify the register which is the first operand of ins remove ins (the original load)
Background image of page 4
5 HOW TO DEBUG PIN Debugging Pintools 1. Invoke gdb with your pintool (but don’t use “run”) 2. On another window, start your pintool with “-pause_tool” 3. Go back to gdb: a) Attach to the process b) Use “cont” to continue execution; can set breakpoints as usual (gdb) attach 32017 (gdb) break main (gdb) cont $ pin –pause_tool 5 –t inscount0 -- /bin/ls Pausing to attach to pid 32017 $ gdb inscount0 (gdb)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 • Architecture Simulation • We cannot simulate the entire program Select Simulation Points Select One Point At the beginning (no skip) After 1 billion instructions After skipping a random number of instructions
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 27

cs8803SC_lecture19 - CS8803SC Software and Hardware...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online