[Ltrace-devel] [PATCH 1/2] ltrace: Add support for Imagination Technologies Meta
Markos Chandras
markos.chandras at gmail.com
Tue Mar 5 13:05:19 UTC 2013
From: Markos Chandras <markos.chandras at imgtec.com>
This patchset adds support for Imagination's Meta architecture.
The Meta Linux kernel port will be included in the Linux Kernel
v3.9. It also uses the generic system call numbers.
Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
README | 1 +
configure.ac | 1 +
sysdeps/linux-gnu/metag/Makefile.am | 16 ++
sysdeps/linux-gnu/metag/arch.h | 27 +++
sysdeps/linux-gnu/metag/plt.c | 35 ++++
sysdeps/linux-gnu/metag/ptrace.h | 21 +++
sysdeps/linux-gnu/metag/regs.c | 85 ++++++++++
sysdeps/linux-gnu/metag/signalent.h | 53 ++++++
sysdeps/linux-gnu/metag/syscallent.h | 293 ++++++++++++++++++++++++++++++++++
sysdeps/linux-gnu/metag/trace.c | 108 +++++++++++++
sysdeps/linux-gnu/trace.c | 2 +-
11 files changed, 641 insertions(+), 1 deletions(-)
create mode 100644 sysdeps/linux-gnu/metag/Makefile.am
create mode 100644 sysdeps/linux-gnu/metag/arch.h
create mode 100644 sysdeps/linux-gnu/metag/plt.c
create mode 100644 sysdeps/linux-gnu/metag/ptrace.h
create mode 100644 sysdeps/linux-gnu/metag/regs.c
create mode 100644 sysdeps/linux-gnu/metag/signalent.h
create mode 100644 sysdeps/linux-gnu/metag/syscallent.h
create mode 100644 sysdeps/linux-gnu/metag/trace.c
diff --git a/README b/README
index 3db5bc8..4a6bf5d 100644
--- a/README
+++ b/README
@@ -27,6 +27,7 @@ to test each release comprehensively on each target.
i[4567]86-*-linux-gnu
ia64-*-linux-gnu
m68k-*-linux-gnu
+ metag-*-linux-gnu
mips-*-linux-gnu
powerpc-*-linux-gnu
powerpc64-*-linux-gnu
diff --git a/configure.ac b/configure.ac
index 525efaa..c8633fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -339,6 +339,7 @@ AC_CONFIG_FILES([
sysdeps/linux-gnu/cris/Makefile
sysdeps/linux-gnu/ia64/Makefile
sysdeps/linux-gnu/m68k/Makefile
+ sysdeps/linux-gnu/metag/Makefile
sysdeps/linux-gnu/mips/Makefile
sysdeps/linux-gnu/ppc/Makefile
sysdeps/linux-gnu/s390/Makefile
diff --git a/sysdeps/linux-gnu/metag/Makefile.am b/sysdeps/linux-gnu/metag/Makefile.am
new file mode 100644
index 0000000..a79d2f7
--- /dev/null
+++ b/sysdeps/linux-gnu/metag/Makefile.am
@@ -0,0 +1,16 @@
+noinst_LTLIBRARIES = \
+ ../libcpu.la
+
+___libcpu_la_SOURCES = \
+ plt.c \
+ regs.c \
+ trace.c
+
+noinst_HEADERS = \
+ arch.h \
+ ptrace.h \
+ signalent.h \
+ syscallent.h
+
+MAINTAINERCLEANFILES = \
+ Makefile.in
diff --git a/sysdeps/linux-gnu/metag/arch.h b/sysdeps/linux-gnu/metag/arch.h
new file mode 100644
index 0000000..727e2cb
--- /dev/null
+++ b/sysdeps/linux-gnu/metag/arch.h
@@ -0,0 +1,27 @@
+/*
+ * This file is part of ltrace.
+ * Copyright (C) 1998,2004,2008 Juan Cespedes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#define LT_ELFCLASS ELFCLASS32
+#define LT_ELF_MACHINE EM_METAG
+
+#define BREAKPOINT_VALUE { 0x01, 0x00, 0x40, 0xAF }
+#define BREAKPOINT_LENGTH 4
+#define DECR_PC_AFTER_BREAK 0
+#define ARCH_ENDIAN_LITTLE
diff --git a/sysdeps/linux-gnu/metag/plt.c b/sysdeps/linux-gnu/metag/plt.c
new file mode 100644
index 0000000..125ecc5
--- /dev/null
+++ b/sysdeps/linux-gnu/metag/plt.c
@@ -0,0 +1,35 @@
+/*
+ * This file is part of ltrace.
+ *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <gelf.h>
+
+#include "proc.h"
+#include "library.h"
+#include "ltrace-elf.h"
+
+GElf_Addr arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela)
+{
+ return lte->plt_addr + ( ndx * 0x18 ) + 0x18;
+}
+
+void *sym2addr(struct process *proc, struct library_symbol *sym)
+{
+ return sym->enter_addr;
+}
diff --git a/sysdeps/linux-gnu/metag/ptrace.h b/sysdeps/linux-gnu/metag/ptrace.h
new file mode 100644
index 0000000..7a41e4a
--- /dev/null
+++ b/sysdeps/linux-gnu/metag/ptrace.h
@@ -0,0 +1,21 @@
+/*
+ * This file is part of ltrace.
+ *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <sys/ptrace.h>
diff --git a/sysdeps/linux-gnu/metag/regs.c b/sysdeps/linux-gnu/metag/regs.c
new file mode 100644
index 0000000..62431de
--- /dev/null
+++ b/sysdeps/linux-gnu/metag/regs.c
@@ -0,0 +1,85 @@
+/*
+ * This file is part of ltrace.
+ *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <linux/uio.h>
+#include <asm/ptrace.h>
+
+#include "proc.h"
+#include "common.h"
+
+void *get_instruction_pointer(struct process *proc)
+{
+ struct user_gp_regs regs;
+ struct iovec iov;
+
+ iov.iov_base = ®s;
+ iov.iov_len = sizeof(regs);
+ if (ptrace(PTRACE_GETREGSET, proc->pid, NT_PRSTATUS, (long)&iov))
+ return (void *)-1;
+
+ return (void *)regs.pc; /* PC */
+}
+
+void set_instruction_pointer(struct process *proc, void *addr)
+{
+ struct user_gp_regs regs;
+ struct iovec iov;
+
+ iov.iov_base = ®s;
+ iov.iov_len = sizeof(regs);
+ if (ptrace(PTRACE_GETREGSET, proc->pid, NT_PRSTATUS, (long)&iov))
+ return;
+
+ regs.pc = (unsigned long)addr;
+
+ iov.iov_base = ®s;
+ iov.iov_len = sizeof(regs);
+ ptrace(PTRACE_SETREGSET, proc->pid, NT_PRSTATUS, (long)&iov);
+}
+
+void *get_stack_pointer(struct process *proc)
+{
+ struct user_gp_regs regs;
+ struct iovec iov;
+
+ iov.iov_base = ®s;
+ iov.iov_len = sizeof(regs);
+ if (ptrace(PTRACE_GETREGSET, proc->pid, NT_PRSTATUS, (long)&iov))
+ return (void *)-1;
+
+ return (void *)regs.ax[0][0]; /* A0StP (A0.0) */
+}
+
+void *get_return_addr(struct process *proc, void *stack_pointer)
+{
+ struct user_gp_regs regs;
+ struct iovec iov;
+
+ iov.iov_base = ®s;
+ iov.iov_len = sizeof(regs);
+ if (ptrace(PTRACE_GETREGSET, proc->pid, NT_PRSTATUS, (long)&iov))
+ return (void *)-1;
+
+ return (void *)regs.dx[4][1]; /* D1RtP (D1.4) */
+}
diff --git a/sysdeps/linux-gnu/metag/signalent.h b/sysdeps/linux-gnu/metag/signalent.h
new file mode 100644
index 0000000..80228b7
--- /dev/null
+++ b/sysdeps/linux-gnu/metag/signalent.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of ltrace.
+ *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+ "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 */
+ "SIGRTMIN", /* 32 */
diff --git a/sysdeps/linux-gnu/metag/syscallent.h b/sysdeps/linux-gnu/metag/syscallent.h
new file mode 100644
index 0000000..447c550
--- /dev/null
+++ b/sysdeps/linux-gnu/metag/syscallent.h
@@ -0,0 +1,293 @@
+/*
+ * This file is part of ltrace.
+ *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+ "io_setup", /* 0 */
+ "io_destroy", /* 1 */
+ "io_submit", /* 2 */
+ "io_cancel", /* 3 */
+ "io_getevents", /* 4 */
+ "setxattr", /* 5 */
+ "lsetxattr", /* 6 */
+ "fsetxattr", /* 7 */
+ "getxattr", /* 8 */
+ "lgetxattr", /* 9 */
+ "fgetxattr", /* 10 */
+ "listxattr", /* 11 */
+ "llistxattr", /* 12 */
+ "flistxattr", /* 13 */
+ "removexattr", /* 14 */
+ "lremovexattr", /* 15 */
+ "fremovexattr", /* 16 */
+ "getcwd", /* 17 */
+ "lookup_dcookie", /* 18 */
+ "eventfd2", /* 19 */
+ "epoll_create1", /* 20 */
+ "epoll_ctl", /* 21 */
+ "epoll_pwait", /* 22 */
+ "dup", /* 23 */
+ "dup3", /* 24 */
+ "fcntl64", /* 25 */
+ "inotify_init1", /* 26 */
+ "inotify_add_watch", /* 27 */
+ "inotify_rm_watch", /* 28 */
+ "ioctl", /* 29 */
+ "ioprio_set", /* 30 */
+ "ioprio_get", /* 31 */
+ "flock", /* 32 */
+ "mknodat", /* 33 */
+ "mkdirat", /* 34 */
+ "unlinkat", /* 35 */
+ "symlinkat", /* 36 */
+ "linkat", /* 37 */
+ "renameat", /* 38 */
+ "umount", /* 39 */
+ "mount", /* 40 */
+ "pivot_root", /* 41 */
+ "42", /* 42 */
+ "statfs64", /* 43 */
+ "fstatfs64", /* 44 */
+ "truncate64", /* 45 */
+ "ftruncate64", /* 46 */
+ "fallocate", /* 47 */
+ "faccessat", /* 48 */
+ "chdir", /* 49 */
+ "fchdir", /* 50 */
+ "chroot", /* 51 */
+ "fchmod", /* 52 */
+ "fchmodat", /* 53 */
+ "fchownat", /* 54 */
+ "fchown", /* 55 */
+ "openat", /* 56 */
+ "close", /* 57 */
+ "vhangup", /* 58 */
+ "pipe2", /* 59 */
+ "quotactl", /* 60 */
+ "getdents64", /* 61 */
+ "llseek", /* 62 */
+ "read", /* 63 */
+ "write", /* 64 */
+ "readv", /* 65 */
+ "writev", /* 66 */
+ "pread64", /* 67 */
+ "pwrite64", /* 68 */
+ "preadv", /* 69 */
+ "pwritev", /* 70 */
+ "sendfile64", /* 71 */
+ "pselect6", /* 72 */
+ "ppoll", /* 73 */
+ "signalfd4", /* 74 */
+ "vmsplice", /* 75 */
+ "splice", /* 76 */
+ "tee", /* 77 */
+ "readlinkat", /* 78 */
+ "fstatat64", /* 79 */
+ "fstat64", /* 80 */
+ "sync", /* 81 */
+ "fsync", /* 82 */
+ "fdatasync", /* 83 */
+ "sync_file_range", /* 84 */
+ "timerfd_create", /* 85 */
+ "timerfd_settime", /* 86 */
+ "timerfd_gettime", /* 87 */
+ "utimensat", /* 88 */
+ "acct", /* 89 */
+ "capget", /* 90 */
+ "capset", /* 91 */
+ "personality", /* 92 */
+ "exit", /* 93 */
+ "exit_group", /* 94 */
+ "waitid", /* 95 */
+ "set_tid_address", /* 96 */
+ "unshare", /* 97 */
+ "futex", /* 98 */
+ "set_robust_list", /* 99 */
+ "get_robust_list", /* 100 */
+ "nanosleep", /* 101 */
+ "getitimer", /* 102 */
+ "setitimer", /* 103 */
+ "kexec_load", /* 104 */
+ "init_module", /* 105 */
+ "delete_module", /* 106 */
+ "timer_create", /* 107 */
+ "timer_gettime", /* 108 */
+ "timer_getoverrun", /* 109 */
+ "timer_settime", /* 110 */
+ "timer_delete", /* 111 */
+ "clock_settime", /* 112 */
+ "clock_gettime", /* 113 */
+ "clock_getres", /* 114 */
+ "clock_nanosleep", /* 115 */
+ "syslog", /* 116 */
+ "ptrace", /* 117 */
+ "sched_setparam", /* 118 */
+ "sched_setscheduler", /* 119 */
+ "sched_getscheduler", /* 120 */
+ "sched_getparam", /* 121 */
+ "sched_setaffinity", /* 122 */
+ "sched_getaffinity", /* 123 */
+ "sched_yield", /* 124 */
+ "sched_get_priority_max", /* 125 */
+ "sched_get_priority_min", /* 126 */
+ "sched_rr_get_interval", /* 127 */
+ "restart_syscall", /* 128 */
+ "kill", /* 129 */
+ "tkill", /* 130 */
+ "tgkill", /* 131 */
+ "sigaltstack", /* 132 */
+ "rt_sigsuspend", /* 133 */
+ "rt_sigaction", /* 134 */
+ "rt_sigprocmask", /* 135 */
+ "rt_sigpending", /* 136 */
+ "rt_sigtimedwait", /* 137 */
+ "rt_sigqueueinfo", /* 138 */
+ "rt_sigreturn", /* 139 */
+ "setpriority", /* 140 */
+ "getpriority", /* 141 */
+ "reboot", /* 142 */
+ "setregid", /* 143 */
+ "setgid", /* 144 */
+ "setreuid", /* 145 */
+ "setuid", /* 146 */
+ "setresuid", /* 147 */
+ "getresuid", /* 148 */
+ "setresgid", /* 149 */
+ "getresgid", /* 150 */
+ "setfsuid", /* 151 */
+ "setfsgid", /* 152 */
+ "times", /* 153 */
+ "setpgid", /* 154 */
+ "getpgid", /* 155 */
+ "getsid", /* 156 */
+ "setsid", /* 157 */
+ "getgroups", /* 158 */
+ "setgroups", /* 159 */
+ "newuname", /* 160 */
+ "sethostname", /* 161 */
+ "setdomainname", /* 162 */
+ "getrlimit", /* 163 */
+ "setrlimit", /* 164 */
+ "getrusage", /* 165 */
+ "umask", /* 166 */
+ "prctl", /* 167 */
+ "getcpu", /* 168 */
+ "gettimeofday", /* 169 */
+ "settimeofday", /* 170 */
+ "adjtimex", /* 171 */
+ "getpid", /* 172 */
+ "getppid", /* 173 */
+ "getuid", /* 174 */
+ "geteuid", /* 175 */
+ "getgid", /* 176 */
+ "getegid", /* 177 */
+ "gettid", /* 178 */
+ "sysinfo", /* 179 */
+ "mq_open", /* 180 */
+ "mq_unlink", /* 181 */
+ "mq_timedsend", /* 182 */
+ "mq_timedreceive", /* 183 */
+ "mq_notify", /* 184 */
+ "mq_getsetattr", /* 185 */
+ "msgget", /* 186 */
+ "msgctl", /* 187 */
+ "msgrcv", /* 188 */
+ "msgsnd", /* 189 */
+ "semget", /* 190 */
+ "semctl", /* 191 */
+ "semtimedop", /* 192 */
+ "semop", /* 193 */
+ "shmget", /* 194 */
+ "shmctl", /* 195 */
+ "shmat", /* 196 */
+ "shmdt", /* 197 */
+ "socket", /* 198 */
+ "socketpair", /* 199 */
+ "bind", /* 200 */
+ "listen", /* 201 */
+ "accept", /* 202 */
+ "connect", /* 203 */
+ "getsockname", /* 204 */
+ "getpeername", /* 205 */
+ "sendto", /* 206 */
+ "recvfrom", /* 207 */
+ "setsockopt", /* 208 */
+ "getsockopt", /* 209 */
+ "shutdown", /* 210 */
+ "sendmsg", /* 211 */
+ "recvmsg", /* 212 */
+ "readahead", /* 213 */
+ "brk", /* 214 */
+ "munmap", /* 215 */
+ "mremap", /* 216 */
+ "add_key", /* 217 */
+ "request_key", /* 218 */
+ "keyctl", /* 219 */
+ "clone", /* 220 */
+ "execve", /* 221 */
+ "mmap2", /* 222 */
+ "fadvise64_64", /* 223 */
+ "swapon", /* 224 */
+ "swapoff", /* 225 */
+ "mprotect", /* 226 */
+ "msync", /* 227 */
+ "mlock", /* 228 */
+ "munlock", /* 229 */
+ "mlockall", /* 230 */
+ "munlockall", /* 231 */
+ "mincore", /* 232 */
+ "madvise", /* 233 */
+ "remap_file_pages", /* 234 */
+ "mbind", /* 235 */
+ "get_mempolicy", /* 236 */
+ "set_mempolicy", /* 237 */
+ "migrate_pages", /* 238 */
+ "move_pages", /* 239 */
+ "rt_tgsigqueueinfo", /* 240 */
+ "perf_event_open", /* 241 */
+ "accept4", /* 242 */
+ "recvmmsg", /* 243 */
+ "244", /* 244 */
+ "metag_setglobalbit", /* 245 */
+ "metag_set_fpu_flags", /* 246 */
+ "metag_set_tls", /* 247 */
+ "metag_get_tls", /* 248 */
+ "249", /* 249 */
+ "250", /* 250 */
+ "251", /* 251 */
+ "252", /* 252 */
+ "253", /* 253 */
+ "254", /* 254 */
+ "255", /* 255 */
+ "256", /* 256 */
+ "257", /* 257 */
+ "258", /* 258 */
+ "259", /* 259 */
+ "wait4", /* 260 */
+ "prlimit64", /* 261 */
+ "fanotify_init", /* 262 */
+ "fanotify_mark", /* 263 */
+ "name_to_handle_at", /* 264 */
+ "open_by_handle_at", /* 265 */
+ "clock_adjtime", /* 266 */
+ "syncfs", /* 267 */
+ "setns", /* 268 */
+ "sendmmsg", /* 269 */
+ "process_vm_readv", /* 270 */
+ "process_vm_writev", /* 271 */
+ "kcmp", /* 272 */
diff --git a/sysdeps/linux-gnu/metag/trace.c b/sysdeps/linux-gnu/metag/trace.c
new file mode 100644
index 0000000..8c4fd65
--- /dev/null
+++ b/sysdeps/linux-gnu/metag/trace.c
@@ -0,0 +1,108 @@
+/*
+ * This file is part of ltrace.
+ *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <sys/ptrace.h>
+#include <linux/uio.h>
+#include <asm/ptrace.h>
+
+#include "proc.h"
+#include "common.h"
+
+void get_arch_dep(struct process *proc)
+{
+
+}
+
+int syscall_p(struct process *proc, int status, int *sysnum)
+{
+ if (WIFSTOPPED(status)
+ && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
+ struct user_gp_regs regs;
+ struct iovec iov;
+
+ /* get GP registers */
+ iov.iov_base = ®s;
+ iov.iov_len = sizeof(regs);
+ if (ptrace(PTRACE_GETREGSET, proc->pid, NT_PRSTATUS,
+ (long)&iov))
+ return -1;
+
+ /* fetch the SWI instruction */
+ unsigned int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, regs.pc,
+ 0);
+ *sysnum = regs.dx[0][1];
+
+ if (insn != 0xAF440001) {
+ /* check if we're returning from the system call */
+ insn = ptrace(PTRACE_PEEKTEXT, proc->pid, regs.pc - 4,
+ 0);
+ if (insn == 0xAF440001) {
+ return 2;
+ }
+
+ return 0;
+ }
+
+ if (*sysnum >= 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+long gimme_arg(enum tof type, struct process *proc, int arg_num, struct arg_type_info *info)
+{
+ long ret;
+ struct user_gp_regs regs;
+ struct iovec iov;
+
+ /* get GP registers */
+ iov.iov_base = ®s;
+ iov.iov_len = sizeof(regs);
+ if (ptrace(PTRACE_GETREGSET, proc->pid, NT_PRSTATUS, (long)&iov))
+ return 0;
+
+ debug(2, "type %d arg %d arg",type, arg_num);
+ if (type == LT_TOF_FUNCTION || type == LT_TOF_SYSCALL) {
+ if (arg_num < 6) {
+ /* Args go backwards starting from D1Ar1 (D1.3) */
+ ret = ((unsigned long *)®s.dx[3][1])[-arg_num];
+ debug(2,"ret = %#lx",ret);
+ return ret;
+ } else {
+ return 0;
+ }
+ }
+ if (arg_num >= 0) {
+ fprintf(stderr,"args on return?");
+ }
+ if (type == LT_TOF_FUNCTIONR || type == LT_TOF_SYSCALLR) {
+ return regs.dx[0][0]; /* D0Re0 (D0.0) */
+ }
+
+ fprintf(stderr, "gimme_arg called with wrong arguments\n");
+
+ return 0;
+}
diff --git a/sysdeps/linux-gnu/trace.c b/sysdeps/linux-gnu/trace.c
index e57a5ed..9a57a0a 100644
--- a/sysdeps/linux-gnu/trace.c
+++ b/sysdeps/linux-gnu/trace.c
@@ -908,7 +908,7 @@ continue_after_breakpoint(struct process *proc, struct breakpoint *sbp)
if (sbp->enabled == 0) {
continue_process(proc->pid);
} else {
-#if defined __sparc__ || defined __ia64___
+#if defined __sparc__ || defined __ia64___ || defined __metag__
/* we don't want to singlestep here */
continue_process(proc->pid);
#else
--
1.7.1
More information about the Ltrace-devel
mailing list