Index: qemu/Makefile.target =================================================================== --- qemu.orig/Makefile.target 2007-07-06 09:46:45.000000000 -0400 +++ qemu/Makefile.target 2007-07-06 09:50:23.000000000 -0400 @@ -240,7 +240,7 @@ endif ifdef CONFIG_LINUX_USER -OBJS= main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o \ +OBJS= main.o syscall.o syscall_names.o mmap.o signal.o path.o osdep.o thunk.o \ elfload.o linuxload.o LIBS+= $(AIOLIBS) ifdef TARGET_HAS_BFLT Index: qemu/linux-user/syscall.c =================================================================== --- qemu.orig/linux-user/syscall.c 2007-07-06 09:50:06.000000000 -0400 +++ qemu/linux-user/syscall.c 2007-07-06 10:01:54.000000000 -0400 @@ -312,6 +312,11 @@ return (unsigned long)ret >= (unsigned long)(-4096); } +char *target_strerror(int err) +{ + return strerror(host_to_target_errno(err)); +} + static target_ulong target_brk; static target_ulong target_original_brk; @@ -2606,6 +2611,9 @@ #ifdef DEBUG gemu_log("syscall %d", num); #endif + if(do_strace) + print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); + switch(num) { case TARGET_NR_exit: #ifdef HAVE_GPROF @@ -4790,6 +4798,8 @@ #ifdef DEBUG gemu_log(" = %ld\n", ret); #endif + if(do_strace) + print_syscall_ret(num, ret); return ret; } Index: qemu/linux-user/syscall_names.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ qemu/linux-user/syscall_names.c 2007-07-06 10:02:27.000000000 -0400 @@ -0,0 +1,93 @@ +#include +#include +#include "qemu.h" + +int do_strace=0; + +struct syscallname { + int nr; + char *name; + char *format; + void (*call)(struct syscallname *,long, long, long, long, long, long); + void (*result)(struct syscallname *,long); +}; + +void +print_newselect(struct syscallname *name, long arg1, long arg2, long arg3, + long arg4, long arg5, long arg6) +{ +long rfds=0,wfds=0,efds=0; + +if( arg2 ) + rfds = *(long *)arg2; +if( arg3 ) + wfds = *(long *)arg3; +if( arg4 ) + efds = *(long *)arg4; + +gemu_log("%s(%d,[%lX],[%lX],[%lX],%p)",name->name, arg1,rfds,wfds,efds,arg5); +} + +void +print_syscall_ret_addr(struct syscallname *name, long ret) +{ +if( ret == -1 ) { + gemu_log(" = -1 errno=%d (%s)\n", errno, target_strerror(errno)); + } else { + gemu_log(" = %x\n", ret); + } +} + +void +print_syscall_ret_raw(struct syscallname *name, long ret) +{ + gemu_log(" = %x\n", ret); +} + +static struct syscallname scnames[] = { +#include "syscall_names.list" +}; + +static int nsyscalls = sizeof(scnames)/sizeof(struct syscallname); + +void +print_syscall(int num, long arg1, long arg2, long arg3, + long arg4, long arg5, long arg6) +{ +int i; +char *format="%s(%ld,%ld,%ld,%ld,%ld,%ld)"; + +for(i=0;i