2002-09-23 Michal Ludvig <mludvig@suse.cz>

Merged x86-64 port by Andi Kleen <ak@suse.de>
	and Michal Ludvig <mludvig@suse.cz>
	* Makefile.in: New target 'headers'. Failure ignored.
	* acconfig.h: New defines for x86-64.
	* configure.in: Ditto.
	* defs.h: Ditto.
	* file.c: Ditto.
	* signal.c: Ditto.
	* process.c: Added support for x86-64.
	* util.c: Ditto.
	* syscall.c: Ditto + added automatic personality switching.
	* linux/syscall.h: Ditto.
	* linux/x86_64: New directory.
	* linux/x86_64/Makefile.in: New file.
	* linux/x86_64/gentab.pl: Ditto.
	* linux/x86_64/i386-headers.diff: Ditto.
	* linux/x86_64/makeheaders.sh: Ditto.
	* linux/x86_64/syscallent.h: Ditto.
	* mem.c (print_mmap): Always print arg[4] as int.
This commit is contained in:
Michal Ludvig 2002-09-23 15:41:01 +00:00
parent 53b320f61f
commit 0e035502d2
17 changed files with 609 additions and 27 deletions

View File

@ -1,3 +1,25 @@
2002-09-23 Michal Ludvig <mludvig@suse.cz>
Merged x86-64 port by Andi Kleen <ak@suse.de>
and Michal Ludvig <mludvig@suse.cz>
* Makefile.in: New target 'headers'. Failure ignored.
* acconfig.h: New defines for x86-64.
* configure.in: Ditto.
* defs.h: Ditto.
* file.c: Ditto.
* signal.c: Ditto.
* process.c: Added support for x86-64.
* util.c: Ditto.
* syscall.c: Ditto + added automatic personality switching.
* linux/syscall.h: Ditto.
* linux/x86_64: New directory.
* linux/x86_64/Makefile.in: New file.
* linux/x86_64/gentab.pl: Ditto.
* linux/x86_64/i386-headers.diff: Ditto.
* linux/x86_64/makeheaders.sh: Ditto.
* linux/x86_64/syscallent.h: Ditto.
* mem.c (print_mmap): Always print arg[4] as int.
2002-09-23 Michal Ludvig <mludvig@suse.cz>
* configure.in: Fix regular expressions.
@ -6,7 +28,7 @@
* file.c: Use '#ifdef LINUX' instead of '#ifdef linux'.
(struct fileflags): Made extern to inhibit compiation warnings.
(sys_getdents64): Merged LINUX and SVR4 part.
* syscall.c(get_scno): Split multiline string into two distinct
* syscall.c (get_scno): Split multiline string into two distinct
strings.
2002-05-24 John Hughes <john@calva.com>

View File

@ -58,7 +58,10 @@ OBJ = strace.o version.o syscall.o util.o desc.o file.o ipc.o \
all: strace
strace: $(OBJ)
headers:
-$(MAKE) -C $(OSARCH) headers
strace: headers $(OBJ)
$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LDLIBS)
install: all

View File

@ -48,6 +48,9 @@
/* Define if this is a SH architecture. */
#undef SH
/* Define if this is a x86-64 architecture. */
#undef X86_64
/* Define if you have a SVR4 MP type procfs. I.E. /dev/xxx/ctl,
/dev/xxx/status. Also implies that you have the pr_lwp
member in prstatus. */

View File

@ -70,6 +70,9 @@ hppa*|parisc*)
sh)
arch=sh
;;
x86?64*)
arch=x86_64
;;
*)
AC_MSG_ERROR(this architecture is not yet supported by strace)
;;
@ -78,7 +81,7 @@ AC_MSG_RESULT($arch)
# Autoheader trick. Heh, heh.
arch_list='
@@@syms="$syms I386 IA64 M68K SPARC MIPS ALPHA ARM POWERPC S390 HPPA SH"@@@
@@@syms="$syms I386 IA64 M68K SPARC MIPS ALPHA ARM POWERPC S390 HPPA SH X86_64"@@@
'
osarch="$opsys"

10
defs.h
View File

@ -87,6 +87,9 @@
# if defined(ALPHA)
# define LINUX_64BIT
# endif
# if defined(X86_64)
# define LINUX_X86_64
# endif
#endif
#if defined(SVR4) || defined(FREEBSD)
@ -113,7 +116,7 @@
#include <sys/pioctl.h>
#endif /* FREEBSD */
#else /* !USE_PROCFS */
#if defined(LINUXSPARC) && defined(__GLIBC__)
#if (defined(LINUXSPARC) || defined (LINUX_X86_64)) && defined(__GLIBC__)
#include <sys/ptrace.h>
#else
/* Work around awkward prototype in ptrace.h. */
@ -180,6 +183,11 @@ extern int ptrace();
#define SUPPORTED_PERSONALITIES 2
#endif /* LINUXSPARC */
#ifdef X86_64
#undef SUPPORTED_PERSONALITIES
#define SUPPORTED_PERSONALITIES 2
#endif
#ifdef SVR4
#ifdef HAVE_MP_PROCFS
extern int mp_ioctl (int f, int c, void *a, int s);

8
file.c
View File

