linux-user: strace now handles guest strings correctly [v2]

- to not to break strace with GUEST_BASE is set:
- Strace now can load and print guest strings correctly.
- Added printing support for commonly used flags in some syscalls
  (e.g open, creat, mmap etc.)

v2:
- fix strace.c build on etch
- add futex print to strace

Signed-off-by: Mika Westerberg <mika.westerberg@iki.fi>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
This commit is contained in:
Mika Westerberg 2009-04-07 16:57:29 +03:00 committed by Riku Voipio
parent 9edc5d7966
commit 74d753ac86
4 changed files with 1118 additions and 77 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,13 @@
/*
* Note that if you change format strings in these, check also
* that corresponding print functions are able to handle string
* locking correctly (see strace.c).
*/
#ifdef TARGET_NR_accept
{ TARGET_NR_accept, "accept" , "%s(%d,%#x,%#x)", NULL, NULL },
{ TARGET_NR_accept, "accept" , NULL, print_accept, NULL },
#endif
#ifdef TARGET_NR_access
{ TARGET_NR_access, "access" , "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_NR_access, "access" , NULL, print_access, NULL },
#endif
#ifdef TARGET_NR_acct
{ TARGET_NR_acct, "acct" , NULL, NULL, NULL },
@ -38,7 +43,7 @@
{ TARGET_NR_break, "break" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_brk
{ TARGET_NR_brk, "brk" , NULL, NULL, print_syscall_ret_addr },
{ TARGET_NR_brk, "brk" , NULL, print_brk, print_syscall_ret_addr },
#endif
#ifdef TARGET_NR_cachectl
{ TARGET_NR_cachectl, "cachectl" , NULL, NULL, NULL },
@ -53,10 +58,10 @@
{ TARGET_NR_capset, "capset" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_chdir
{ TARGET_NR_chdir, "chdir" , "%s(\"%s\")", NULL, NULL },
{ TARGET_NR_chdir, "chdir" , NULL, print_chdir, NULL },
#endif
#ifdef TARGET_NR_chmod
{ TARGET_NR_chmod, "chmod" , "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL },
#endif
#ifdef TARGET_NR_chown
{ TARGET_NR_chown, "chown" , NULL, NULL, NULL },
@ -89,7 +94,7 @@
{ TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL },
#endif
#ifdef TARGET_NR_creat
{ TARGET_NR_creat, "creat" , "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_NR_creat, "creat" , NULL, print_creat, NULL },
#endif
#ifdef TARGET_NR_create_module
{ TARGET_NR_create_module, "create_module" , NULL, NULL, NULL },
@ -122,7 +127,7 @@
{ TARGET_NR_epoll_wait_old, "epoll_wait_old" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_execv
{ TARGET_NR_execv, "execv" , "%s(\"%s\",%ld,%ld,%ld,%ld,%ld)\n", NULL, NULL },
{ TARGET_NR_execv, "execv" , NULL, print_execv, NULL },
#endif
#ifdef TARGET_NR_execve
{ TARGET_NR_execve, "execve" , NULL, print_execve, NULL },
@ -140,7 +145,7 @@
{ TARGET_NR_exit_group, "exit_group" , "%s(%d)\n", NULL, NULL },
#endif
#ifdef TARGET_NR_faccessat
{ TARGET_NR_faccessat, "faccessat" , "%s(%d,\"%s\",%#o,%#x)", NULL, NULL },
{ TARGET_NR_faccessat, "faccessat" , NULL, print_faccessat, NULL },
#endif
#ifdef TARGET_NR_fadvise64
{ TARGET_NR_fadvise64, "fadvise64" , NULL, NULL, NULL },
@ -155,22 +160,22 @@
{ TARGET_NR_fchmod, "fchmod" , "%s(%d,%#o)", NULL, NULL },
#endif
#ifdef TARGET_NR_fchmodat
{ TARGET_NR_fchmodat, "fchmodat" , "%s(%d,\"%s\",%#o,%#x)", NULL, NULL },
{ TARGET_NR_fchmodat, "fchmodat" , NULL, print_fchmodat, NULL },
#endif
#ifdef TARGET_NR_fchown
{ TARGET_NR_fchown, "fchown" , "%s(\"%s\",%d,%d)", NULL, NULL },
{ TARGET_NR_fchown, "fchown" , "%s(%d,%d,%d)", NULL, NULL },
#endif
#ifdef TARGET_NR_fchown32
{ TARGET_NR_fchown32, "fchown32" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_fchownat
{ TARGET_NR_fchownat, "fchownat" , "%s(%d,\"%s\",%d,%d,%#x)", NULL, NULL },
{ TARGET_NR_fchownat, "fchownat" , NULL, print_fchownat, NULL },
#endif
#ifdef TARGET_NR_fcntl
{ TARGET_NR_fcntl, "fcntl" , NULL, NULL, NULL },
{ TARGET_NR_fcntl, "fcntl" , NULL, print_fcntl, NULL },
#endif
#ifdef TARGET_NR_fcntl64
{ TARGET_NR_fcntl64, "fcntl64" , NULL, NULL, NULL },
{ TARGET_NR_fcntl64, "fcntl64" , NULL, print_fcntl64, NULL },
#endif
#ifdef TARGET_NR_fdatasync
{ TARGET_NR_fdatasync, "fdatasync" , NULL, NULL, NULL },
@ -194,10 +199,10 @@
{ TARGET_NR_fsetxattr, "fsetxattr" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_fstat
{ TARGET_NR_fstat, "fstat" , "%s(%d,%p)", NULL, NULL },
{ TARGET_NR_fstat, "fstat" , NULL, print_fstat, NULL },
#endif
#ifdef TARGET_NR_fstat64
{ TARGET_NR_fstat64, "fstat64" , "%s(%d,%p)", NULL, NULL },
{ TARGET_NR_fstat64, "fstat64" , NULL, print_fstat64, NULL },
#endif
#ifdef TARGET_NR_fstatfs
{ TARGET_NR_fstatfs, "fstatfs" , "%s(%d,%p)", NULL, NULL },
@ -218,10 +223,10 @@
{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_futex
{ TARGET_NR_futex, "futex" , NULL, NULL, NULL },
{ TARGET_NR_futex, "futex" , NULL, print_futex, NULL },
#endif
#ifdef TARGET_NR_futimesat
{ TARGET_NR_futimesat, "futimesat" , "%s(%d,\"%s\",%p)", NULL, NULL },
{ TARGET_NR_futimesat, "futimesat" , NULL, print_futimesat, NULL },
#endif
#ifdef TARGET_NR_getcwd
{ TARGET_NR_getcwd, "getcwd" , "%s(%p,%d)", NULL, NULL },
@ -425,10 +430,10 @@
{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_link
{ TARGET_NR_link, "link" , "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_NR_link, "link" , NULL, print_link, NULL },
#endif
#ifdef TARGET_NR_linkat
{ TARGET_NR_linkat, "linkat" , "%s(%d,\"%s\",%d,\"%s\",%#x)", NULL, NULL },
{ TARGET_NR_linkat, "linkat" , NULL, print_linkat, NULL },
#endif
#ifdef TARGET_NR_Linux
{ TARGET_NR_Linux, "Linux" , NULL, NULL, NULL },
@ -461,10 +466,10 @@
{ TARGET_NR_lsetxattr, "lsetxattr" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_lstat
{ TARGET_NR_lstat, "lstat" , "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_NR_lstat, "lstat" , NULL, print_lstat, NULL },
#endif
#ifdef TARGET_NR_lstat64
{ TARGET_NR_lstat64, "lstat64" , "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_NR_lstat64, "lstat64" , NULL, print_lstat64, NULL },
#endif
#ifdef TARGET_NR_madvise
{ TARGET_NR_madvise, "madvise" , NULL, NULL, NULL },
@ -485,16 +490,16 @@
{ TARGET_NR_mincore, "mincore" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_mkdir
{ TARGET_NR_mkdir, "mkdir" , "%s(\"%s\",%#o)", NULL, NULL },
{ TARGET_NR_mkdir, "mkdir" , NULL, print_mkdir, NULL },
#endif
#ifdef TARGET_NR_mkdirat
{ TARGET_NR_mkdirat, "mkdirat" , "%s(%d,\"%s\",%#o)", NULL, NULL },
{ TARGET_NR_mkdirat, "mkdirat" , NULL, print_mkdirat, NULL },
#endif
#ifdef TARGET_NR_mknod
{ TARGET_NR_mknod, "mknod" , "%s(\"%s\",%#o,%#x)", NULL, NULL },
{ TARGET_NR_mknod, "mknod" , NULL, print_mknod, NULL },
#endif
#ifdef TARGET_NR_mknodat
{ TARGET_NR_mknodat, "mknodat" , "%s(%d,\"%s\",%#o,%#x)", NULL, NULL },
{ TARGET_NR_mknodat, "mknodat" , NULL, print_mknodat, NULL },
#endif
#ifdef TARGET_NR_mlock
{ TARGET_NR_mlock, "mlock" , NULL, NULL, NULL },
@ -503,22 +508,22 @@
{ TARGET_NR_mlockall, "mlockall" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_mmap
{ TARGET_NR_mmap, "mmap" , NULL, NULL, print_syscall_ret_addr },
{ TARGET_NR_mmap, "mmap" , NULL, print_mmap, print_syscall_ret_addr },
#endif
#ifdef TARGET_NR_mmap2
{ TARGET_NR_mmap2, "mmap2" , NULL, NULL, print_syscall_ret_addr },
{ TARGET_NR_mmap2, "mmap2" , NULL, print_mmap2, print_syscall_ret_addr },
#endif
#ifdef TARGET_NR_modify_ldt
{ TARGET_NR_modify_ldt, "modify_ldt" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_mount
{ TARGET_NR_mount, "mount" , NULL, NULL, NULL },
{ TARGET_NR_mount, "mount" , NULL, print_mount, NULL },
#endif
#ifdef TARGET_NR_move_pages
{ TARGET_NR_move_pages, "move_pages" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_mprotect
{ TARGET_NR_mprotect, "mprotect" , NULL, NULL, NULL },
{ TARGET_NR_mprotect, "mprotect" , NULL, print_mprotect, NULL },
#endif
#ifdef TARGET_NR_mpx
{ TARGET_NR_mpx, "mpx" , NULL, NULL, NULL },
@ -530,7 +535,7 @@
{ TARGET_NR_mq_notify, "mq_notify" , "%s(%d,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_open
{ TARGET_NR_mq_open, "mq_open" , "%s(\"/%s\",%#x,%#o,%p)", NULL, NULL },
{ TARGET_NR_mq_open, "mq_open" , NULL, print_mq_open, NULL },
#endif
#ifdef TARGET_NR_mq_timedreceive
{ TARGET_NR_mq_timedreceive, "mq_timedreceive" , "%s(%d,%p,%d,%u,%p)", NULL, NULL },
@ -539,7 +544,7 @@
{ TARGET_NR_mq_timedsend, "mq_timedsend" , "%s(%d,%p,%d,%u,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_unlink
{ TARGET_NR_mq_unlink, "mq_unlink" , "%s(%s)", NULL, NULL },
{ TARGET_NR_mq_unlink, "mq_unlink" , NULL, print_mq_unlink, NULL },
#endif
#ifdef TARGET_NR_mremap
{ TARGET_NR_mremap, "mremap" , NULL, NULL, NULL },
@ -569,16 +574,16 @@
{ TARGET_NR_munlockall, "munlockall" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_munmap
{ TARGET_NR_munmap, "munmap" , "%s(%p,%d)", NULL, NULL },
{ TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL },
#endif
#ifdef TARGET_NR_nanosleep
{ TARGET_NR_nanosleep, "nanosleep" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_fstatat64
{ TARGET_NR_fstatat64, "fstatat64" , "%s(%d,\"%s\",%p,%#x)", NULL, NULL },
{ TARGET_NR_fstatat64, "fstatat64" , NULL, print_fstatat64, NULL },
#endif
#ifdef TARGET_NR_newfstatat
{ TARGET_NR_newfstatat, "newfstatat" , "%s(%d,\"%s\",%p,%#x)", NULL, NULL },
{ TARGET_NR_newfstatat, "newfstatat" , NULL, print_newfstatat, NULL },
#endif
#ifdef TARGET_NR__newselect
{ TARGET_NR__newselect, "_newselect" , NULL, print_newselect, print_syscall_ret_newselect },
@ -611,10 +616,10 @@
{ TARGET_NR_olduname, "olduname" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_open
{ TARGET_NR_open, "open" , "%s(\"%s\",%#x,%#o)", NULL, NULL },
{ TARGET_NR_open, "open" , NULL, print_open, NULL },
#endif
#ifdef TARGET_NR_openat
{ TARGET_NR_openat, "openat" , "%s(%d,\"%s\",%#x,%#o)", NULL, NULL },
{ TARGET_NR_openat, "openat" , NULL, print_openat, NULL },
#endif
#ifdef TARGET_NR_osf_adjtime
{ TARGET_NR_osf_adjtime, "osf_adjtime" , NULL, NULL, NULL },
@ -1007,10 +1012,10 @@
{ TARGET_NR_readdir, "readdir" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_readlink
{ TARGET_NR_readlink, "readlink" , "%s(\"%s\",%p,%d)", NULL, NULL },
{ TARGET_NR_readlink, "readlink" , NULL, print_readlink, NULL },
#endif
#ifdef TARGET_NR_readlinkat
{ TARGET_NR_readlinkat, "readlinkat" , "%s(%d,\"%s\",%p,%d)", NULL, NULL },
{ TARGET_NR_readlinkat, "readlinkat" , NULL, print_readlinkat, NULL },
#endif
#ifdef TARGET_NR_readv
{ TARGET_NR_readv, "readv" , NULL, NULL, NULL },
@ -1034,10 +1039,10 @@
{ TARGET_NR_removexattr, "removexattr" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_rename
{ TARGET_NR_rename, "rename" , "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_NR_rename, "rename" , NULL, print_rename, NULL },
#endif
#ifdef TARGET_NR_renameat
{ TARGET_NR_renameat, "renameat" , "%s(%d,\"%s\",%d,\"%s\")", NULL, NULL },
{ TARGET_NR_renameat, "renameat" , NULL, print_renameat, NULL },
#endif
#ifdef TARGET_NR_request_key
{ TARGET_NR_request_key, "request_key" , NULL, NULL, NULL },
@ -1301,16 +1306,16 @@
{ TARGET_NR_ssetmask, "ssetmask" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_stat
{ TARGET_NR_stat, "stat" , "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_NR_stat, "stat" , NULL, print_stat, NULL },
#endif
#ifdef TARGET_NR_stat64
{ TARGET_NR_stat64, "stat64" , "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_NR_stat64, "stat64" , NULL, print_stat64, NULL },
#endif
#ifdef TARGET_NR_statfs
{ TARGET_NR_statfs, "statfs" , "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_NR_statfs, "statfs" , NULL, print_statfs, NULL },
#endif
#ifdef TARGET_NR_statfs64
{ TARGET_NR_statfs64, "statfs64" , "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_NR_statfs64, "statfs64" , NULL, print_statfs64, NULL },
#endif
#ifdef TARGET_NR_stime
{ TARGET_NR_stime, "stime" , NULL, NULL, NULL },
@ -1334,10 +1339,10 @@
{ TARGET_NR_swapon, "swapon" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_symlink
{ TARGET_NR_symlink, "symlink" , "%s(\"%s\",\"%s\")", NULL, NULL },
{ TARGET_NR_symlink, "symlink" , NULL, print_symlink, NULL },
#endif
#ifdef TARGET_NR_symlinkat
{ TARGET_NR_symlinkat, "symlinkat" , "%s(\"%s\",%d,\"%s\")", NULL, NULL },
{ TARGET_NR_symlinkat, "symlinkat", NULL, print_symlinkat, NULL },
#endif
#ifdef TARGET_NR_sync
{ TARGET_NR_sync, "sync" , NULL, NULL, NULL },
@ -1427,19 +1432,19 @@
{ TARGET_NR_umask, "umask" , "%s(%#o)", NULL, NULL },
#endif
#ifdef TARGET_NR_umount
{ TARGET_NR_umount, "umount" , "%s(\"%s\",\"%s\",\"%s\",%#x,%p)", NULL, NULL },
{ TARGET_NR_umount, "umount" , NULL, print_umount, NULL },
#endif
#ifdef TARGET_NR_umount2
{ TARGET_NR_umount2, "umount2" , NULL, NULL, NULL },
{ TARGET_NR_umount2, "umount2" , NULL, print_umount2, NULL },
#endif
#ifdef TARGET_NR_uname
{ TARGET_NR_uname, "uname" , "%s(%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_unlink
{ TARGET_NR_unlink, "unlink" , "%s(\"%s\")", NULL, NULL },
{ TARGET_NR_unlink, "unlink" , NULL, print_unlink, NULL },
#endif
#ifdef TARGET_NR_unlinkat
{ TARGET_NR_unlinkat, "unlinkat" , "%s(%d,\"%s\",%#x)", NULL, NULL },
{ TARGET_NR_unlinkat, "unlinkat" , NULL, print_unlinkat, NULL },
#endif
#ifdef TARGET_NR_unshare
{ TARGET_NR_unshare, "unshare" , NULL, NULL, NULL },
@ -1469,10 +1474,10 @@
{ TARGET_NR_ustat, "ustat" , "%s(%#x,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_utime
{ TARGET_NR_utime, "utime" , "%s(\"%s\",%p)", NULL, NULL },
{ TARGET_NR_utime, "utime" , NULL, print_utime, NULL },
#endif
#ifdef TARGET_NR_utimes
{ TARGET_NR_utimes, "utimes" , NULL, NULL, NULL },
{ TARGET_NR_utimes, "utimes" , NULL, print_utimes, NULL },
#endif
#ifdef TARGET_NR_utrap_install
{ TARGET_NR_utrap_install, "utrap_install" , NULL, NULL, NULL },
@ -1511,5 +1516,5 @@
{ TARGET_NR_writev, "writev" , "%s(%d,%p,%#x)", NULL, NULL },
#endif
#ifdef TARGET_NR_utimensat
{ TARGET_NR_utimensat, "utimensat", "%s(%d,\"%s\",%p,%#x)", NULL, NULL },
{ TARGET_NR_utimensat, "utimensat", NULL, print_utimensat, NULL },
#endif

View file

@ -93,12 +93,6 @@
//#define DEBUG
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
|| defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
/* 16 bit uid wrappers emulation */
#define USE_UID16
#endif
//#include <linux/msdos_fs.h>
#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct linux_dirent [2])
#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct linux_dirent [2])

View file

@ -48,6 +48,12 @@
#define TARGET_IOC_NRBITS 8
#define TARGET_IOC_TYPEBITS 8
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
|| defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
/* 16 bit uid wrappers emulation */
#define USE_UID16
#endif
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
|| defined(TARGET_M68K) || defined(TARGET_CRIS)