[Ltrace-devel] [PATCH] Add support for cris-*-linux-gnu (v32) arch.

Edgar E. Iglesias edgar.iglesias at gmail.com
Mon Jul 19 11:37:45 UTC 2010


Hello,

This patch adds support for the CRIS architecture. If there is something
you'd like me to change let me know and I'll be happy to fix it.

Thanks,
Edgar

commit 0d5a8c45daea1ba1c3a51efb98f66798c7452969
Author: Edgar E. Iglesias <edgar at axis.com>
Date:   Mon Jul 19 13:30:07 2010 +0200

    Add support for cris-*-linux-gnu (v32) arch.
    
    Signed-off-by: Edgar E. Iglesias <edgar at axis.com>

diff --git a/sysdeps/linux-gnu/cris/Makefile b/sysdeps/linux-gnu/cris/Makefile
new file mode 100644
index 0000000..60d7531
--- /dev/null
+++ b/sysdeps/linux-gnu/cris/Makefile
@@ -0,0 +1,10 @@
+OBJ	=	trace.o regs.o plt.o
+
+all:		arch.o
+
+arch.o:		$(OBJ)
+		$(CC) -nostdlib -r -o arch.o $(OBJ)
+
+clean:
+		$(RM) $(OBJ) arch.o
+
diff --git a/sysdeps/linux-gnu/cris/arch.h b/sysdeps/linux-gnu/cris/arch.h
new file mode 100644
index 0000000..11ccb99
--- /dev/null
+++ b/sysdeps/linux-gnu/cris/arch.h
@@ -0,0 +1,6 @@
+#define BREAKPOINT_VALUE { 0x38, 0xe9 }
+#define BREAKPOINT_LENGTH 2
+#define DECR_PC_AFTER_BREAK 0
+
+#define LT_ELFCLASS	ELFCLASS32
+#define LT_ELF_MACHINE	EM_CRIS
diff --git a/sysdeps/linux-gnu/cris/plt.c b/sysdeps/linux-gnu/cris/plt.c
new file mode 100644
index 0000000..46367b8
--- /dev/null
+++ b/sysdeps/linux-gnu/cris/plt.c
@@ -0,0 +1,12 @@
+#include <gelf.h>
+#include "common.h"
+
+GElf_Addr arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela)
+{
+	return lte->plt_addr + 0x20 + (ndx * 26);
+}
+
+void *sym2addr(Process *proc, struct library_symbol *sym)
+{
+	return sym->enter_addr;
+}
diff --git a/sysdeps/linux-gnu/cris/ptrace.h b/sysdeps/linux-gnu/cris/ptrace.h
new file mode 100644
index 0000000..c3cbcb6
--- /dev/null
+++ b/sysdeps/linux-gnu/cris/ptrace.h
@@ -0,0 +1 @@
+#include <sys/ptrace.h>
diff --git a/sysdeps/linux-gnu/cris/regs.c b/sysdeps/linux-gnu/cris/regs.c
new file mode 100644
index 0000000..b78734c
--- /dev/null
+++ b/sysdeps/linux-gnu/cris/regs.c
@@ -0,0 +1,37 @@
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <asm/ptrace.h>
+
+#include "common.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(Process *proc)
+{
+	return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 4 * PT_PPC, 0);
+}
+
+void set_instruction_pointer(Process *proc, void *addr)
+{
+	ptrace(PTRACE_POKEUSER, proc->pid, 4 * PT_PPC, addr);
+}
+
+void *get_stack_pointer(Process *proc)
+{
+	return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 4 * PT_USP, 0);
+}
+
+void *get_return_addr(Process *proc, void *stack_pointer)
+{
+	return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 4 * PT_SRP, 0);
+}
diff --git a/sysdeps/linux-gnu/cris/signalent.h b/sysdeps/linux-gnu/cris/signalent.h
new file mode 100644
index 0000000..44a9a7c
--- /dev/null
+++ b/sysdeps/linux-gnu/cris/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/cris/syscallent.h b/sysdeps/linux-gnu/cris/syscallent.h
new file mode 100644
index 0000000..2baf95b
--- /dev/null
+++ b/sysdeps/linux-gnu/cris/syscallent.h
@@ -0,0 +1,325 @@
+"0",				/* 0 */
+ "exit",
+"fork",
+"read",
+"write",
+"open",
+"close",
+"waitpid",
+"creat",
+"link",
+"unlink",
+"execve",
+"chdir",
+"time",
+"mknod",
+"chmod",
+"lchown",
+"break",
+"oldstat",
+"lseek",
+"getpid",
+"mount",
+"umount",
+"setuid",
+"getuid",
+"stime",
+"ptrace",
+"alarm",
+"oldfstat",
+"pause",
+"utime",
+"stty",
+"gtty",
+"access",
+"nice",
+"ftime",
+"sync",
+"kill",
+"rename",
+"mkdir",
+"rmdir",
+"dup",
+"pipe",
+"times",
+"prof",
+"brk",
+"setgid",
+"getgid",
+"signal",
+"geteuid",
+"getegid",
+"acct",
+"umount2",
+"lock",
+"ioctl",
+"fcntl",
+"mpx",
+"setpgid",
+"ulimit",
+"oldolduname",
+"umask",
+"chroot",
+"ustat",
+"dup2",
+"getppid",
+"getpgrp",
+"setsid",
+"sigaction",
+"sgetmask",
+"ssetmask",
+"setreuid",
+"setregid",
+"sigsuspend",
+"sigpending",
+"sethostname",
+"setrlimit",
+"getrlimit",
+"getrusage",
+"gettimeofday",
+"settimeofday",
+"getgroups",
+"setgroups",
+"select",
+"symlink",
+"oldlstat",
+"readlink",
+"uselib",
+"swapon",
+"reboot",
+"readdir",
+"mmap",
+"munmap",
+"truncate",
+"ftruncate",
+"fchmod",
+"fchown",
+"getpriority",
+"setpriority",
+"profil",
+"statfs",
+"fstatfs",
+"ioperm",
+"socketcall",
+"syslog",
+"setitimer",
+"getitimer",
+"stat",
+"lstat",
+"fstat",
+"olduname",
+"iopl",
+"vhangup",
+"idle",
+"vm86",
+"wait4",
+"swapoff",
+"sysinfo",
+"ipc",
+"fsync",
+"sigreturn",
+"clone",
+"setdomainname",
+"uname",
+"modify_ldt",
+"adjtimex",
+"mprotect",
+"sigprocmask",
+"create_module",
+"init_module",
+"delete_module",
+"get_kernel_syms",
+"quotactl",
+"getpgid",
+"fchdir",
+"bdflush",
+"sysfs",
+"personality",
+"afs_syscall",
+"setfsuid",
+"setfsgid",
+"_llseek",
+"getdents",
+"_newselect",
+"flock",
+"msync",
+"readv",
+"writev",
+"getsid",
+"fdatasync",
+"_sysctl",
+"mlock",
+"munlock",
+"mlockall",
+"munlockall",
+"sched_setparam",
+"sched_getparam",
+"sched_setscheduler",
+"sched_getscheduler",
+"sched_yield",
+"sched_get_priority_max",
+"sched_get_priority_min",
+"sched_rr_get_interval",
+"nanosleep",
+"mremap",
+"setresuid",
+"getresuid",
+"invalid",
+"query_module",
+"poll",
+"nfsservctl",
+"setresgid",
+"getresgid",
+"prctl",
+"rt_sigreturn",
+"rt_sigaction",
+"rt_sigprocmask",
+"rt_sigpending",
+"rt_sigtimedwait",
+"rt_sigqueueinfo",
+"rt_sigsuspend",
+"pread64",
+"pwrite64",
+"chown",
+"getcwd",
+"capget",
+"capset",
+"sigaltstack",
+"sendfile",
+"getpmsg",
+"putpmsg",
+"vfork",
+"ugetrlimit",
+"mmap2",
+"truncate64",
+"ftruncate64",
+"stat64",
+"lstat64",
+"fstat64",
+"lchown32",
+"getuid32",
+"getgid32",
+"geteuid32",
+"getegid32",
+"setreuid32",
+"setregid32",
+"getgroups32",
+"setgroups32",
+"fchown32",
+"setresuid32",
+"getresuid32",
+"setresgid32",
+"getresgid32",
+"chown32",
+"setuid32",
+"setgid32",
+"setfsuid32",
+"setfsgid32",
+"pivot_root",
+"mincore",
+"madvise",
+"getdents64",
+"fcntl64",
+"invalid",
+"invalid",
+"gettid",
+"readahead",
+"setxattr",
+"lsetxattr",
+"fsetxattr",
+"getxattr",
+"lgetxattr",
+"fgetxattr",
+"listxattr",
+"llistxattr",
+"flistxattr",
+"removexattr",
+"lremovexattr",
+"fremovexattr",
+"tkill",
+"sendfile64",
+"futex",
+"sched_setaffinity",
+"sched_getaffinity",
+"set_thread_area",
+"get_thread_area",
+"io_setup",
+"io_destroy",
+"io_getevents",
+"io_submit",
+"io_cancel",
+"fadvise64",
+"invalid",
+"exit_group",
+"lookup_dcookie",
+"epoll_create",
+"epoll_ctl",
+"epoll_wait",
+"remap_file_pages",
+"set_tid_address",
+"timer_create",
+"timer_settime",
+"timer_gettime",
+"timer_getoverrun",
+"timer_delete",
+"clock_settime",
+"clock_gettime",
+"clock_getres",
+"clock_nanosleep",
+"statfs64",
+"fstatfs64",
+"tgkill",
+"utimes",
+"fadvise64_64",
+"vserver",
+"mbind",
+"get_mempolicy",
+"set_mempolicy",
+"mq_open",
+"mq_unlink",
+"mq_timedsend",
+"mq_timedreceive",
+"mq_notify",
+"mq_getsetattr",
+"kexec_load",
+"waitid",
+"invalid",
+"add_key",
+"request_key",
+"keyctl",
+"ioprio_set",
+"ioprio_get",
+"inotify_init",
+"inotify_add_watch",
+"inotify_rm_watch",
+"migrate_pages",
+"openat",
+"mkdirat",
+"mknodat",
+"fchownat",
+"futimesat",
+"fstatat64",
+"unlinkat",
+"renameat",
+"linkat",
+"symlinkat",
+"readlinkat",
+"fchmodat",
+"faccessat",
+"pselect6",
+"ppoll",
+"unshare",
+"set_robust_list",
+"get_robust_list",
+"splice",
+"sync_file_range",
+"tee",
+"vmsplice",
+"move_pages",
+"getcpu",
+"epoll_pwait",
+"utimensat",
+"signalfd",
+"timerfd",
+"eventfd",
+"fallocate",
diff --git a/sysdeps/linux-gnu/cris/trace.c b/sysdeps/linux-gnu/cris/trace.c
new file mode 100644
index 0000000..b9439fc
--- /dev/null
+++ b/sysdeps/linux-gnu/cris/trace.c
@@ -0,0 +1,75 @@
+#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 <elf.h>
+
+#include "common.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_arch_dep(Process *proc)
+{
+}
+
+/* Returns 1 if syscall, 2 if sysret, 0 otherwise.
+ */
+#define SYSCALL_INSN   0xe93d
+int syscall_p(Process *proc, int status, int *sysnum)
+{
+	if (WIFSTOPPED(status)
+	    && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
+		long pc = (long)get_instruction_pointer(proc);
+		unsigned int insn =
+		    (int)ptrace(PTRACE_PEEKTEXT, proc->pid, pc - sizeof(long),
+				0);
+
+		if ((insn >> 16) == SYSCALL_INSN) {
+			*sysnum =
+			    (int)ptrace(PTRACE_PEEKUSER, proc->pid,
+					sizeof(long) * PT_R9, 0);
+			if (proc->callstack_depth > 0
+			    && proc->callstack[proc->callstack_depth -
+					       1].is_syscall) {
+				return 2;
+			}
+			return 1;
+		}
+	}
+	return 0;
+}
+
+long gimme_arg(enum tof type, Process *proc, int arg_num, arg_type_info *info)
+{
+	int pid = proc->pid;
+
+	if (arg_num == -1) {	/* return value */
+		return ptrace(PTRACE_PEEKUSER, pid, PT_R10 * 4, 0);
+	} else if (arg_num < 6) {
+		int pt_arg[6] =
+			{
+				PT_ORIG_R10, PT_R11, PT_R12, PT_R13, PT_MOF,
+				PT_SRP
+			};
+		return ptrace(PTRACE_PEEKUSER, pid, pt_arg[arg_num] * 4, 0);
+	} else {
+		return ptrace(PTRACE_PEEKDATA, pid,
+			      proc->stack_pointer + 4 * (arg_num - 6), 0);
+	}
+	return 0;
+}
+
+void save_register_args(enum tof type, Process *proc)
+{
+}



More information about the Ltrace-devel mailing list