diff options
author | Juan Cespedes <cespedes@debian.org> | 1999-08-30 19:34:50 +0200 |
---|---|---|
committer | Juan Cespedes <cespedes@debian.org> | 1999-08-30 19:34:50 +0200 |
commit | 1b9cfd6ad305ad909e8ff17139111a7c78f01464 (patch) | |
tree | 352a033cfd2ab78eab367c81f30b46ec5b886947 /sysdeps/linux-gnu/m68k | |
parent | e3eb9aa37086f16c0c8c2778dcd8020a39a92564 (diff) | |
download | ltrace-1b9cfd6ad305ad909e8ff17139111a7c78f01464.tar.gz |
Version: 0.3.8
* glibc-2.1 does no longer need `_GNU_SOURCE' defined to use <getopt.h>
* Changed description of package; adopted Red Hat's one
(thanks to whoever wrote it)
* Close all the file descriptors used before executing program (close-on-exec)
* Updated copyright file for new location /usr/share/common-licenses/GPL.
* Used GNU autoconf instead of "uname" to guess host system type
* Install man page in /usr/share/man instead of /usr/man
* Added a few functions to /etc/ltrace.conf
* Updated list of syscalls and signals to linux-2.2.12
* Fixed bugs in C++ demangle (Morten Eriksen <mortene@sim.no>)
* New Standards-Version: 3.0.1 (but keeping docs in /usr/doc)
Diffstat (limited to 'sysdeps/linux-gnu/m68k')
-rw-r--r-- | sysdeps/linux-gnu/m68k/Makefile | 10 | ||||
-rw-r--r-- | sysdeps/linux-gnu/m68k/arch.h | 3 | ||||
-rw-r--r-- | sysdeps/linux-gnu/m68k/breakpoint.c | 28 | ||||
-rw-r--r-- | sysdeps/linux-gnu/m68k/regs.c | 31 | ||||
-rw-r--r-- | sysdeps/linux-gnu/m68k/signalent.h | 32 | ||||
-rw-r--r-- | sysdeps/linux-gnu/m68k/syscallent.h | 191 | ||||
-rw-r--r-- | sysdeps/linux-gnu/m68k/trace.c | 103 |
7 files changed, 398 insertions, 0 deletions
diff --git a/sysdeps/linux-gnu/m68k/Makefile b/sysdeps/linux-gnu/m68k/Makefile new file mode 100644 index 0000000..2af3c25 --- /dev/null +++ b/sysdeps/linux-gnu/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-gnu/m68k/arch.h b/sysdeps/linux-gnu/m68k/arch.h new file mode 100644 index 0000000..b701e29 --- /dev/null +++ b/sysdeps/linux-gnu/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-gnu/m68k/breakpoint.c b/sysdeps/linux-gnu/m68k/breakpoint.c new file mode 100644 index 0000000..3bf427f --- /dev/null +++ b/sysdeps/linux-gnu/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-gnu/m68k/regs.c b/sysdeps/linux-gnu/m68k/regs.c new file mode 100644 index 0000000..f046f19 --- /dev/null +++ b/sysdeps/linux-gnu/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-gnu/m68k/signalent.h b/sysdeps/linux-gnu/m68k/signalent.h new file mode 100644 index 0000000..f8e0f0e --- /dev/null +++ b/sysdeps/linux-gnu/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-gnu/m68k/syscallent.h b/sysdeps/linux-gnu/m68k/syscallent.h new file mode 100644 index 0000000..cf56647 --- /dev/null +++ b/sysdeps/linux-gnu/m68k/syscallent.h @@ -0,0 +1,191 @@ + "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 */ + "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 */ + "110", /* 110 */ + "vhangup", /* 111 */ + "idle", /* 112 */ + "113", /* 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 */ + "166", /* 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 */ + "getpmsg", /* 188 */ + "putpmsg", /* 189 */ + "vfork", /* 190 */ diff --git a/sysdeps/linux-gnu/m68k/trace.c b/sysdeps/linux-gnu/m68k/trace.c new file mode 100644 index 0000000..0485860 --- /dev/null +++ b/sysdeps/linux-gnu/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; +} |