aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/linux-gnu
diff options
context:
space:
mode:
authorJuan Cespedes <cespedes@debian.org>2002-03-27 00:22:23 +0100
committerJuan Cespedes <cespedes@debian.org>2002-03-27 00:22:23 +0100
commitf1bfe203f5f1c0e11a614f9d593a68406f5cb47e (patch)
tree6586ca2df6603121b7645bd66c9a32eb23ee3d1a /sysdeps/linux-gnu
parent8f8282f72eaeadc5419cd5470100e8dcaba5b7fd (diff)
downloadltrace-f1bfe203f5f1c0e11a614f9d593a68406f5cb47e.tar.gz
Version 0.3.24
* Fixed 2 minor buffer overflows (closes: Bug#130746) * Obey --prefix, --sysconfdir, --mandir options in configure * Adding powerpc support (doesn't work yet) (Anton Blanchard <anton@linuxcare.com.au>)
Diffstat (limited to 'sysdeps/linux-gnu')
-rw-r--r--sysdeps/linux-gnu/ppc/Makefile10
-rw-r--r--sysdeps/linux-gnu/ppc/arch.h3
-rw-r--r--sysdeps/linux-gnu/ppc/arch.obin0 -> 32104 bytes
-rw-r--r--sysdeps/linux-gnu/ppc/regs.c35
-rw-r--r--sysdeps/linux-gnu/ppc/regs.obin0 -> 9608 bytes
-rw-r--r--sysdeps/linux-gnu/ppc/signalent.h32
-rw-r--r--sysdeps/linux-gnu/ppc/syscallent.h208
-rw-r--r--sysdeps/linux-gnu/ppc/trace.c61
-rw-r--r--sysdeps/linux-gnu/ppc/trace.obin0 -> 23252 bytes
9 files changed, 349 insertions, 0 deletions
diff --git a/sysdeps/linux-gnu/ppc/Makefile b/sysdeps/linux-gnu/ppc/Makefile
new file mode 100644
index 0000000..4b347a5
--- /dev/null
+++ b/sysdeps/linux-gnu/ppc/Makefile
@@ -0,0 +1,10 @@
+OBJ = 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-gnu/ppc/arch.h b/sysdeps/linux-gnu/ppc/arch.h
new file mode 100644
index 0000000..e04fe5b
--- /dev/null
+++ b/sysdeps/linux-gnu/ppc/arch.h
@@ -0,0 +1,3 @@
+#define BREAKPOINT_VALUE { 0xf7, 0xe0, 0x00, 0x08 }
+#define BREAKPOINT_LENGTH 4
+#define DECR_PC_AFTER_BREAK 0
diff --git a/sysdeps/linux-gnu/ppc/arch.o b/sysdeps/linux-gnu/ppc/arch.o
new file mode 100644
index 0000000..312a4f8
--- /dev/null
+++ b/sysdeps/linux-gnu/ppc/arch.o
Binary files differ
diff --git a/sysdeps/linux-gnu/ppc/regs.c b/sysdeps/linux-gnu/ppc/regs.c
new file mode 100644
index 0000000..1eb51e5
--- /dev/null
+++ b/sysdeps/linux-gnu/ppc/regs.c
@@ -0,0 +1,35 @@
+#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_NIP, 0);
+}
+
+void
+set_instruction_pointer(pid_t pid, long addr) {
+ ptrace(PTRACE_POKEUSER, pid, 4*PT_NIP, addr);
+}
+
+void *
+get_stack_pointer(pid_t pid) {
+ return (void *)ptrace(PTRACE_PEEKUSER, pid, 4*PT_R1, 0);
+}
+
+void *
+get_return_addr(pid_t pid, void * stack_pointer) {
+ return (void *)ptrace(PTRACE_PEEKTEXT, pid, 4*PT_LNK, 0);
+}
diff --git a/sysdeps/linux-gnu/ppc/regs.o b/sysdeps/linux-gnu/ppc/regs.o
new file mode 100644
index 0000000..c8cc474
--- /dev/null
+++ b/sysdeps/linux-gnu/ppc/regs.o
Binary files differ
diff --git a/sysdeps/linux-gnu/ppc/signalent.h b/sysdeps/linux-gnu/ppc/signalent.h
new file mode 100644
index 0000000..5395f82
--- /dev/null
+++ b/sysdeps/linux-gnu/ppc/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 */
+ "SIGSYS", /* 31 */
diff --git a/sysdeps/linux-gnu/ppc/syscallent.h b/sysdeps/linux-gnu/ppc/syscallent.h
new file mode 100644
index 0000000..40c8ba1
--- /dev/null
+++ b/sysdeps/linux-gnu/ppc/syscallent.h
@@ -0,0 +1,208 @@
+ "0", /* 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 */
+ "lchown", /* 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 */
+ "vhangup", /* 111 */
+ "idle", /* 112 */
+ "vm86", /* 113 */
+ "wait4", /* 114 */
+ "swapoff", /* 115 */
+ "sysinfo", /* 116 */
+ "ipc", /* 117 */
+ "fsync", /* 118 */
+ "sigreturn", /* 119 */
+ "clone", /* 120 */
+ "setdomainname", /* 121 */
+ "uname", /* 122 */
+ "modify_ldt", /* 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 */
+ "query_module", /* 166 */
+ "poll", /* 167 */
+ "nfsservctl", /* 168 */
+ "setresgid", /* 169 */
+ "getresgid", /* 170 */
+ "prctl", /* 171 */
+ "rt_sigreturn", /* 172 */
+ "rt_sigaction", /* 173 */
+ "rt_sigprocmask", /* 174 */
+ "rt_sigpending", /* 175 */
+ "rt_sigtimedwait", /* 176 */
+ "rt_sigqueueinfo", /* 177 */
+ "rt_sigsuspend", /* 178 */
+ "pread", /* 179 */
+ "pwrite", /* 180 */
+ "chown", /* 181 */
+ "getcwd", /* 182 */
+ "capget", /* 183 */
+ "capset", /* 184 */
+ "sigaltstack", /* 185 */
+ "sendfile", /* 186 */
+ "getpmsg", /* 187 */
+ "putpmsg", /* 188 */
+ "vfork", /* 189 */
+ "ugetrlimit", /* 190 */
+ "readahead", /* 191 */
+ "mmap2", /* 192 */
+ "truncate64", /* 193 */
+ "ftruncate64", /* 194 */
+ "stat64", /* 195 */
+ "lstat64", /* 196 */
+ "fstat64", /* 197 */
+ "pciconfig_read", /* 198 */
+ "pciconfig_write", /* 199 */
+ "pciconfig_iobase", /* 200 */
+ "multiplexer", /* 201 */
+ "getdents64", /* 202 */
+ "pivot_root", /* 203 */
+ "fcntl64", /* 204 */
+ "madvise", /* 205 */
+ "mincore", /* 206 */
+ "gettid", /* 207 */
diff --git a/sysdeps/linux-gnu/ppc/trace.c b/sysdeps/linux-gnu/ppc/trace.c
new file mode 100644
index 0000000..8e4135f
--- /dev/null
+++ b/sysdeps/linux-gnu/ppc/trace.c
@@ -0,0 +1,61 @@
+#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.
+ */
+#define SYSCALL_INSN 0x44000002
+int
+syscall_p(struct process * proc, int status, int * sysnum) {
+ if (WIFSTOPPED(status) && WSTOPSIG(status)==SIGTRAP) {
+ int pc = ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_NIP, 0);
+ int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc-4, 0);
+
+ if (insn == SYSCALL_INSN) {
+ *sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_RO, 0);
+ if (proc->callstack_depth > 0 &&
+ proc->callstack[proc->callstack_depth-1].is_syscall) {
+ return 2;
+ }
+ if (*sysnum >= 0 && *sysnum <= 255) {
+ return 1;
+ }
+ }
+ }
+ return 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_R3, 0);
+ }
+
+ if (type==LT_TOF_FUNCTION || type==LT_TOF_SYSCALL) {
+ if (arg_num < 8) {
+ return ptrace(PTRACE_PEEKUSER, proc->pid, 4*(arg_num+PT_R3), 0);
+ } else {
+ return ptrace(PTRACE_PEEKDATA, proc->pid, proc->stack_pointer+4*(arg_num-8), 0); /* Check */
+ }
+ } else {
+ fprintf(stderr, "gimme_arg called with wrong arguments\n");
+ exit(1);
+ }
+ return 0;
+}
diff --git a/sysdeps/linux-gnu/ppc/trace.o b/sysdeps/linux-gnu/ppc/trace.o
new file mode 100644
index 0000000..aafcf69
--- /dev/null
+++ b/sysdeps/linux-gnu/ppc/trace.o
Binary files differ