0

I am running a Python gdb script on a program that runs with a Pintool. Specifically, I used the -appdebug_enable switch and created a semantic breakpoint in the Pintool that automatically triggers the breakpoint and runs the Python script that I sourced. The script basically inspects local and global variables and scans the memory that was dynamically allocated by the program. I notice that the gdb script runs orders of magnitude slower than if I run the program and gdb without the Pintool. I also tried with a dummy Pintool to see if my Pintool implementation caused the slowdown but it did not seem to be the case.

My conclusion is that Pin slows down my gdb script, but can anyone explain how and why? Is there any tool I can use to profile the performance slowdown from Pin?

(I understand that gdb performance is not something people usually care too much about, but I am curious about the source of the slowdown.)

vanbastelaer
  • 368
  • 2
  • 15

1 Answers1

0

In your case PIN is used as a JIT (just in time) compiler. So it is effectively stopping your program whenever instruction sequence change, and recompile (main reason for delay) and also add some instructions of its own (additional delays). PIN takes your program executable as argument. From first instruction to next branch instruction (call,jmp,ret) it regenerate sequence of instruction with its additional set of instructions that will transfer control back to PIN framework after executing the generated instruction sequence. While regenerating code PIN allows a user using instrumentation code to inject additional analysis code.

ajit
  • 410
  • 3
  • 9
  • I am not sure what Pin's JIT has to do with GDB? The program under Pin is paused and I am running gdb to inspect its memory; no instrumentation nor analysis code was called during this time. – vanbastelaer Aug 12 '20 at 14:50
  • Is your python gdb script invoking commands like "gdb.execute", "gdb.write" or similar? In other words is it the case that script is running instructions of your program "in the script" while analyzing local and global variables? If it is then it is running *instrumented code and additional code* of the PIN JIT framework. – ajit Aug 13 '20 at 05:56
  • My gdb script is not running instructions in my program. It is purely inspecting e.g., the heap memory (such as dereferencing pointers). I also don't think it is the instrumentation that caused the slowdown because, like I said, when I run a dummy Pintool that does no instrumentation, it is still much slower than without using Pin at all. – vanbastelaer Aug 13 '20 at 13:26