A replay tool aiming to reproduce a program's execution interposes itself at an appropriate replay interface between the program and the environment. During recording, it logs all non-deterministic side effects passing through the interface from the environment and feeds them back during replay. The replay interface is critical for correctness and recording overhead of replay tools. iTarget is a novel replay tool that uses programming language techniques to automatically seek a replay interface that both ensures correctness and minimizes recording overhead. It performs static analysis to extract data flows, estimates their recording costs via dynamic profiling, computes an optimal replay interface that minimizes the recording overhead, and instruments the program accordingly for interposition. Experimental results show that iTarget can successfully replay complex C programs, including Apache web server and Berkeley DB, and that it can reduce the log size by up to two orders of ma...