@ -889,7 +889,7 @@ long addr;
}
#endif /* HAVE_STAT64 */
#if defined(LINUX) && !defined(IA64) && !defined(HPPA)
#if defined(LINUX) && !defined(IA64) && !defined(HPPA) && !defined(X86_64)
static void
convertoldstat(oldbuf, newbuf)
const struct __old_kernel_stat *oldbuf;
@ -977,7 +977,7 @@ struct tcb *tcp;
}
#ifdef LINUX
# if !defined(IA64) && !defined(HPPA)
# if !defined(IA64) && !defined(HPPA) && !defined(X86_64)
int
sys_oldstat(tcp)
struct tcb *tcp;
@ -1024,7 +1024,7 @@ struct tcb *tcp;
}
#ifdef LINUX
# if !defined(IA64) && !defined(HPPA)
# if !defined(IA64) && !defined(HPPA) && !defined(X86_64)
int
sys_oldfstat(tcp)
struct tcb *tcp;
@ -1072,7 +1072,7 @@ struct tcb *tcp;
}
#ifdef LINUX
# if !defined(IA64) && !defined(HPPA)
# if !defined(IA64) && !defined(HPPA) && !defined(X86_64)
int
sys_oldlstat(tcp)
struct tcb *tcp;

View File

@ -110,7 +110,7 @@ int sys_osf_utimes();
#endif
#if !defined(ALPHA) && !defined(MIPS) &&!defined(HPPA)
#if !defined(ALPHA) && !defined(MIPS) && !defined(HPPA) && !defined(X86_64)
# ifdef IA64
/*
* IA64 syscall numbers (the only ones available from standard header
@ -161,7 +161,7 @@ int sys_osf_utimes();
#define SYS_recvmsg (SYS_socket_subcall + 17)
#define SYS_socket_nsubcalls 18
#endif /* !(ALPHA || MIPS || HPPA) */
#endif /* !(ALPHA || MIPS || HPPA || X86_64) */
/* sys_ipc subcalls */
@ -169,7 +169,7 @@ int sys_semget(), sys_semctl(), sys_semop();
int sys_msgsnd(), sys_msgrcv(), sys_msgget(), sys_msgctl();
int sys_shmat(), sys_shmdt(), sys_shmget(), sys_shmctl();
#if !defined(ALPHA) && !defined(MIPS) && !defined(SPARC) &&!defined(HPPA)
#if !defined(ALPHA) && !defined(MIPS) && !defined(SPARC) && !defined(HPPA) && !defined(X86_64)
# ifdef IA64
/*
* IA64 syscall numbers (the only ones available from standard
@ -210,7 +210,7 @@ int sys_shmat(), sys_shmdt(), sys_shmget(), sys_shmctl();
#define SYS_shmctl (SYS_ipc_subcall + 24)
#define SYS_ipc_nsubcalls 25
#endif /* !(ALPHA || MIPS || HPPA) */
#endif /* !(ALPHA || MIPS || SPARC || HPPA || X86_64) */
#ifdef IA64
/*

40
linux/x86_64/Makefile.in Normal file
View File

@ -0,0 +1,40 @@
#
# $Id$
#
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
CPP = @CPP@
SHELL = /bin/sh
DEFS = @DEFS@
LDLIBS = @LIBS@
CFLAGS = -g
LDFLAGS = -g
WARNFLAGS = @WARNFLAGS@
CPPFLAGS =
INCLUDES = -I. -I.. -I$(srcdir)/.. -I../.. -I$(srcdir)
includedir = @includedir@
all: ioctlent.h errnoent.h signalent.h syscallent.h
ia32headers= syscallent1.h syscall1.h signalent1.h ioctls1.h \
ioctlent1.h ioctldefs1.h errnoent1.h dummy1.h
headers: $(ia32headers)
$(ia32headers):
$(SHELL) ./makeheaders.sh
clean:
rm -f ioctlent.c *.raw *.tmp *.o ioctlsort *1.h
distclean: clean
rm -f Makefile
maintainer-clean: distclean

77
linux/x86_64/gentab.pl Normal file
View File

@ -0,0 +1,77 @@
#!/usr/bin/perl -w
#generate syscall table from a template file (usually the master i386 syscall
#ent.h) and the x86_64 unistd.h
%conv = (
"exit" => "_exit",
);
%known = (
"mmap" => "sys_mmap",
"sched_yield" => "printargs",
);
# only used when the template file has no entry
%args = (
"arch_prctl" => 2,
"tkill" => 2,
"gettid" => 0,
"readahead" => 3,
# should decode all these:
"setxattr" => 5,
"lsetxattr" => 5,
"fsetxattr" => 5,
"getxattr" => 4,
"lgetxattr" => 4,
"fgetxattr" => 4,
"listxattr" => 3,
"llistxattr" => 3,
"flistxattr" => 3,
"removexattr" => 2,
"lremovexattr" => 2,
"fremovexattr" => 2,
"mmap" => 6,
"sched_yield" => 0,
);
open(F,$ARGV[0]) || die "cannot open template file $ARGV[0]\n";
while (<F>) {
next unless /{/;
s/\/\*.*\*\///;
($name) = /"([^"]+)"/;
chomp;
$call{$name} = $_;
}
open(SL, ">syscallnum.h") || die "cannot create syscallnum.h\n";
open(S,$ARGV[1]) || die "cannot open syscall file $ARGV[1]\n";
while (<S>) {
$name = "";
next unless (($name, $num) = /define\s+__NR_(\S+)\s+(\d+)/);
next if $name eq "";
$name = $conv{$name} if defined($conv{$name});
if (!defined($call{$name})) {
unless (defined($args{$name})) {
print STDERR "unknown call $name $num\n";
$na = 3;
} else {
$na = $args{$name};
}
if (defined($known{$name})) {
$func = $known{$name};
} else {
$func = "printargs";
}
print "\t{ $na,\t0,\t$func,\t\"$name\" }, /* $num */\n";
} else {
print "$call{$name} /* $num */\n";
}
print SL "#define SYS_$name $num\n"
}

