From: Claudio Mignanti Date: Wed, 11 Feb 2009 18:39:53 +0000 (+0000) Subject: Add cris support in strace X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=69b869d98aa2fa3cb714a7e48964307b0ebe232b;p=openwrt%2Fsvn-archive%2Farchive.git Add cris support in strace SVN-Revision: 14477 --- diff --git a/utils/strace/patches-4.5.16/010-cris_support.patch b/utils/strace/patches-4.5.16/010-cris_support.patch new file mode 100644 index 0000000000..07aa9648fc --- /dev/null +++ b/utils/strace/patches-4.5.16/010-cris_support.patch @@ -0,0 +1,345 @@ +diff -Naur strace-4.5.16.ori/config.h.in strace-4.5.16/config.h.in +--- strace-4.5.16.ori/config.h.in 2008-08-04 20:11:11.000000000 +0200 ++++ strace-4.5.16/config.h.in 2008-08-04 20:48:28.000000000 +0200 +@@ -403,6 +403,12 @@ + /* Define for the AMD x86-64 architecture. */ + #undef X86_64 + ++/* Define for the CRISv10 architecture. */ ++#undef CRISV10 ++ ++/* Define for the CRISv32 architecture. */ ++#undef CRISV32 ++ + /* Enable GNU extensions on systems that have them. */ + #ifndef _GNU_SOURCE + # undef _GNU_SOURCE +diff -Naur strace-4.5.16.ori/configure strace-4.5.16/configure +--- strace-4.5.16.ori/configure 2008-08-04 20:11:11.000000000 +0200 ++++ strace-4.5.16/configure 2008-08-04 21:15:39.000000000 +0200 +@@ -2539,6 +2539,22 @@ + _ACEOF + + ;; ++cris|crisv10) ++ arch=crisv10 ++ ++cat >>confdefs.h <<\_ACEOF ++#define CRISV10 1 ++_ACEOF ++ ++ ;; ++crisv32) ++ arch=crisv32 ++ ++cat >>confdefs.h <<\_ACEOF ++#define CRISV32 1 ++_ACEOF ++ ++ ;; + *) + { echo "$as_me:$LINENO: result: NO!" >&5 + echo "${ECHO_T}NO!" >&6; } +diff -Naur strace-4.5.16.ori/configure.ac strace-4.5.16/configure.ac +--- strace-4.5.16.ori/configure.ac 2008-08-04 20:11:11.000000000 +0200 ++++ strace-4.5.16/configure.ac 2008-08-04 20:50:58.000000000 +0200 +@@ -111,6 +111,14 @@ + AC_MSG_RESULT([NO!]) + AC_MSG_ERROR([architecture $host_cpu is not supported by strace]) + ;; ++cris|crisv10) ++ arch=crisv10 ++ AC_DEFINE([CRISV10], 1, [Define for the CRISv10 architecture.]) ++ ;; ++crisv32) ++ arch=crisv32 ++ AC_DEFINE([CRISV32], 1, [Define for the CRISv32 architecture.]) ++ ;; + esac + AC_MSG_RESULT($arch) + +diff -Naur strace-4.5.16.ori/process.c strace-4.5.16/process.c +--- strace-4.5.16.ori/process.c 2008-08-04 20:11:11.000000000 +0200 ++++ strace-4.5.16/process.c 2008-08-04 21:18:30.000000000 +0200 +@@ -548,7 +548,7 @@ + # define ARG_PTID (known_scno(tcp) == SYS_clone2 ? 3 : 2) + # define ARG_CTID (known_scno(tcp) == SYS_clone2 ? 4 : 3) + # define ARG_TLS (known_scno(tcp) == SYS_clone2 ? 5 : 4) +-# elif defined S390 || defined S390X ++# elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32 + # define ARG_STACK 0 + # define ARG_FLAGS 1 + # define ARG_PTID 2 +@@ -704,6 +704,10 @@ + 0x100000 | new) < 0) + return -1; + return 0; ++#elif defined(CRISV10) || defined(CRISV32) ++ if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R9), new) < 0) ++ return -1; ++ return 0; + #elif defined(ARM) + /* Some kernels support this, some (pre-2.6.16 or so) don't. */ + # ifndef PTRACE_SET_SYSCALL +@@ -2934,6 +2938,77 @@ + { uoff(regs.r0), "r0" }, + { uoff(regs.r12_orig), "orig_r12" }, + #endif ++#ifdef CRISV10 ++ { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" }, ++ { 4*PT_ORIG_R10, "4*PT_ORIG_R10" }, ++ { 4*PT_R13, "4*PT_R13" }, ++ { 4*PT_R12, "4*PT_R12" }, ++ { 4*PT_R11, "4*PT_R11" }, ++ { 4*PT_R10, "4*PT_R10" }, ++ { 4*PT_R9, "4*PT_R9" }, ++ { 4*PT_R8, "4*PT_R8" }, ++ { 4*PT_R7, "4*PT_R7" }, ++ { 4*PT_R6, "4*PT_R6" }, ++ { 4*PT_R5, "4*PT_R5" }, ++ { 4*PT_R4, "4*PT_R4" }, ++ { 4*PT_R3, "4*PT_R3" }, ++ { 4*PT_R2, "4*PT_R2" }, ++ { 4*PT_R1, "4*PT_R1" }, ++ { 4*PT_R0, "4*PT_R0" }, ++ { 4*PT_MOF, "4*PT_MOF" }, ++ { 4*PT_DCCR, "4*PT_DCCR" }, ++ { 4*PT_SRP, "4*PT_SRP" }, ++ { 4*PT_IRP, "4*PT_IRP" }, ++ { 4*PT_CSRINSTR, "4*PT_CSRINSTR" }, ++ { 4*PT_CSRADDR, "4*PT_CSRADDR" }, ++ { 4*PT_CSRDATA, "4*PT_CSRDATA" }, ++ { 4*PT_USP, "4*PT_USP" }, ++#endif ++#ifdef CRISV32 ++ { 4*PT_ORIG_R10, "4*PT_ORIG_R10" }, ++ { 4*PT_R0, "4*PT_R0" }, ++ { 4*PT_R1, "4*PT_R1" }, ++ { 4*PT_R2, "4*PT_R2" }, ++ { 4*PT_R3, "4*PT_R3" }, ++ { 4*PT_R4, "4*PT_R4" }, ++ { 4*PT_R5, "4*PT_R5" }, ++ { 4*PT_R6, "4*PT_R6" }, ++ { 4*PT_R7, "4*PT_R7" }, ++ { 4*PT_R8, "4*PT_R8" }, ++ { 4*PT_R9, "4*PT_R9" }, ++ { 4*PT_R10, "4*PT_R10" }, ++ { 4*PT_R11, "4*PT_R11" }, ++ { 4*PT_R12, "4*PT_R12" }, ++ { 4*PT_R13, "4*PT_R13" }, ++ { 4*PT_ACR, "4*PT_ACR" }, ++ { 4*PT_SRS, "4*PT_SRS" }, ++ { 4*PT_MOF, "4*PT_MOF" }, ++ { 4*PT_SPC, "4*PT_SPC" }, ++ { 4*PT_CCS, "4*PT_CCS" }, ++ { 4*PT_SRP, "4*PT_SRP" }, ++ { 4*PT_ERP, "4*PT_ERP" }, ++ { 4*PT_EXS, "4*PT_EXS" }, ++ { 4*PT_EDA, "4*PT_EDA" }, ++ { 4*PT_USP, "4*PT_USP" }, ++ { 4*PT_PPC, "4*PT_PPC" }, ++ { 4*PT_BP_CTRL, "4*PT_BP_CTRL" }, ++ { 4*PT_BP+4, "4*PT_BP+4" }, ++ { 4*PT_BP+8, "4*PT_BP+8" }, ++ { 4*PT_BP+12, "4*PT_BP+12" }, ++ { 4*PT_BP+16, "4*PT_BP+16" }, ++ { 4*PT_BP+20, "4*PT_BP+20" }, ++ { 4*PT_BP+24, "4*PT_BP+24" }, ++ { 4*PT_BP+28, "4*PT_BP+28" }, ++ { 4*PT_BP+32, "4*PT_BP+32" }, ++ { 4*PT_BP+36, "4*PT_BP+36" }, ++ { 4*PT_BP+40, "4*PT_BP+40" }, ++ { 4*PT_BP+44, "4*PT_BP+44" }, ++ { 4*PT_BP+48, "4*PT_BP+48" }, ++ { 4*PT_BP+52, "4*PT_BP+52" }, ++ { 4*PT_BP+56, "4*PT_BP+56" }, ++#endif ++ ++#if !defined(CRISV10) && !defined(CRISV32) + #if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(AVR32) + { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" }, + #endif +@@ -2971,6 +3046,7 @@ + #if defined(I386) || defined(X86_64) + { uoff(u_debugreg), "offsetof(struct user, u_debugreg)" }, + #endif /* I386 */ ++#endif /* !CRISV10/!CRISV32 */ + #endif /* !IA64 */ + #endif /* !ALPHA */ + #endif /* !POWERPC/!SPARC */ +diff -Naur strace-4.5.16.ori/signal.c strace-4.5.16/signal.c +--- strace-4.5.16.ori/signal.c 2007-08-02 03:15:59.000000000 +0200 ++++ strace-4.5.16/signal.c 2008-08-04 20:57:04.000000000 +0200 +@@ -1449,9 +1449,38 @@ + } + return 0; + #else ++#if defined(CRISV10) || defined(CRISV32) ++ struct sigcontext sc; ++ ++ if (entering(tcp)) { ++ long regs[PT_MAX+1]; ++ ++ tcp->u_arg[0] = 0; ++ ++ if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (long)regs) < 0) { ++ perror("sigreturn: PTRACE_GETREGS"); ++ return 0; ++ } ++ if (umove(tcp, regs[PT_USP], &sc) < 0) ++ return 0; ++ tcp->u_arg[0] = 1; ++ tcp->u_arg[1] = sc.oldmask; ++ } else { ++ sigset_t sigm; ++ ++ long_to_sigset(tcp->u_arg[1], &sigm); ++ tcp->u_rval = tcp->u_error = 0; ++ if (tcp->u_arg[0] == 0) ++ return 0; ++ tcp->auxstr = sprintsigmask("mask now ", &sigm, 0); ++ return RVAL_NONE | RVAL_STR; ++ } ++ return 0; ++#else + #warning No sys_sigreturn() for this architecture + #warning (no problem, just a reminder :-) + return 0; ++#endif /* !CRISV10/!CRISV32 */ + #endif /* MIPS */ + #endif /* SPARC || SPARC64 */ + #endif /* ALPHA */ +diff -Naur strace-4.5.16.ori/syscall.c strace-4.5.16/syscall.c +--- strace-4.5.16.ori/syscall.c 2008-08-04 20:11:11.000000000 +0200 ++++ strace-4.5.16/syscall.c 2008-08-04 21:02:28.000000000 +0200 +@@ -809,6 +809,8 @@ + static long r9; + #elif defined(X86_64) + static long rax; ++#elif defined(CRISV10) || defined(CRISV32) ++ static long r10; + #elif defined(AVR32) + static struct pt_regs regs; + #endif +@@ -1294,7 +1296,10 @@ + return 0; + } + } +-#endif /* AVR32 */ ++#elif defined(CRISV10) || defined(CRISV32) ++ if (upeek(pid, 4*PT_R9, &scno) < 0) ++ return -1; ++#endif /* CRISV10/CRISV32 */ + #endif /* LINUX */ + #ifdef SUNOS4 + if (upeek(pid, uoff(u_arg[7]), &scno) < 0) +@@ -1489,6 +1494,14 @@ + fprintf(stderr, "stray syscall exit: r8 = %ld\n", r8); + return 0; + } ++#elif defined(CRISV10) || defined(CRISV32) ++ if (upeek(pid, 4*PT_R10, &r10) < 0) ++ return -1; ++ if (r10 != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) { ++ if (debug) ++ fprintf(stderr, "stray syscall exit: r10 = %ld\n", r10); ++ return 0; ++ } + #endif + #endif /* LINUX */ + return 1; +@@ -1663,6 +1676,17 @@ + tcp->u_rval = regs.r12; + u_error = 0; + } ++#else ++#if defined(CRISV10) || defined(CRISV32) ++ if (r10 && (unsigned) -r10 < nerrnos) { ++ tcp->u_rval = -1; ++ u_error = -r10; ++ } ++ else { ++ tcp->u_rval = r10; ++ u_error = 0; ++ } ++#endif /* CRISV10/CRISV32 */ + #endif /* AVR32 */ + #endif /* SH64 */ + #endif /* SH */ +@@ -2175,6 +2199,23 @@ + tcp->u_arg[3] = regs.r9; + tcp->u_arg[4] = regs.r5; + tcp->u_arg[5] = regs.r3; ++#elif defined(CRISV10) || defined(CRISV32) ++ { ++ int i; ++ static const int crisregs[] = { ++ 4*PT_ORIG_R10, 4*PT_R11, 4*PT_R12, ++ 4*PT_R13, 4*PT_MOF, 4*PT_SRP ++ }; ++ ++ if (tcp->scno >= 0 && tcp->scno < nsyscalls) ++ tcp->u_nargs = sysent[tcp->scno].nargs; ++ else ++ tcp->u_nargs = 0; ++ for (i = 0; i < tcp->u_nargs; i++) { ++ if (upeek(pid, crisregs[i], &tcp->u_arg[i]) < 0) ++ return -1; ++ } ++ } + #else /* Other architecture (like i386) (32bits specific) */ + { + int i; +diff -Naur strace-4.5.16.ori/util.c strace-4.5.16/util.c +--- strace-4.5.16.ori/util.c 2008-08-04 20:11:11.000000000 +0200 ++++ strace-4.5.16/util.c 2008-08-04 21:05:37.000000000 +0200 +@@ -1079,6 +1079,12 @@ + #elif defined(AVR32) + if (upeek(tcp->pid, REG_PC, &pc) < 0) + return -1; ++#elif defined(CRISV10) ++ if (upeek(tcp->pid, 4*PT_IRP, &pc) < 0) ++ return -1; ++#elif defined(CRISV32) ++ if (upeek(tcp->pid, 4*PT_ERP, &pc) < 0) ++ return -1; + #endif + return pc; + #endif /* LINUX */ +@@ -1235,6 +1241,22 @@ + return; + } + tprintf("[%08lx] ", pc); ++#elif defined(CRISV10) ++ long pc; ++ ++ if (upeek(tcp->pid, 4*PT_IRP, &pc) < 0) { ++ PRINTBADPC; ++ return; ++ } ++ tprintf("[%08lx] ", (unsigned long)pc); ++#elif defined(CRISV32) ++ long pc; ++ ++ if (upeek(tcp->pid, 4*PT_ERP, &pc) < 0) { ++ PRINTBADPC; ++ return; ++ } ++ tprintf("[%08lx] ", (unsigned long)pc); + #endif /* !architecture */ + #endif /* LINUX */ + +@@ -1419,6 +1441,13 @@ + # elif defined (AVR32) + # define arg0_offset (REG_R12) + # define arg1_offset (REG_R11) ++# elif defined CRISV10 || defined CRISV32 ++# define arg0_offset (4*PT_R11) ++# define arg1_offset (4*PT_ORIG_R10) ++# define restore_arg0(tcp, state, val) 0 ++# define restore_arg1(tcp, state, val) 0 ++# define arg0_index 1 ++# define arg1_index 0 + # else + # define arg0_offset 0 + # define arg1_offset 4