diff options
author | Juan Cespedes <cespedes@debian.org> | 1998-09-25 14:48:42 +0200 |
---|---|---|
committer | Juan Cespedes <cespedes@debian.org> | 1998-09-25 14:48:42 +0200 |
commit | d44c6b8b090b8b7aa9d971d9e0bfd848732a3071 (patch) | |
tree | c304ad26a8ab4faf3fe5c92c3fb4d011c40c503a /sysdeps | |
parent | 8e3e082c27716245619721207cd5067d8c6271f9 (diff) | |
download | ltrace-d44c6b8b090b8b7aa9d971d9e0bfd848732a3071.tar.gz |
Version: 0.3.6
* Added m68k port (Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>) (Bug#27075)
* Changed "int pid" with "pid_t pid" everywhere
* Fixed return type of some functions from "int" to "void *" (thanks, Roman)
Diffstat (limited to 'sysdeps')
25 files changed, 999 insertions, 41 deletions
diff --git a/sysdeps/Linux/arm/arch.h b/sysdeps/Linux/arm/arch.h index 7a5af84..8eda583 100644 --- a/sysdeps/Linux/arm/arch.h +++ b/sysdeps/Linux/arm/arch.h @@ -1,5 +1,3 @@ -#include <sys/types.h> - #define BREAKPOINT_VALUE 0xef9f0001 #define BREAKPOINT_LENGTH 4 /* we don't need to decr the pc; the kernel does it for us! */ diff --git a/sysdeps/Linux/arm/breakpoint.c b/sysdeps/Linux/arm/breakpoint.c index 1fe7994..2e80739 100644 --- a/sysdeps/Linux/arm/breakpoint.c +++ b/sysdeps/Linux/arm/breakpoint.c @@ -1,7 +1,11 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/ptrace.h> #include "ltrace.h" -void insert_breakpoint(int pid, struct breakpoint * sbp) +void insert_breakpoint(pid_t pid, struct breakpoint * sbp) { int a; @@ -14,7 +18,7 @@ void insert_breakpoint(int pid, struct breakpoint * sbp) ptrace(PTRACE_POKETEXT, pid, sbp->addr, a); } -void delete_breakpoint(int pid, struct breakpoint * sbp) +void delete_breakpoint(pid_t pid, struct breakpoint * sbp) { int a; diff --git a/sysdeps/Linux/arm/regs.c b/sysdeps/Linux/arm/regs.c index 92d1ca9..78ee60f 100644 --- a/sysdeps/Linux/arm/regs.c +++ b/sysdeps/Linux/arm/regs.c @@ -1,3 +1,7 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <sys/ptrace.h> #include <asm/ptrace.h> @@ -14,20 +18,20 @@ #define off_lr 56 #define off_sp 52 -int get_instruction_pointer(pid_t pid) +void * get_instruction_pointer(pid_t pid) { - return ptrace(PTRACE_PEEKUSER, pid, off_pc, 0); + return (void *)ptrace(PTRACE_PEEKUSER, pid, off_pc, 0); } -int get_stack_pointer(pid_t pid) +void * get_stack_pointer(pid_t pid) { - return ptrace(PTRACE_PEEKUSER, pid, off_sp, 0); + return (void *)ptrace(PTRACE_PEEKUSER, pid, off_sp, 0); } /* really, this is given the *stack_pointer expecting * a CISC architecture; in our case, we don't need that */ -int get_return_addr(pid_t pid, void * stack_pointer) +void * get_return_addr(pid_t pid, void * stack_pointer) { - return ptrace(PTRACE_PEEKUSER, pid, off_lr, 0); + return (void *)ptrace(PTRACE_PEEKUSER, pid, off_lr, 0); } diff --git a/sysdeps/Linux/arm/syscallent.h b/sysdeps/Linux/arm/syscallent.h index 36b9021..cbce4cb 100644 --- a/sysdeps/Linux/arm/syscallent.h +++ b/sysdeps/Linux/arm/syscallent.h @@ -111,7 +111,7 @@ "iopl", /* 110 */ "vhangup", /* 111 */ "idle", /* 112 */ - "vm86", /* 113 */ + "syscall", /* 113 */ "wait4", /* 114 */ "swapoff", /* 115 */ "sysinfo", /* 116 */ @@ -157,8 +157,28 @@ "sched_setscheduler", /* 156 */ "sched_getscheduler", /* 157 */ "sched_yield", /* 158 */ - "sched_get_priority_max",/* 159 */ - "sched_get_priority_min",/* 160 */ - "sched_rr_get_interval",/* 161 */ + "sched_get_priority_max", /* 159 */ + "sched_get_priority_min", /* 160 */ + "sched_rr_get_interval", /* 161 */ "nanosleep", /* 162 */ "mremap", /* 163 */ + "setresuid", /* 164 */ + "getresuid", /* 165 */ + "vm86", /* 166 */ + "query_module", /* 167 */ + "poll", /* 168 */ + "nfsservctl", /* 169 */ + "setresgid", /* 170 */ + "getresgid", /* 171 */ + "prctl", /* 172 */ + "rt_sigreturn", /* 173 */ + "rt_sigaction", /* 174 */ + "rt_sigprocmask", /* 175 */ + "rt_sigpending", /* 176 */ + "rt_sigtimedwait", /* 177 */ + "rt_sigqueueinfo", /* 178 */ + "rt_sigsuspend", /* 179 */ + "pread", /* 180 */ + "pwrite", /* 181 */ + "xstat", /* 182 */ + "xmknod", /* 183 */ diff --git a/sysdeps/Linux/arm/trace.c b/sysdeps/Linux/arm/trace.c index 95d2c47..6647458 100644 --- a/sysdeps/Linux/arm/trace.c +++ b/sysdeps/Linux/arm/trace.c @@ -1,3 +1,7 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <sys/wait.h> #include <signal.h> diff --git a/sysdeps/Linux/i386/arch.h b/sysdeps/Linux/i386/arch.h index adfee31..6a18fd7 100644 --- a/sysdeps/Linux/i386/arch.h +++ b/sysdeps/Linux/i386/arch.h @@ -1,5 +1,3 @@ -#include <sys/types.h> - #define BREAKPOINT_VALUE {0xcc} #define BREAKPOINT_LENGTH 1 #define DECR_PC_AFTER_BREAK 1 diff --git a/sysdeps/Linux/i386/breakpoint.c b/sysdeps/Linux/i386/breakpoint.c index dfde2ad..ce235c8 100644 --- a/sysdeps/Linux/i386/breakpoint.c +++ b/sysdeps/Linux/i386/breakpoint.c @@ -1,7 +1,11 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/ptrace.h> #include "ltrace.h" -void insert_breakpoint(int pid, struct breakpoint * sbp) +void insert_breakpoint(pid_t pid, struct breakpoint * sbp) { int a; @@ -12,7 +16,7 @@ void insert_breakpoint(int pid, struct breakpoint * sbp) ptrace(PTRACE_POKETEXT, pid, sbp->addr, a); } -void delete_breakpoint(int pid, struct breakpoint * sbp) +void delete_breakpoint(pid_t pid, struct breakpoint * sbp) { int a; diff --git a/sysdeps/Linux/i386/regs.c b/sysdeps/Linux/i386/regs.c index d066cf1..f36be55 100644 --- a/sysdeps/Linux/i386/regs.c +++ b/sysdeps/Linux/i386/regs.c @@ -1,3 +1,7 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <sys/ptrace.h> #include <asm/ptrace.h> @@ -10,18 +14,18 @@ # define PTRACE_POKEUSER PTRACE_POKEUSR #endif -int get_instruction_pointer(pid_t pid) +void * get_instruction_pointer(pid_t pid) { - return ptrace(PTRACE_PEEKUSER, pid, 4*EIP, 0); + return (void *)ptrace(PTRACE_PEEKUSER, pid, 4*EIP, 0); } -int get_stack_pointer(pid_t pid) +void * get_stack_pointer(pid_t pid) { - return ptrace(PTRACE_PEEKUSER, pid, 4*UESP, 0); + return (void *)ptrace(PTRACE_PEEKUSER, pid, 4*UESP, 0); } -int get_return_addr(pid_t pid, void * stack_pointer) +void * get_return_addr(pid_t pid, void * stack_pointer) { - return ptrace(PTRACE_PEEKTEXT, pid, stack_pointer, 0); + return (void *)ptrace(PTRACE_PEEKTEXT, pid, stack_pointer, 0); } diff --git a/sysdeps/Linux/i386/syscallent.h b/sysdeps/Linux/i386/syscallent.h index 36b9021..9a1ad53 100644 --- a/sysdeps/Linux/i386/syscallent.h +++ b/sysdeps/Linux/i386/syscallent.h @@ -1,4 +1,4 @@ - "setup", /* 0 */ + "(NONE)", /* 0 */ "exit", /* 1 */ "fork", /* 2 */ "read", /* 3 */ @@ -14,7 +14,7 @@ "time", /* 13 */ "mknod", /* 14 */ "chmod", /* 15 */ - "chown", /* 16 */ + "lchown", /* 16 */ "break", /* 17 */ "oldstat", /* 18 */ "lseek", /* 19 */ @@ -50,7 +50,7 @@ "geteuid", /* 49 */ "getegid", /* 50 */ "acct", /* 51 */ - "phys", /* 52 */ + "umount2", /* 52 */ "lock", /* 53 */ "ioctl", /* 54 */ "fcntl", /* 55 */ @@ -111,7 +111,7 @@ "iopl", /* 110 */ "vhangup", /* 111 */ "idle", /* 112 */ - "vm86", /* 113 */ + "vm86old", /* 113 */ "wait4", /* 114 */ "swapoff", /* 115 */ "sysinfo", /* 116 */ @@ -157,8 +157,34 @@ "sched_setscheduler", /* 156 */ "sched_getscheduler", /* 157 */ "sched_yield", /* 158 */ - "sched_get_priority_max",/* 159 */ - "sched_get_priority_min",/* 160 */ - "sched_rr_get_interval",/* 161 */ + "sched_get_priority_max", /* 159 */ + "sched_get_priority_min", /* 160 */ + "sched_rr_get_interval", /* 161 */ "nanosleep", /* 162 */ "mremap", /* 163 */ + "setresuid", /* 164 */ + "getresuid", /* 165 */ + "vm86", /* 166 */ + "query_module", /* 167 */ + "poll", /* 168 */ + "nfsservctl", /* 169 */ + "setresgid", /* 170 */ + "getresgid", /* 171 */ + "prctl", /* 172 */ + "rt_sigreturn", /* 173 */ + "rt_sigaction", /* 174 */ + "rt_sigprocmask", /* 175 */ + "rt_sigpending", /* 176 */ + "rt_sigtimedwait", /* 177 */ + "rt_sigqueueinfo", /* 178 */ + "rt_sigsuspend", /* 179 */ + "pread", /* 180 */ + "pwrite", /* 181 */ + "chown", /* 182 */ + "getcwd", /* 183 */ + "capget", /* 184 */ + "capset", /* 185 */ + "sigaltstack", /* 186 */ + "sendfile", /* 187 */ + "streams1", /* 188 */ + "streams2", /* 189 */ diff --git a/sysdeps/Linux/i386/trace.c b/sysdeps/Linux/i386/trace.c index 353eb87..15c0361 100644 --- a/sysdeps/Linux/i386/trace.c +++ b/sysdeps/Linux/i386/trace.c @@ -1,3 +1,7 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <sys/wait.h> #include <signal.h> diff --git a/sysdeps/Linux/m68k/Makefile b/sysdeps/Linux/m68k/Makefile new file mode 100644 index 0000000..2af3c25 --- /dev/null +++ b/sysdeps/Linux/m68k/Makefile @@ -0,0 +1,10 @@ +OBJ = breakpoint.o trace.o regs.o + +all: arch.o + +arch.o: $(OBJ) + $(LD) -r -o arch.o $(OBJ) + +clean: + $(RM) $(OBJ) arch.o + diff --git a/sysdeps/Linux/m68k/arch.h b/sysdeps/Linux/m68k/arch.h new file mode 100644 index 0000000..b701e29 --- /dev/null +++ b/sysdeps/Linux/m68k/arch.h @@ -0,0 +1,3 @@ +#define BREAKPOINT_VALUE {0x4e,0x4f} +#define BREAKPOINT_LENGTH 2 +#define DECR_PC_AFTER_BREAK 2 diff --git a/sysdeps/Linux/m68k/breakpoint.c b/sysdeps/Linux/m68k/breakpoint.c new file mode 100644 index 0000000..3bf427f --- /dev/null +++ b/sysdeps/Linux/m68k/breakpoint.c @@ -0,0 +1,28 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <sys/ptrace.h> +#include "ltrace.h" + +void insert_breakpoint(pid_t pid, struct breakpoint * sbp) +{ + int a; + + a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr, 0); + sbp->orig_value[0] = (a & 0xFF000000) >> 24; + sbp->orig_value[1] = (a & 0x00FF0000) >> 16; + a &= 0x0000FFFF; + a |= 0x4E4F0000; + ptrace(PTRACE_POKETEXT, pid, sbp->addr, a); +} + +void delete_breakpoint(pid_t pid, struct breakpoint * sbp) +{ + int a; + + a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr, 0); + a &= 0x0000FFFF; + a |= (sbp->orig_value[0] << 24) | (sbp->orig_value[1] << 16); + ptrace(PTRACE_POKETEXT, pid, sbp->addr, a); +} diff --git a/sysdeps/Linux/m68k/regs.c b/sysdeps/Linux/m68k/regs.c new file mode 100644 index 0000000..f046f19 --- /dev/null +++ b/sysdeps/Linux/m68k/regs.c @@ -0,0 +1,31 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <sys/types.h> +#include <sys/ptrace.h> +#include <asm/ptrace.h> + +#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR)) +# define PTRACE_PEEKUSER PTRACE_PEEKUSR +#endif + +#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR)) +# define PTRACE_POKEUSER PTRACE_POKEUSR +#endif + +void * get_instruction_pointer(pid_t pid) +{ + return (void *)ptrace(PTRACE_PEEKUSER, pid, 4*PT_PC, 0); +} + +void * get_stack_pointer(pid_t pid) +{ + return (void *)ptrace(PTRACE_PEEKUSER, pid, 4*PT_USP, 0); +} + +void * get_return_addr(pid_t pid, void * stack_pointer) +{ + return (void *)ptrace(PTRACE_PEEKTEXT, pid, stack_pointer, 0); +} + diff --git a/sysdeps/Linux/m68k/signalent.h b/sysdeps/Linux/m68k/signalent.h new file mode 100644 index 0000000..e2c1337 --- /dev/null +++ b/sysdeps/Linux/m68k/signalent.h @@ -0,0 +1,32 @@ + "SIG_0", /* 0 */ + "SIGHUP", /* 1 */ + "SIGINT", /* 2 */ + "SIGQUIT", /* 3 */ + "SIGILL", /* 4 */ + "SIGTRAP", /* 5 */ + "SIGABRT", /* 6 */ + "SIGBUS", /* 7 */ + "SIGFPE", /* 8 */ + "SIGKILL", /* 9 */ + "SIGUSR1", /* 10 */ + "SIGSEGV", /* 11 */ + "SIGUSR2", /* 12 */ + "SIGPIPE", /* 13 */ + "SIGALRM", /* 14 */ + "SIGTERM", /* 15 */ + "SIGSTKFLT", /* 16 */ + "SIGCHLD", /* 17 */ + "SIGCONT", /* 18 */ + "SIGSTOP", /* 19 */ + "SIGTSTP", /* 20 */ + "SIGTTIN", /* 21 */ + "SIGTTOU", /* 22 */ + "SIGURG", /* 23 */ + "SIGXCPU", /* 24 */ + "SIGXFSZ", /* 25 */ + "SIGVTALRM", /* 26 */ + "SIGPROF", /* 27 */ + "SIGWINCH", /* 28 */ + "SIGIO", /* 29 */ + "SIGPWR", /* 30 */ + "SIGUNUSED", /* 31 */ diff --git a/sysdeps/Linux/m68k/syscallent.h b/sysdeps/Linux/m68k/syscallent.h new file mode 100644 index 0000000..8475011 --- /dev/null +++ b/sysdeps/Linux/m68k/syscallent.h @@ -0,0 +1,189 @@ + "setup", /* 0 */ /* used only by init, to get system going */ + "exit", /* 1 */ + "fork", /* 2 */ + "read", /* 3 */ + "write", /* 4 */ + "open", /* 5 */ + "close", /* 6 */ + "waitpid", /* 7 */ + "creat", /* 8 */ + "link", /* 9 */ + "unlink", /* 10 */ + "execve", /* 11 */ + "chdir", /* 12 */ + "time", /* 13 */ + "mknod", /* 14 */ + "chmod", /* 15 */ + "chown", /* 16 */ + "break", /* 17 */ + "oldstat", /* 18 */ + "lseek", /* 19 */ + "getpid", /* 20 */ + "mount", /* 21 */ + "umount", /* 22 */ + "setuid", /* 23 */ + "getuid", /* 24 */ + "stime", /* 25 */ + "ptrace", /* 26 */ + "alarm", /* 27 */ + "oldfstat", /* 28 */ + "pause", /* 29 */ + "utime", /* 30 */ + "stty", /* 31 */ + "gtty", /* 32 */ + "access", /* 33 */ + "nice", /* 34 */ + "ftime", /* 35 */ + "sync", /* 36 */ + "kill", /* 37 */ + "rename", /* 38 */ + "mkdir", /* 39 */ + "rmdir", /* 40 */ + "dup", /* 41 */ + "pipe", /* 42 */ + "times", /* 43 */ + "prof", /* 44 */ + "brk", /* 45 */ + "setgid", /* 46 */ + "getgid", /* 47 */ + "signal", /* 48 */ + "geteuid", /* 49 */ + "getegid", /* 50 */ + "acct", /* 51 */ + "umount2", /* 52 */ + "lock", /* 53 */ + "ioctl", /* 54 */ + "fcntl", /* 55 */ + "mpx", /* 56 */ + "setpgid", /* 57 */ + "ulimit", /* 58 */ + "oldolduname", /* 59 */ + "umask", /* 60 */ + "chroot", /* 61 */ + "ustat", /* 62 */ + "dup2", /* 63 */ + "getppid", /* 64 */ + "getpgrp", /* 65 */ + "setsid", /* 66 */ + "sigaction", /* 67 */ + "sgetmask", /* 68 */ + "ssetmask", /* 69 */ + "setreuid", /* 70 */ + "setregid", /* 71 */ + "sigsuspend", /* 72 */ + "sigpending", /* 73 */ + "sethostname", /* 74 */ + "setrlimit", /* 75 */ + "getrlimit", /* 76 */ + "getrusage", /* 77 */ + "gettimeofday", /* 78 */ + "settimeofday", /* 79 */ + "getgroups", /* 80 */ + "setgroups", /* 81 */ + "select", /* 82 */ + "symlink", /* 83 */ + "oldlstat", /* 84 */ + "readlink", /* 85 */ + "uselib", /* 86 */ + "swapon", /* 87 */ + "reboot", /* 88 */ + "readdir", /* 89 */ + "mmap", /* 90 */ + "munmap", /* 91 */ + "truncate", /* 92 */ + "ftruncate", /* 93 */ + "fchmod", /* 94 */ + "fchown", /* 95 */ + "getpriority", /* 96 */ + "setpriority", /* 97 */ + "profil", /* 98 */ + "statfs", /* 99 */ + "fstatfs", /* 100 */ + "ioperm", /* 101 */ + "socketcall", /* 102 */ + "syslog", /* 103 */ + "setitimer", /* 104 */ + "getitimer", /* 105 */ + "stat", /* 106 */ + "lstat", /* 107 */ + "fstat", /* 108 */ + "olduname", /* 109 */ + "iopl", /* 110 */ /* not supported */ + "vhangup", /* 111 */ + "idle", /* 112 */ + "vm86", /* 113 */ /* not supported */ + "wait4", /* 114 */ + "swapoff", /* 115 */ + "sysinfo", /* 116 */ + "ipc", /* 117 */ + "fsync", /* 118 */ + "sigreturn", /* 119 */ + "clone", /* 120 */ + "setdomainname", /* 121 */ + "uname", /* 122 */ + "cacheflush", /* 123 */ + "adjtimex", /* 124 */ + "mprotect", /* 125 */ + "sigprocmask", /* 126 */ + "create_module", /* 127 */ + "init_module", /* 128 */ + "delete_module", /* 129 */ + "get_kernel_syms", /* 130 */ + "quotactl", /* 131 */ + "getpgid", /* 132 */ + "fchdir", /* 133 */ + "bdflush", /* 134 */ + "sysfs", /* 135 */ + "personality", /* 136 */ + "afs_syscall", /* 137 */ /* Syscall for Andrew File System */ + "setfsuid", /* 138 */ + "setfsgid", /* 139 */ + "_llseek", /* 140 */ + "getdents", /* 141 */ + "_newselect", /* 142 */ + "flock", /* 143 */ + "msync", /* 144 */ + "readv", /* 145 */ + "writev", /* 146 */ + "getsid", /* 147 */ + "fdatasync", /* 148 */ + "_sysctl", /* 149 */ + "mlock", /* 150 */ + "munlock", /* 151 */ + "mlockall", /* 152 */ + "munlockall", /* 153 */ + "sched_setparam", /* 154 */ + "sched_getparam", /* 155 */ + "sched_setscheduler", /* 156 */ + "sched_getscheduler", /* 157 */ + "sched_yield", /* 158 */ + "sched_get_priority_max", /* 159 */ + "sched_get_priority_min", /* 160 */ + "sched_rr_get_interval", /* 161 */ + "nanosleep", /* 162 */ + "mremap", /* 163 */ + "setresuid", /* 164 */ + "getresuid", /* 165 */ + "query_module", /* 167 */ + "poll", /* 168 */ + "nfsservctl", /* 169 */ + "setresgid", /* 170 */ + "getresgid", /* 171 */ + "prctl", /* 172 */ + "rt_sigreturn", /* 173 */ + "rt_sigaction", /* 174 */ + "rt_sigprocmask", /* 175 */ + "rt_sigpending", /* 176 */ + "rt_sigtimedwait", /* 177 */ + "rt_sigqueueinfo", /* 178 */ + "rt_sigsuspend", /* 179 */ + "pread", /* 180 */ + "pwrite", /* 181 */ + "lchown", /* 182 */ + "getcwd", /* 183 */ + "capget", /* 184 */ + "capset", /* 185 */ + "sigaltstack", /* 186 */ + "sendfile", /* 187 */ + "streams1", /* 188 */ /* some people actually want it */ + "streams2", /* 189 */ /* some people actually want it */ diff --git a/sysdeps/Linux/m68k/syscallent.h- b/sysdeps/Linux/m68k/syscallent.h- new file mode 100644 index 0000000..492c3db --- /dev/null +++ b/sysdeps/Linux/m68k/syscallent.h- @@ -0,0 +1,190 @@ + "setup", /* 0 */ + "exit", /* 1 */ + "fork", /* 2 */ + "read", /* 3 */ + "write", /* 4 */ + "open", /* 5 */ + "close", /* 6 */ + "waitpid", /* 7 */ + "creat", /* 8 */ + "link", /* 9 */ + "unlink", /* 10 */ + "execve", /* 11 */ + "chdir", /* 12 */ + "time", /* 13 */ + "mknod", /* 14 */ + "chmod", /* 15 */ + "chown", /* 16 */ + "break", /* 17 */ + "oldstat", /* 18 */ + "lseek", /* 19 */ + "getpid", /* 20 */ + "mount", /* 21 */ + "umount", /* 22 */ + "setuid", /* 23 */ + "getuid", /* 24 */ + "stime", /* 25 */ + "ptrace", /* 26 */ + "alarm", /* 27 */ + "oldfstat", /* 28 */ + "pause", /* 29 */ + "utime", /* 30 */ + "stty", /* 31 */ + "gtty", /* 32 */ + "access", /* 33 */ + "nice", /* 34 */ + "ftime", /* 35 */ + "sync", /* 36 */ + "kill", /* 37 */ + "rename", /* 38 */ + "mkdir", /* 39 */ + "rmdir", /* 40 */ + "dup", /* 41 */ + "pipe", /* 42 */ + "times", /* 43 */ + "prof", /* 44 */ + "brk", /* 45 */ + "setgid", /* 46 */ + "getgid", /* 47 */ + "signal", /* 48 */ + "geteuid", /* 49 */ + "getegid", /* 50 */ + "acct", /* 51 */ + "umount2", /* 52 */ + "lock", /* 53 */ + "ioctl", /* 54 */ + "fcntl", /* 55 */ + "mpx", /* 56 */ + "setpgid", /* 57 */ + "ulimit", /* 58 */ + "oldolduname", /* 59 */ + "umask", /* 60 */ + "chroot", /* 61 */ + "ustat", /* 62 */ + "dup2", /* 63 */ + "getppid", /* 64 */ + "getpgrp", /* 65 */ + "setsid", /* 66 */ + "sigaction", /* 67 */ + "sgetmask", /* 68 */ + "ssetmask", /* 69 */ + "setreuid", /* 70 */ + "setregid", /* 71 */ + "sigsuspend", /* 72 */ + "sigpending", /* 73 */ + "sethostname", /* 74 */ + "setrlimit", /* 75 */ + "getrlimit", /* 76 */ + "getrusage", /* 77 */ + "gettimeofday", /* 78 */ + "settimeofday", /* 79 */ + "getgroups", /* 80 */ + "setgroups", /* 81 */ + "select", /* 82 */ + "symlink", /* 83 */ + "oldlstat", /* 84 */ + "readlink", /* 85 */ + "uselib", /* 86 */ + "swapon", /* 87 */ + "reboot", /* 88 */ + "readdir", /* 89 */ + "mmap", /* 90 */ + "munmap", /* 91 */ + "truncate", /* 92 */ + "ftruncate", /* 93 */ + "fchmod", /* 94 */ + "fchown", /* 95 */ + "getpriority", /* 96 */ + "setpriority", /* 97 */ + "profil", /* 98 */ + "statfs", /* 99 */ + "fstatfs", /* 100 */ + "ioperm", /* 101 */ + "socketcall", /* 102 */ + "syslog", /* 103 */ + "setitimer", /* 104 */ + "getitimer", /* 105 */ + "stat", /* 106 */ + "lstat", /* 107 */ + "fstat", /* 108 */ + "olduname", /* 109 */ + "(NONE)", /* 110 */ + "vhangup", /* 111 */ + "idle", /* 112 */ + "(NONE)", /* 113 */ + "wait4", /* 114 */ + "swapoff", /* 115 */ + "sysinfo", /* 116 */ + "ipc", /* 117 */ + "fsync", /* 118 */ + "sigreturn", /* 119 */ + "clone", /* 120 */ + "setdomainname", /* 121 */ + "uname", /* 122 */ + "cacheflush", /* 123 */ + "adjtimex", /* 124 */ + "mprotect", /* 125 */ + "sigprocmask", /* 126 */ + "create_module", /* 127 */ + "init_module", /* 128 */ + "delete_module", /* 129 */ + "get_kernel_syms", /* 130 */ + "quotactl", /* 131 */ + "getpgid", /* 132 */ + "fchdir", /* 133 */ + "bdflush", /* 134 */ + "sysfs", /* 135 */ + "personality", /* 136 */ + "afs_syscall", /* 137 */ + "setfsuid", /* 138 */ + "setfsgid", /* 139 */ + "_llseek", /* 140 */ + "getdents", /* 141 */ + "_newselect", /* 142 */ + "flock", /* 143 */ + "msync", /* 144 */ + "readv", /* 145 */ + "writev", /* 146 */ + "getsid", /* 147 */ + "fdatasync", /* 148 */ + "_sysctl", /* 149 */ + "mlock", /* 150 */ + "munlock", /* 151 */ + "mlockall", /* 152 */ + "munlockall", /* 153 */ + "sched_setparam", /* 154 */ + "sched_getparam", /* 155 */ + "sched_setscheduler", /* 156 */ + "sched_getscheduler", /* 157 */ + "sched_yield", /* 158 */ + "sched_get_priority_max", /* 159 */ + "sched_get_priority_min", /* 160 */ + "sched_rr_get_interval", /* 161 */ + "nanosleep", /* 162 */ + "mremap", /* 163 */ + "setresuid", /* 164 */ + "getresuid", /* 165 */ + "(NONE)", /* 166 */ + "query_module", /* 167 */ + "poll", /* 168 */ + "nfsservctl", /* 169 */ + "setresgid", /* 170 */ + "getresgid", /* 171 */ + "prctl", /* 172 */ + "rt_sigreturn", /* 173 */ + "rt_sigaction", /* 174 */ + "rt_sigprocmask", /* 175 */ + "rt_sigpending", /* 176 */ + "rt_sigtimedwait", /* 177 */ + "rt_sigqueueinfo", /* 178 */ + "rt_sigsuspend", /* 179 */ + "pread", /* 180 */ + "pwrite", /* 181 */ + "lchown", /* 182 */ + "getcwd", /* 183 */ + "capget", /* 184 */ + "capset", /* 185 */ + "sigaltstack", /* 186 */ + "sendfile", /* 187 */ + "streams1", /* 188 */ + "streams2", /* 189 */ diff --git a/sysdeps/Linux/m68k/trace.c b/sysdeps/Linux/m68k/trace.c new file mode 100644 index 0000000..0485860 --- /dev/null +++ b/sysdeps/Linux/m68k/trace.c @@ -0,0 +1,103 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <sys/types.h> +#include <sys/wait.h> +#include <signal.h> +#include <sys/ptrace.h> +#include <asm/ptrace.h> + +#include "ltrace.h" + +#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR)) +# define PTRACE_PEEKUSER PTRACE_PEEKUSR +#endif + +#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR)) +# define PTRACE_POKEUSER PTRACE_POKEUSR +#endif + +/* Returns 1 if syscall, 2 if sysret, 0 otherwise. + */ +int syscall_p(struct process * proc, int status, int * sysnum) +{ + if (WIFSTOPPED(status) && WSTOPSIG(status)==SIGTRAP) { + *sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_ORIG_D0, 0); + if (*sysnum == -1) return 0; + if (*sysnum>=0) { + if (proc->current_syscall!=*sysnum) { + return 1; + } else { + return 2; + } + } + } + return 0; +} + +void continue_after_breakpoint(struct process *proc, struct breakpoint * sbp, int delete_it) +{ + delete_breakpoint(proc->pid, sbp); + ptrace(PTRACE_POKEUSER, proc->pid, 4*PT_PC, sbp->addr); + if (delete_it) { + continue_process(proc->pid); + } else { + proc->breakpoint_being_enabled = sbp; + ptrace(PTRACE_SINGLESTEP, proc->pid, 0, 0); + } +} + +long gimme_arg(enum tof type, struct process * proc, int arg_num) +{ + if (arg_num==-1) { /* return value */ + return ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_D0, 0); + } + + if (type==LT_TOF_FUNCTION) { + return ptrace(PTRACE_PEEKTEXT, proc->pid, proc->stack_pointer+4*(arg_num+1), 0); + } else if (type==LT_TOF_SYSCALL) { +#if 0 + switch(arg_num) { + case 0: return ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_D1, 0); + case 1: return ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_D2, 0); + case 2: return ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_D3, 0); + case 3: return ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_D4, 0); + case 4: return ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_D5, 0); + default: + fprintf(stderr, "gimme_arg called with wrong arguments\n"); + exit(2); + } +#else + /* That hack works on m68k, too */ + return ptrace(PTRACE_PEEKUSER, proc->pid, 4*arg_num, 0); +#endif + } else { + fprintf(stderr, "gimme_arg called with wrong arguments\n"); + exit(1); + } + + return 0; +} + +int umovestr(struct process * proc, void * addr, int len, void * laddr) +{ + long a; + int i; + int offset=0; + + while(offset<len) { + a = ptrace(PTRACE_PEEKTEXT, proc->pid, addr+offset, 0); + for(i=0; i<sizeof(long); i++) { + if (((char*)&a)[i] && offset+i < len) { + *(char *)(laddr+offset+i) = ((char*)&a)[i]; + } else { + *(char *)(laddr+offset+i) = '\0'; + return 0; + } + } + offset += sizeof(long); + } + *(char *)(laddr+offset) = '\0'; + return 0; +} diff --git a/sysdeps/Linux/mksyscalls b/sysdeps/Linux/mksyscalls new file mode 100755 index 0000000..a3358be --- /dev/null +++ b/sysdeps/Linux/mksyscalls @@ -0,0 +1,36 @@ +#!/usr/bin/awk -f + +# hack expression to generate arch/syscallent.h from <asm/unistd.h> +# It reads from stdin and writes to stdout +# resulting blurb still needs editing! + +BEGIN { + max=0; +} + +{ + if (($1 ~ /^#define$/) && (substr($2,1,5) ~ /^__NR_$/) && ($3>=0) && ($3<=1000)) { + SYSCALL[$3]=substr($2,6); + if ($3 > max) { + max=$3; + } + } +} + +END { + for(i=0; i<=max; i++) { + if (SYSCALL[i]) { + if (length(SYSCALL[i])<5) { + pad="\t\t\t"; + } else if (length(SYSCALL[i])<13) { + pad="\t\t"; + } else { + pad="\t"; + } + printf("\t\"%s\",%s/* %d */\n", SYSCALL[i], pad, i); + } else { + printf("\t\"(NONE)\",\t\t/* %d */\n", i); + } + } +} + diff --git a/sysdeps/Linux/proc.c b/sysdeps/Linux/proc.c index b3f7d66..8390136 100644 --- a/sysdeps/Linux/proc.c +++ b/sysdeps/Linux/proc.c @@ -1,3 +1,7 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <stdio.h> #include <string.h> diff --git a/sysdeps/Linux/sparc/arch.h b/sysdeps/Linux/sparc/arch.h index 83b437d..1173591 100644 --- a/sysdeps/Linux/sparc/arch.h +++ b/sysdeps/Linux/sparc/arch.h @@ -1,5 +1,3 @@ -#include <sys/types.h> - #define BREAKPOINT_VALUE {0x91, 0xd0, 0x20, 0x01} #define BREAKPOINT_LENGTH 4 #define DECR_PC_AFTER_BREAK 0 diff --git a/sysdeps/Linux/sparc/breakpoint.c b/sysdeps/Linux/sparc/breakpoint.c index c0a700b..250e511 100644 --- a/sysdeps/Linux/sparc/breakpoint.c +++ b/sysdeps/Linux/sparc/breakpoint.c @@ -1,7 +1,11 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/ptrace.h> #include "ltrace.h" -void insert_breakpoint(int pid, struct breakpoint * sbp) +void insert_breakpoint(pid_t pid, struct breakpoint * sbp) { unsigned long a; @@ -11,7 +15,7 @@ void insert_breakpoint(int pid, struct breakpoint * sbp) ptrace(PTRACE_POKETEXT, pid, sbp->addr, a); } -void delete_breakpoint(int pid, struct breakpoint * sbp) +void delete_breakpoint(pid_t pid, struct breakpoint * sbp) { ptrace(PTRACE_POKETEXT, pid, sbp->addr, *(long *)sbp->orig_value); } diff --git a/sysdeps/Linux/sparc/regs.c b/sysdeps/Linux/sparc/regs.c index 73e9e42..aaa81a9 100644 --- a/sysdeps/Linux/sparc/regs.c +++ b/sysdeps/Linux/sparc/regs.c @@ -1,18 +1,22 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <sys/ptrace.h> -int get_instruction_pointer(pid_t pid) +void * get_instruction_pointer(pid_t pid) { - return ptrace(PTRACE_PEEKUSER, pid, PT_PC, 0); + return (void *)ptrace(PTRACE_PEEKUSER, pid, PT_PC, 0); } -int get_stack_pointer(pid_t pid) +void * get_stack_pointer(pid_t pid) { - return -1; + return (void *)-1; } -int get_return_addr(pid_t pid, void * stack_pointer) +void * get_return_addr(pid_t pid, void * stack_pointer) { - return -1; + return (void *)-1; } diff --git a/sysdeps/Linux/sparc/syscallent.h b/sysdeps/Linux/sparc/syscallent.h index e69de29..432a400 100644 --- a/sysdeps/Linux/sparc/syscallent.h +++ b/sysdeps/Linux/sparc/syscallent.h @@ -0,0 +1,256 @@ + "setup", /* 0 */ + "exit", /* 1 */ + "fork", /* 2 */ + "read", /* 3 */ + "write", /* 4 */ + "open", /* 5 */ + "close", /* 6 */ + "wait4", /* 7 */ + "creat", /* 8 */ + "link", /* 9 */ + "unlink", /* 10 */ + "execv", /* 11 */ + "chdir", /* 12 */ + "(NONE)", /* 13 */ + "mknod", /* 14 */ + "chmod", /* 15 */ + "chown", /* 16 */ + "brk", /* 17 */ + "(NONE)", /* 18 */ + "lseek", /* 19 */ + "getpid", /* 20 */ + "capget", /* 21 */ + "capset", /* 22 */ + "setuid", /* 23 */ + "getuid", /* 24 */ + "(NONE)", /* 25 */ + "ptrace", /* 26 */ + "alarm", /* 27 */ + "sigaltstack", /* 28 */ + "pause", /* 29 */ + "utime", /* 30 */ + "stty", /* 31 */ + "gtty", /* 32 */ + "access", /* 33 */ + "nice", /* 34 */ + "ftime", /* 35 */ + "sync", /* 36 */ + "kill", /* 37 */ + "stat", /* 38 */ + "sendfile", /* 39 */ + "lstat", /* 40 */ + "dup", /* 41 */ + "pipe", /* 42 */ + "times", /* 43 */ + "profil", /* 44 */ + "(NONE)", /* 45 */ + "setgid", /* 46 */ + "getgid", /* 47 */ + "signal", /* 48 */ + "geteuid", /* 49 */ + "getegid", /* 50 */ + "acct", /* 51 */ + "(NONE)", /* 52 */ + "mctl", /* 53 */ + "ioctl", /* 54 */ + "reboot", /* 55 */ + "(NONE)", /* 56 */ + "symlink", /* 57 */ + "readlink", /* 58 */ + "execve", /* 59 */ + "umask", /* 60 */ + "chroot", /* 61 */ + "fstat", /* 62 */ + "(NONE)", /* 63 */ + "getpagesize", /* 64 */ + "msync", /* 65 */ + "(NONE)", /* 66 */ + "pread", /* 67 */ + "pwrite", /* 68 */ + "sbrk", /* 69 */ + "sstk", /* 70 */ + "mmap", /* 71 */ + "vadvise", /* 72 */ + "munmap", /* 73 */ + "mprotect", /* 74 */ + "madvise", /* 75 */ + "vhangup", /* 76 */ + "(NONE)", /* 77 */ + "mincore", /* 78 */ + "getgroups", /* 79 */ + "setgroups", /* 80 */ + "getpgrp", /* 81 */ + "setpgrp", /* 82 */ + "setitimer", /* 83 */ + "(NONE)", /* 84 */ + "swapon", /* 85 */ + "getitimer", /* 86 */ + "gethostname", /* 87 */ + "sethostname", /* 88 */ + "getdtablesize", /* 89 */ + "dup2", /* 90 */ + "getdopt", /* 91 */ + "fcntl", /* 92 */ + "select", /* 93 */ + "setdopt", /* 94 */ + "fsync", /* 95 */ + "setpriority", /* 96 */ + "socket", /* 97 */ + "connect", /* 98 */ + "accept", /* 99 */ + "getpriority", /* 100 */ + "rt_sigreturn", /* 101 */ + "rt_sigaction", /* 102 */ + "rt_sigprocmask", /* 103 */ + "rt_sigpending", /* 104 */ + "rt_sigtimedwait", /* 105 */ + "rt_sigqueueinfo", /* 106 */ + "rt_sigsuspend", /* 107 */ + "sigvec", /* 108 */ + "sigblock", /* 109 */ + "sigsetmask", /* 110 */ + "sigpause", /* 111 */ + "sigstack", /* 112 */ + "recvmsg", /* 113 */ + "sendmsg", /* 114 */ + "vtrace", /* 115 */ + "gettimeofday", /* 116 */ + "getrusage", /* 117 */ + "getsockopt", /* 118 */ + "getcwd", /* 119 */ + "readv", /* 120 */ + "writev", /* 121 */ + "settimeofday", /* 122 */ + "fchown", /* 123 */ + "fchmod", /* 124 */ + "recvfrom", /* 125 */ + "setreuid", /* 126 */ + "setregid", /* 127 */ + "rename", /* 128 */ + "truncate", /* 129 */ + "ftruncate", /* 130 */ + "flock", /* 131 */ + "(NONE)", /* 132 */ + "sendto", /* 133 */ + "shutdown", /* 134 */ + "socketpair", /* 135 */ + "mkdir", /* 136 */ + "rmdir", /* 137 */ + "utimes", /* 138 */ + "(NONE)", /* 139 */ + "adjtime", /* 140 */ + "getpeername", /* 141 */ + "gethostid", /* 142 */ + "(NONE)", /* 143 */ + "getrlimit", /* 144 */ + "setrlimit", /* 145 */ + "killpg", /* 146 */ + "prctl", /* 147 */ + "(NONE)", /* 148 */ + "(NONE)", /* 149 */ + "getsockname", /* 150 */ + "getmsg", /* 151 */ + "putmsg", /* 152 */ + "poll", /* 153 */ + "(NONE)", /* 154 */ + "nfssvc", /* 155 */ + "getdirentries", /* 156 */ + "statfs", /* 157 */ + "fstatfs", /* 158 */ + "umount", /* 159 */ + "async_daemon", /* 160 */ + "getfh", /* 161 */ + "getdomainname", /* 162 */ + "setdomainname", /* 163 */ + "(NONE)", /* 164 */ + "quotactl", /* 165 */ + "exportfs", /* 166 */ + "mount", /* 167 */ + "ustat", /* 168 */ + "semsys", /* 169 */ + "msgsys", /* 170 */ + "shmsys", /* 171 */ + "auditsys", /* 172 */ + "rfssys", /* 173 */ + "getdents", /* 174 */ + "setsid", /* 175 */ + "fchdir", /* 176 */ + "fchroot", /* 177 */ + "vpixsys", /* 178 */ + "aioread", /* 179 */ + "aiowrite", /* 180 */ + "aiowait", /* 181 */ + "aiocancel", /* 182 */ + "sigpending", /* 183 */ + "query_module", /* 184 */ + "setpgid", /* 185 */ + "pathconf", /* 186 */ + "fpathconf", /* 187 */ + "sysconf", /* 188 */ + "uname", /* 189 */ + "init_module", /* 190 */ + "personality", /* 191 */ + "prof", /* 192 */ + "break", /* 193 */ + "lock", /* 194 */ + "mpx", /* 195 */ + "ulimit", /* 196 */ + "getppid", /* 197 */ + "sigaction", /* 198 */ + "sgetmask", /* 199 */ + "ssetmask", /* 200 */ + "sigsuspend", /* 201 */ + "oldlstat", /* 202 */ + "uselib", /* 203 */ + "readdir", /* 204 */ + "ioperm", /* 205 */ + "socketcall", /* 206 */ + "syslog", /* 207 */ + "olduname", /* 208 */ + "iopl", /* 209 */ + "idle", /* 210 */ + "vm86", /* 211 */ + "waitpid", /* 212 */ + "swapoff", /* 213 */ + "sysinfo", /* 214 */ + "ipc", /* 215 */ + "sigreturn", /* 216 */ + "clone", /* 217 */ + "modify_ldt", /* 218 */ + "adjtimex", /* 219 */ + "sigprocmask", /* 220 */ + "create_module", /* 221 */ + "delete_module", /* 222 */ + "get_kernel_syms", /* 223 */ + "getpgid", /* 224 */ + "bdflush", /* 225 */ + "sysfs", /* 226 */ + "afs_syscall", /* 227 */ + "setfsuid", /* 228 */ + "setfsgid", /* 229 */ + "_newselect", /* 230 */ + "time", /* 231 */ + "oldstat", /* 232 */ + "stime", /* 233 */ + "oldfstat", /* 234 */ + "phys", /* 235 */ + "_llseek", /* 236 */ + "mlock", /* 237 */ + "munlock", /* 238 */ + "mlockall", /* 239 */ + "munlockall", /* 240 */ + "sched_setparam", /* 241 */ + "sched_getparam", /* 242 */ + "sched_setscheduler", /* 243 */ + "sched_getscheduler", /* 244 */ + "sched_yield", /* 245 */ + "sched_get_priority_max", /* 246 */ + "sched_get_priority_min", /* 247 */ + "sched_rr_get_interval", /* 248 */ + "nanosleep", /* 249 */ + "mremap", /* 250 */ + "_sysctl", /* 251 */ + "getsid", /* 252 */ + "fdatasync", /* 253 */ + "nfsservctl", /* 254 */ + "aplib", /* 255 */ diff --git a/sysdeps/Linux/sparc/trace.c b/sysdeps/Linux/sparc/trace.c index 4671877..1452d94 100644 --- a/sysdeps/Linux/sparc/trace.c +++ b/sysdeps/Linux/sparc/trace.c @@ -1,3 +1,7 @@ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <sys/wait.h> #include <signal.h> |