View File

@ -0,0 +1,31 @@
diff -urN syscallent1.h syscallent1.h
--- syscallent1.h Fri Aug 3 14:27:54 2001
+++ syscallent1.h Mon Sep 9 16:37:19 2002
@@ -50,7 +50,7 @@
{ 3, TF, sys_chown, "lchown" }, /* 16 */
#endif
{ 0, 0, sys_break, "break" }, /* 17 */
- { 2, TF, sys_oldstat, "oldstat" }, /* 18 */
+ { 2, TF, printargs, "oldstat" }, /* 18 */
{ 3, 0, sys_lseek, "lseek" }, /* 19 */
{ 0, 0, sys_getpid, "getpid" }, /* 20 */
{ 5, TF, sys_mount, "mount" }, /* 21 */
@@ -60,7 +60,7 @@
{ 1, 0, sys_stime, "stime" }, /* 25 */
{ 4, 0, sys_ptrace, "ptrace" }, /* 26 */
{ 1, 0, sys_alarm, "alarm" }, /* 27 */
- { 2, 0, sys_oldfstat, "oldfstat" }, /* 28 */
+ { 2, 0, printargs, "oldfstat" }, /* 28 */
{ 0, TS, sys_pause, "pause" }, /* 29 */
{ 2, TF, sys_utime, "utime" }, /* 30 */
{ 2, 0, sys_stty, "stty" }, /* 31 */
@@ -116,7 +116,7 @@
{ 2, 0, sys_setgroups, "setgroups" }, /* 81 */
{ 1, 0, sys_oldselect, "oldselect" }, /* 82 */
{ 2, TF, sys_symlink, "symlink" }, /* 83 */
- { 2, TF, sys_oldlstat, "oldlstat" }, /* 84 */
+ { 2, TF, printargs, "oldlstat" }, /* 84 */
{ 3, TF, sys_readlink, "readlink" }, /* 85 */
{ 1, TF, sys_uselib, "uselib" }, /* 86 */
{ 1, TF, sys_swapon, "swapon" }, /* 87 */

View File

