Commits

Victor Stinner committed 610608c

Experimental support of ARM architecture (Linux EAPI)

strace.py has been tested on Raspberry Pi (armv6l)

Comments (0)

Files changed (5)

  * Drop support of Python 2.5
  * Remove the ptrace.compatibility module
  * Fix Process.readStruct() and Process.readArray() on x86_64
+ * Experimental support of ARM architecture (Linux EAPI),
+   strace.py has been tested on Raspberry Pi (armv6l)
 
 python-ptrace 0.6.6 (2013-12-16)
 --------------------------------

ptrace/binding/linux_struct.py

 from ctypes import (Structure, Union, sizeof,
     c_char, c_ushort, c_int, c_uint, c_ulong, c_void_p,
     c_uint16, c_uint32, c_uint64)
-from ptrace.cpu_info import CPU_64BITS, CPU_PPC32
+from ptrace.cpu_info import CPU_64BITS, CPU_PPC32, CPU_ARM
 
 pid_t = c_int
 uid_t = c_ushort
             ("dsisr", c_ulong),
             ("result", c_ulong),
         )
+    elif CPU_ARM:
+        _fields_ = tuple(("r%i" % reg, c_ulong) for reg in range(18))
     elif CPU_64BITS:
         _fields_ = (
             ("r15", c_ulong),

ptrace/cpu_info.py

     CPU_PPC64 = (_machine == 'ppc64')
     CPU_I386 = (_machine in ("i386", "i686"))    # compatible Intel 32 bits
     CPU_X86_64 = (_machine in ("x86_64", "amd64"))  # compatible Intel 64 bits
+    CPU_ARM = _machine.startswith('arm')
     del _machine
 else:
     # uname() fallback for Windows
     CPU_PPC64 = False
     CPU_I386 = False
     CPU_X86_64 = False
+    CPU_ARM = False
     bits, linkage = architecture()
     if bits == '32bit':
         CPU_I386 = True

ptrace/syscall/prototypes.py

     "break": ("brk",),
     "exit": ("exit_group",),
     "fcntl": ("fcntl64",),
+    "getcwd": ("__getcwd",),
 }
 
 # Name of arguments containing a filename or a path
             ("struct user_desc*", "newtls"),
             ("void*", "child_tidptr"),
         )),
-    "__getcwd": ("long", (
+    "getcwd": ("long", (
             ("char*", "pathname"),
             ("size_t", "size"),
         )),

ptrace/syscall/ptrace_syscall.py

 from os import strerror
 
-from ptrace.cpu_info import CPU_X86_64, CPU_POWERPC, CPU_I386
+from ptrace.cpu_info import CPU_X86_64, CPU_POWERPC, CPU_I386, CPU_ARM
 from ptrace.ctypes_tools import ulong2long, formatAddress, formatWordHex
 from ptrace.func_call import FunctionCall
 from ptrace.syscall import SYSCALL_NAMES, SYSCALL_PROTOTYPES, SyscallArgument
         # Read syscall number
         if CPU_POWERPC:
             self.syscall = regs.gpr0
+        elif CPU_ARM:
+            self.syscall = regs.r7
         elif RUNNING_LINUX:
             if CPU_X86_64:
                 self.syscall = regs.orig_rax
     def readArgumentValues(self, regs):
         if CPU_X86_64:
             return (regs.rdi, regs.rsi, regs.rdx, regs.r10, regs.r8, regs.r9)
+        if CPU_ARM:
+            return (regs.r0, regs.r1, regs.r2, regs.r3, regs.r4, regs.r5, regs.r6)
         if RUNNING_BSD:
             sp = self.process.getStackPointer()
             return [ self.process.readWord(sp + index*CPU_WORD_SIZE)
                 continue
             argument.text = None
 
-        if CPU_I386:
+        if CPU_ARM:
+            regname = "r0"
+        elif CPU_I386:
             regname = "eax"
         elif CPU_X86_64:
             regname = "rax"