INTRODUCTION

One can think of sreplay as a virtual application.  It is a
freestanding program that has just enough logic to get itself running
and then parse and replay a trace of system calls.

A freestanding program is one that does not rely on code provided by
the compiler runtime library or the system C library.  Operating
system kernels, hypervisors and bootloaders are freestanding for
obvious reasons, but sreplay is so because the code provided by libc
makes system calls before handing control to main.  Because our goal
is to make sreplay execute only those system calls provided in a
trace, it must be freestanding.  For similar reasons, the trace is
accepted as a literal command line argument, because opening a file
would involve one or more system calls.  The alternative is to embed
the trace as a seperate ELF section in the sreplay binary, similar to
Linux's zImage format, but we have chosen to pursue the simplicity of
the argv approach for now.

To summarize, the following two invocations are equivalent from a
system call perspective:

 $ true; true
 $ sreplay $(strace true 2>&1)

PORTING

To port sreplay to a new architecture, you must supply a start.S that
provides the logic to set up an initial stack frame and other things
necessary to branch to main.  You must also supply a stub.h which
provides a macro that expands to the assembly necessary to make a
system call.

CROSS-COMPILING

The build machinery has an inferface similar to Linux's.  So to
cross-compile for ppc64:

 make ARCH=ppc64 CROSS_COMPILE=powerpc64-linux-

NOTES

A more accurate application replay would execute the trace of
instructions gathered by single-stepping the original application.
Our approach is close enough for most purposes, but it definitely
exhibits different behavior -- it is not cpu-bound at all, and it's
page fault pattern is vastly different from any real application.

The file descriptor returned by open is different depending on whether
we are running under a debugger or not.

LIBC

libc/sysdeps/unix/sysv/linux/i386/syscall.S
libc/sysdeps/unix/sysv/linux/i386/sysdep.h
libc/sysdeps/unix/sysv/linux/i386/mmap.S
libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
libc/sysdeps/powerpc/powerpc64/sysdep.h
libc/sysdeps/powerpc/powerpc64/elf/start.S

LINUX

arch/i386/kernel/sys_i386.c

RELATED WORK

[1] Gamut (Generic Application eMUlaTor) is an application for selectively
    utilizing parts of a single machine or networked servers.

     http://www.cs.duke.edu/%7Ejustin/cod/README.gamut-0.7.0