@ -0,0 +1,8 @@
#!/bin/sh
for i in ../*.h; do
NM=`basename $i .h`1.h
/bin/cp -vf $i $NM
done
patch -p0 < i386-headers.diff

202
linux/x86_64/syscallent.h Normal file
View File

@ -0,0 +1,202 @@
{ 3, 0, sys_read, "read" }, /* 0 */
{ 3, 0, sys_write, "write" }, /* 1 */
{ 3, TF, sys_open, "open" }, /* 2 */
{ 1, 0, sys_close, "close" }, /* 3 */
{ 2, TF, sys_stat, "stat" }, /* 4 */
{ 2, 0, sys_fstat, "fstat" }, /* 5 */
{ 2, TF, sys_lstat, "lstat" }, /* 6 */
{ 3, 0, sys_poll, "poll" }, /* 7 */
{ 3, 0, sys_lseek, "lseek" }, /* 8 */
{ 6, 0, sys_mmap, "mmap" }, /* 9 */
{ 3, 0, sys_mprotect, "mprotect" }, /* 10 */
{ 2, 0, sys_munmap, "munmap" }, /* 11 */
{ 1, 0, sys_brk, "brk" }, /* 12 */
{ 4, TS, sys_rt_sigaction, "rt_sigaction" }, /* 13 */
{ 4, TS, sys_rt_sigprocmask, "rt_sigprocmask"}, /* 14 */
{ 1, TS, printargs, "rt_sigreturn" }, /* 15 */
{ 3, 0, sys_ioctl, "ioctl" }, /* 16 */
{ 5, TF, sys_pread, "pread" }, /* 17 */
{ 5, TF, sys_pwrite, "pwrite" }, /* 18 */
{ 3, 0, sys_readv, "readv" }, /* 19 */
{ 3, 0, sys_writev, "writev" }, /* 20 */
{ 2, TF, sys_access, "access" }, /* 21 */
{ 1, 0, sys_pipe, "pipe" }, /* 22 */
{ 5, 0, sys_select, "select" }, /* 23 */
{ 0, 0, sys_sched_yield, "sched_yield"}, /* 24 */
{ 4, 0, sys_mremap, "mremap" }, /* 25 */
{ 3, 0, sys_msync, "msync" }, /* 26 */
{ 3, 0, printargs, "mincore" }, /* 27 */
{ 3, 0, sys_madvise, "madvise" }, /* 28 */
{ 4, TI, sys_shmget, "shmget" }, /* 29 */
{ 4, TI, sys_shmat, "shmat" }, /* 30 */
{ 4, TI, sys_shmctl, "shmctl" }, /* 31 */
{ 1, 0, sys_dup, "dup" }, /* 32 */
{ 2, 0, sys_dup2, "dup2" }, /* 33 */
{ 0, TS, sys_pause, "pause" }, /* 34 */
{ 2, 0, sys_nanosleep, "nanosleep" }, /* 35 */
{ 2, 0, sys_getitimer, "getitimer" }, /* 36 */
{ 1, 0, sys_alarm, "alarm" }, /* 37 */
{ 3, 0, sys_setitimer, "setitimer" }, /* 38 */
{ 0, 0, sys_getpid, "getpid" }, /* 39 */
{ 4, TF, sys_sendfile, "sendfile" }, /* 40 */
{ 3, TN, sys_socket, "socket" }, /* 41 */
{ 3, TN, sys_connect, "connect" }, /* 42 */
{ 3, TN, sys_accept, "accept" }, /* 43 */
{ 6, TN, sys_sendto, "sendto" }, /* 44 */
{ 6, TN, sys_recvfrom, "recvfrom" }, /* 45 */
{ 5, TN, sys_sendmsg, "sendmsg" }, /* 46 */
{ 5, TN, sys_recvmsg, "recvmsg" }, /* 47 */
{ 2, TN, sys_shutdown, "shutdown" }, /* 48 */
{ 3, TN, sys_bind, "bind" }, /* 49 */
{ 2, TN, sys_listen, "listen" }, /* 50 */
{ 3, TN, sys_getsockname, "getsockname" }, /* 51 */
{ 3, TN, sys_getpeername, "getpeername" }, /* 52 */
{ 4, TN, sys_socketpair, "socketpair" }, /* 53 */
{ 5, TN, sys_setsockopt, "setsockopt" }, /* 54 */
{ 5, TN, sys_getsockopt, "getsockopt" }, /* 55 */
{ 2, TP, sys_clone, "clone" }, /* 56 */
{ 0, TP, sys_fork, "fork" }, /* 57 */
{ 0, TP, sys_vfork, "vfork" }, /* 58 */
{ 3, TF|TP, sys_execve, "execve" }, /* 59 */
{ 1, TP, sys_exit, "_exit" }, /* 60 */
{ 4, TP, sys_wait4, "wait4" }, /* 61 */
{ 2, TS, sys_kill, "kill" }, /* 62 */
{ 1, 0, sys_uname, "uname" }, /* 63 */
{ 4, TI, sys_semget, "semget" }, /* 64 */
{ 4, TI, sys_semop, "semop" }, /* 65 */
{ 4, TI, sys_semctl, "semctl" }, /* 66 */
{ 4, TI, sys_shmdt, "shmdt" }, /* 67 */
{ 4, TI, sys_msgget, "msgget" }, /* 68 */
{ 4, TI, sys_msgsnd, "msgsnd" }, /* 69 */
{ 4, TI, sys_msgrcv, "msgrcv" }, /* 70 */
{ 4, TI, sys_msgctl, "msgctl" }, /* 71 */
{ 3, 0, sys_fcntl, "fcntl" }, /* 72 */
{ 2, 0, sys_flock, "flock" }, /* 73 */
{ 1, 0, sys_fsync, "fsync" }, /* 74 */
{ 1, 0, sys_fdatasync, "fdatasync" }, /* 75 */
{ 2, TF, sys_truncate, "truncate" }, /* 76 */
{ 2, 0, sys_ftruncate, "ftruncate" }, /* 77 */
{ 3, 0, sys_getdents, "getdents" }, /* 78 */
{ 2, TF, sys_getcwd, "getcwd" }, /* 79 */
{ 1, TF, sys_chdir, "chdir" }, /* 80 */
{ 1, 0, sys_fchdir, "fchdir" }, /* 81 */
{ 2, TF, sys_rename, "rename" }, /* 82 */
{ 2, TF, sys_mkdir, "mkdir" }, /* 83 */
{ 1, TF, sys_rmdir, "rmdir" }, /* 84 */
{ 2, TF, sys_creat, "creat" }, /* 85 */
{ 2, TF, sys_link, "link" }, /* 86 */
{ 1, TF, sys_unlink, "unlink" }, /* 87 */
{ 2, TF, sys_symlink, "symlink" }, /* 88 */
{ 3, TF, sys_readlink, "readlink" }, /* 89 */
{ 2, TF, sys_chmod, "chmod" }, /* 90 */
{ 2, 0, sys_fchmod, "fchmod" }, /* 91 */
{ 3, TF, sys_chown, "chown" }, /* 92 */
{ 3, 0, sys_fchown, "fchown" }, /* 93 */
{ 3, TF, sys_chown, "lchown" }, /* 94 */
{ 1, 0, sys_umask, "umask" }, /* 95 */
{ 2, 0, sys_gettimeofday, "gettimeofday" }, /* 96 */
{ 2, 0, printargs, "getrlimit" }, /* 97 */
{ 2, 0, sys_getrusage, "getrusage" }, /* 98 */
{ 1, 0, sys_sysinfo, "sysinfo" }, /* 99 */
{ 1, 0, sys_times, "times" }, /* 100 */
{ 4, 0, sys_ptrace, "ptrace" }, /* 101 */
{ 0, 0, sys_getuid, "getuid" }, /* 102 */
{ 3, 0, sys_syslog, "syslog" }, /* 103 */
{ 0, 0, sys_getgid, "getgid" }, /* 104 */
{ 1, 0, sys_setuid, "setuid" }, /* 105 */
{ 1, 0, sys_setgid, "setgid" }, /* 106 */
{ 0, 0, sys_geteuid, "geteuid" }, /* 107 */
{ 0, 0, sys_getegid, "getegid" }, /* 108 */
{ 2, 0, sys_setpgid, "setpgid" }, /* 109 */
{ 0, 0, sys_getppid, "getppid" }, /* 110 */
{ 0, 0, sys_getpgrp, "getpgrp" }, /* 111 */
{ 0, 0, sys_setsid, "setsid" }, /* 112 */
{ 2, 0, sys_setreuid, "setreuid" }, /* 113 */
{ 2, 0, sys_setregid, "setregid" }, /* 114 */
{ 2, 0, sys_getgroups, "getgroups" }, /* 115 */
{ 2, 0, sys_setgroups, "setgroups" }, /* 116 */
{ 3, 0, sys_setresuid, "setresuid" }, /* 117 */
{ 3, 0, sys_getresuid, "getresuid" }, /* 118 */
{ 3, 0, sys_setresgid, "setresgid" }, /* 119 */
{ 3, 0, sys_getresgid, "getresgid" }, /* 120 */
{ 1, 0, sys_getpgid, "getpgid" }, /* 121 */
{ 1, 0, sys_setfsuid, "setfsuid" }, /* 122 */
{ 1, 0, sys_setfsgid, "setfsgid" }, /* 123 */
{ 1, 0, sys_getsid, "getsid" }, /* 124 */
{ 2, 0, sys_capget, "capget" }, /* 125 */
{ 2, 0, sys_capset, "capset" }, /* 126 */
{ 2, TS, sys_rt_sigpending, "rt_sigpending" }, /* 127 */
{ 4, TS, sys_rt_sigtimedwait, "rt_sigtimedwait" }, /* 128 */
{ 3, TS, sys_rt_sigqueueinfo, "rt_sigqueueinfo" }, /* 129 */
{ 2, TS, sys_rt_sigsuspend, "rt_sigsuspend" }, /* 130 */
{ 2, TS, sys_sigaltstack, "sigaltstack" }, /* 131 */
{ 2, TF, sys_utime, "utime" }, /* 132 */
{ 3, TF, sys_mknod, "mknod" }, /* 133 */
{ 1, TF, sys_uselib, "uselib" }, /* 134 */
{ 1, 0, sys_personality, "personality" }, /* 135 */
{ 2, 0, sys_ustat, "ustat" }, /* 136 */
{ 2, TF, sys_statfs, "statfs" }, /* 137 */
{ 2, 0, sys_fstatfs, "fstatfs" }, /* 138 */
{ 3, 0, sys_sysfs, "sysfs" }, /* 139 */
{ 2, 0, sys_getpriority, "getpriority" }, /* 140 */
{ 3, 0, sys_setpriority, "setpriority" }, /* 141 */
{ 0, 0, sys_sched_setparam, "sched_setparam" }, /* 142 */
{ 2, 0, sys_sched_getparam, "sched_getparam" }, /* 143 */
{ 3, 0, sys_sched_setscheduler, "sched_setscheduler" }, /* 144 */
{ 1, 0, sys_sched_getscheduler, "sched_getscheduler" }, /* 145 */
{ 1, 0, sys_sched_get_priority_max, "sched_get_priority_max" }, /* 146 */
{ 1, 0, sys_sched_get_priority_min, "sched_get_priority_min" }, /* 147 */
{ 2, 0, sys_sched_rr_get_interval, "sched_rr_get_interval" }, /* 148 */
{ 1, 0, sys_mlock, "mlock" }, /* 149 */
{ 2, 0, sys_munlock, "munlock" }, /* 150 */
{ 2, 0, sys_mlockall, "mlockall" }, /* 151 */
{ 0, 0, sys_munlockall, "munlockall" }, /* 152 */
{ 0, 0, sys_vhangup, "vhangup" }, /* 153 */
{ 3, 0, sys_modify_ldt, "modify_ldt" }, /* 154 */
{ 2, TF, sys_pivotroot, "pivot_root" }, /* 155 */
{ 1, 0, sys_sysctl, "_sysctl" }, /* 156 */
{ 5, 0, printargs, "prctl" }, /* 157 */
{ 2, 0, printargs, "arch_prctl" }, /* 158 */
{ 1, 0, sys_adjtimex, "adjtimex" }, /* 159 */
{ 2, 0, sys_setrlimit, "setrlimit" }, /* 160 */
{ 1, TF, sys_chroot, "chroot" }, /* 161 */
{ 0, 0, sys_sync, "sync" }, /* 162 */
{ 1, TF, sys_acct, "acct" }, /* 163 */
{ 2, 0, sys_settimeofday, "settimeofday" }, /* 164 */
{ 5, TF, sys_mount, "mount" }, /* 165 */
{ 3, 0, printargs, "umount2" }, /* 166 */
{ 1, TF, sys_swapon, "swapon" }, /* 167 */
{ 1, 0, sys_swapoff, "swapoff" }, /* 168 */
{ 3, 0, sys_reboot, "reboot" }, /* 169 */
{ 2, 0, sys_sethostname, "sethostname" }, /* 170 */
{ 2, 0, sys_setdomainname, "setdomainname" }, /* 171 */
{ 1, 0, sys_iopl, "iopl" }, /* 172 */
{ 3, 0, sys_ioperm, "ioperm" }, /* 173 */
{ 2, 0, sys_create_module, "create_module" }, /* 174 */
{ 2, 0, sys_init_module, "init_module" }, /* 175 */
{ 1, 0, sys_delete_module, "delete_module" }, /* 176 */
{ 1, 0, sys_get_kernel_syms, "get_kernel_syms"}, /* 177 */
{ 5, 0, sys_query_module, "query_module" }, /* 178 */
{ 4, 0, sys_quotactl, "quotactl" }, /* 179 */
{ 3, 0, printargs, "nfsservctl" }, /* 180 */
{ 3, 0, printargs, "getpmsg" }, /* 181 */
{ 3, 0, printargs, "putpmsg" }, /* 182 */
{ 5, 0, sys_afs_syscall, "afs_syscall" }, /* 183 */
{ 3, 0, printargs, "tuxcall" }, /* 184 */
{ 3, 0, printargs, "security" }, /* 185 */
{ 0, 0, printargs, "gettid" }, /* 186 */
{ 3, 0, printargs, "readahead" }, /* 187 */
{ 5, 0, printargs, "setxattr" }, /* 188 */
{ 5, 0, printargs, "lsetxattr" }, /* 189 */
{ 5, 0, printargs, "fsetxattr" }, /* 190 */
{ 4, 0, printargs, "getxattr" }, /* 191 */
{ 4, 0, printargs, "lgetxattr" }, /* 192 */
{ 4, 0, printargs, "fgetxattr" }, /* 193 */
{ 3, 0, printargs, "listxattr" }, /* 194 */
{ 3, 0, printargs, "llistxattr" }, /* 195 */
{ 3, 0, printargs, "flistxattr" }, /* 196 */
{ 2, 0, printargs, "removexattr" }, /* 197 */
{ 2, 0, printargs, "lremovexattr" }, /* 198 */
{ 2, 0, printargs, "fremovexattr" }, /* 199 */
{ 2, 0, printargs, "tkill" }, /* 200 */
{ 1, 0, sys_time, "time" }, /* 201 */

4
mem.c
View File

@ -185,8 +185,8 @@ long *u_arg;
#else
printflags(mmap_flags, u_arg[3]);
#endif
/* fd */
tprintf(", %ld, ", u_arg[4]);
/* fd (is always int, not long) */
tprintf(", %d, ", (int)u_arg[4]);
/* offset */
tprintf("%#lx", u_arg[5]);
}

View File

@ -495,6 +495,11 @@ int new;
if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0)
return -1;
return 0;
#elif defined(X86_64)
/* Attempt to make vfork into fork, which we can follow. */
if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_RAX * 8), new) < 0)
return -1;
return 0;
#elif defined(POWERPC)
if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R0), new) < 0)
return -1;
@ -569,6 +574,12 @@ setarg(tcp, argnum)
if (errno)
return -1;
}
#elif defined(X86_64)
{
ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(8*(long)argnum), tcp->u_arg[argnum]);
if (errno)
return -1;
}
#elif defined(MIPS)
{
errno = 0;
@ -2033,6 +2044,35 @@ struct xlat struct_user_offsets[] = {
{ 4*UESP, "4*UESP" },
{ 4*SS, "4*SS" },
#else /* !I386 */
#ifdef X86_64
{ 8*RDI, "8*RDI" },
{ 8*RSI, "8*RSI" },
{ 8*RDX, "8*RDX" },
{ 8*R10, "8*R10" },
{ 8*R8, "8*R8" },
{ 8*R9, "8*R9" },
{ 8*RBX, "8*RBX" },
{ 8*RCX, "8*RCX" },
{ 8*RBP, "8*RBP" },
{ 8*RAX, "8*RAX" },
#if 0
{ 8*DS, "8*DS" },
{ 8*ES, "8*ES" },
{ 8*FS, "8*FS" },
{ 8*GS, "8*GS" },
#endif
{ 8*ORIG_RAX, "8*ORIG_EAX" },
{ 8*RIP, "8*RIP" },
{ 8*CS, "8*CS" },
{ 8*EFLAGS, "8*EFL" },
{ 8*RSP, "8*RSP" },
{ 8*SS, "8*SS" },
{ 8*R11, "8*R11" },
{ 8*R12, "8*R12" },
{ 8*R13, "8*R13" },
{ 8*R14, "8*R14" },
{ 8*R15, "8*R15" },
#endif
#ifdef M68K
{ 4*PT_D1, "4*PT_D1" },
{ 4*PT_D2, "4*PT_D2" },
@ -2110,7 +2150,7 @@ struct xlat struct_user_offsets[] = {
#if !defined(S390) && !defined(MIPS)
{ uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
#endif
#ifdef I386
#if defined(I386) || defined(X86_64)
{ uoff(i387), "offsetof(struct user, i387)" },
#else /* !I386 */
#ifdef M68K
@ -2132,7 +2172,7 @@ struct xlat struct_user_offsets[] = {
#endif
{ uoff(magic), "offsetof(struct user, magic)" },
{ uoff(u_comm), "offsetof(struct user, u_comm)" },
#ifdef I386
#if defined(I386) || defined(X86_64)
{ uoff(u_debugreg), "offsetof(struct user, u_debugreg)" },
#endif /* I386 */
#endif /* !IA64 */

View File

@ -83,7 +83,7 @@ typedef struct {
struct regs si_regs;
int si_mask;
} m_siginfo_t;
#elif !defined(IA64)
#elif !defined(IA64) && !defined(X86_64)
#include <asm/sigcontext.h>
#endif /* SPARC */
#else /* !HAVE_ASM_SIGCONTEXT_H */
@ -1357,10 +1357,9 @@ struct tcb *tcp;
}
return 0;
#else
#ifdef HPPA
#warning NO sys_sigreturn DECODE FOR HPPA
#warning No sys_sigreturn() for this architecture
#warning (no problem, just a reminder :-)
return 0;
#endif /* HPPA */
#endif /* MIPS */
#endif /* SPARC */
#endif /* ALPHA */

127
syscall.c
View File

@ -499,7 +499,7 @@ struct tcb *tcp;
}
}
static void
void
decode_subcall(tcp, subcall, nsubcalls, style)
struct tcb *tcp;
int subcall;
@ -686,7 +686,8 @@ struct tcb *tcp;
static long r28;
#elif defined(SH)
static long r0;
#elif defined(X86_64)
static long rax;
#endif
#endif /* LINUX */
#ifdef FREEBSD
@ -698,6 +699,7 @@ get_scno(tcp)
struct tcb *tcp;
{
long scno = 0;
static int currpers=-1;
#ifndef USE_PROCFS
int pid = tcp->pid;
#endif /* !PROCFS */
@ -723,6 +725,73 @@ struct tcb *tcp;
#elif defined (I386)
if (upeek(pid, 4*ORIG_EAX, &scno) < 0)
return -1;
#elif defined (X86_64)
if (upeek(pid, 8*ORIG_RAX, &scno) < 0)
return -1;
if (!(tcp->flags & TCB_INSYSCALL)) {
long val;
/* Check CS register value. On x86-64 linux it is:
* 0x33 for long mode (64 bit)
* 0x23 for compatibility mode (32 bit)
* It takes only one ptrace and thus doesn't need
* to be cached.
*/
if (upeek(pid, 8*CS, &val) < 0)
return -1;
switch(val)
{
case 0x23: currpers = 1; break;
case 0x33: currpers = 0; break;
default:
fprintf(stderr, "Unknown value CS=0x%02X while "
"detecting personality of process "
"PID=%d\n", (int)val, pid);
currpers = current_personality;
break;
}
#if 0
/* This version analyzes the opcode of a syscall instruction.
* (int 0x80 on i386 vs. syscall on x86-64)
* It works, but is too complicated.
*/
unsigned long val, rip, i;
if(upeek(pid, 8*RIP, &rip)<0)
perror("upeek(RIP)");
/* sizeof(syscall) == sizeof(int 0x80) == 2 */
rip-=2;
errno = 0;
call = ptrace(PTRACE_PEEKTEXT,pid,(char *)rip,0);
if (errno)
printf("ptrace_peektext failed: %s\n",
strerror(errno));
switch (call & 0xffff)
{
/* x86-64: syscall = 0x0f 0x05 */
case 0x050f: currpers = 0; break;
/* i386: int 0x80 = 0xcd 0x80 */
case 0x80cd: currpers = 1; break;
default:
currpers = current_personality;
fprintf(stderr,
"Unknown syscall opcode (0x%04X) while "
"detecting personality of process "
"PID=%d\n", (int)call, pid);
break;
}
#endif
if(currpers != current_personality)
{
char *names[]={"64 bit", "32 bit"};
set_personality(currpers);
printf("[ Process PID=%d runs in %s mode. ]\n",
pid, names[current_personality]);
}
}
#elif defined(IA64)
# define IA64_PSR_IS ((long)1 << 34)
if (upeek (pid, PT_CR_IPSR, &psr) >= 0)
@ -1021,6 +1090,14 @@ struct tcb *tcp;
fprintf(stderr, "stray syscall exit: eax = %ld\n", eax);
return 0;
}
#elif defined (X86_64)
if (upeek(pid, 8*RAX, &rax) < 0)
return -1;
if (rax != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) {
if (debug)
fprintf(stderr, "stray syscall exit: rax = %ld\n", rax);
return 0;
}
#elif defined (S390)
if (upeek(pid, PT_GPR2, &gpr2) < 0)
return -1;
@ -1097,6 +1174,16 @@ struct tcb *tcp;
u_error = 0;
}
#else /* !I386 */
#ifdef X86_64
if (rax < 0 && -rax < nerrnos) {
tcp->u_rval = -1;
u_error = -rax;
}
else {
tcp->u_rval = rax;
u_error = 0;
}
#else
#ifdef IA64
if (ia32) {
int err;
@ -1208,6 +1295,7 @@ struct tcb *tcp;
#endif /* POWERPC */
#endif /* MIPS */
#endif /* IA64 */
#endif /* X86_64 */
#endif /* I386 */
#endif /* S390 */
#endif /* LINUX */
@ -1249,6 +1337,17 @@ struct tcb *tcp;
u_error = 0;
}
#endif /* I386 */
#ifdef X86_64
/* Wanna know how to kill an hour single-stepping? */
if (tcp->status.PR_REG[EFLAGS] & 0x1) {
tcp->u_rval = -1;
u_error = tcp->status.PR_REG[RAX];
}
else {
tcp->u_rval = tcp->status.PR_REG[RAX];
u_error = 0;
}
#endif /* X86_64 */
#ifdef MIPS
if (tcp->status.pr_reg[CTX_A3]) {
tcp->u_rval = -1;
@ -1440,6 +1539,23 @@ struct tcb *tcp;
return -1;
}
}
#elif defined(X86_64)
{
int i;
static int argreg[SUPPORTED_PERSONALITIES][MAX_ARGS] = {
{RDI,RSI,RDX,R10,R8,R9}, /* x86-64 ABI */
{RBX,RCX,RDX,RDX,RSI,RDI,RBP} /* i386 ABI */
};
if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
tcp->u_nargs = sysent[tcp->scno].nargs;
else
tcp->u_nargs = MAX_ARGS;
for (i = 0; i < tcp->u_nargs; i++) {
if (upeek(pid, argreg[current_personality][i]*8, &tcp->u_arg[i]) < 0)
return -1;
}
}
#else /* Other architecture (like i386) (32bits specific) */
{
int i;
@ -1729,7 +1845,7 @@ struct tcb *tcp;
switch (tcp->scno + NR_SYSCALL_BASE) {
#ifdef LINUX
#if !defined (ALPHA) && !defined(SPARC) && !defined(MIPS) && !defined(HPPA)
#if !defined (ALPHA) && !defined(SPARC) && !defined(MIPS) && !defined(HPPA) && !defined(X86_64)
case SYS_socketcall:
decode_subcall(tcp, SYS_socket_subcall,
SYS_socket_nsubcalls, deref_style);
@ -1738,7 +1854,7 @@ struct tcb *tcp;
decode_subcall(tcp, SYS_ipc_subcall,
SYS_ipc_nsubcalls, shift_style);
break;
#endif /* !ALPHA && !MIPS && !SPARC */
#endif /* !ALPHA && !MIPS && !SPARC && !HPPA && !X86_64 */
#ifdef SPARC
case SYS_socketcall:
sparc_socket_decode (tcp);
@ -1899,6 +2015,9 @@ struct tcb *tcp;
#ifdef I386
val = tcp->status.PR_REG[EDX];
#endif /* I386 */
#ifdef X86_64
val = tcp->status.PR_REG[RDX];
#endif /* X86_64 */
#ifdef MIPS
val = tcp->status.PR_REG[CTX_V1];
#endif /* MIPS */

33
util.c
View File

@ -908,7 +908,9 @@ long *res;
errno = 0;
val = ptrace(PTRACE_PEEKUSER, pid, (char *) off, 0);
if (val == -1 && errno) {
perror("upeek: ptrace(PTRACE_PEEKUSER, ... )");
char buf[60];
sprintf(buf,"upeek: ptrace(PTRACE_PEEKUSER,%d,%lu,0)",pid,off);
perror(buf);
return -1;
}
*res = val;
@ -927,6 +929,9 @@ struct tcb *tcp;
#if defined(I386)
if (upeek(tcp->pid, 4*EIP, &pc) < 0)
return -1;
#elif defined(X86_64)
if (upeek(tcp->pid, 8*RIP, &pc) < 0)
return -1;
#elif defined(IA64)
if (upeek(tcp->pid, PT_B0, &pc) < 0)
return -1;
@ -1002,6 +1007,14 @@ struct tcb *tcp;
return;
}
tprintf("[%08lx] ", eip);
#elif defined(X86_64)
long rip;
if (upeek(tcp->pid, 8*RIP, &rip) < 0) {
tprintf("[????????] ");
return;
}
tprintf("[%16lx] ", rip);
#elif defined(IA62)
long ip;
@ -1212,7 +1225,7 @@ struct tcb *tcp;
}
#else /* !IA64 */
#if defined (I386)
#if defined (I386) || defined(X86_64)
#define LOOP 0x0000feeb
#elif defined (M68K)
#define LOOP 0x60fe0000
@ -1245,6 +1258,9 @@ struct tcb *tcp;
#if defined (I386)
if (upeek(tcp->pid, 4*EIP, &tcp->baddr) < 0)
return -1;
#elif defined (X86_64)
if (upeek(tcp->pid, 8*RIP, &tcp->baddr) < 0)
return -1;
#elif defined (M68K)
if (upeek(tcp->pid, 4*PT_PC, &tcp->baddr) < 0)
return -1;
@ -1346,7 +1362,7 @@ struct tcb *tcp;
{
#ifdef LINUX
#if defined(I386)
#if defined(I386) || defined(X86_64)
long eip;
#elif defined(POWERPC)
long pc;
@ -1467,6 +1483,17 @@ struct tcb *tcp;
eip, tcp->baddr);
return 0;
}
#elif defined(X86_64)
if (upeek(tcp->pid, 8*RIP, &eip) < 0)
return -1;
if (eip != tcp->baddr) {
/* The breakpoint has not been reached yet. */
if (debug)
fprintf(stderr,
"NOTE: PC not at bpt (pc %#lx baddr %#lx)\n",
eip, tcp->baddr);
return 0;
}
#elif defined(POWERPC)
if (upeek(tcp->pid, 4*PT_NIP, &pc) < 0)
return -1;