Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-python-ptrace for
openSUSE:Factory checked in at 2024-03-06 23:04:46
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-python-ptrace (Old)
and /work/SRC/openSUSE:Factory/.python-python-ptrace.new.1770 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-python-ptrace"
Wed Mar 6 23:04:46 2024 rev:8 rq:1155342 version:0.9.8
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-python-ptrace/python-python-ptrace.changes
2021-01-13 18:36:14.294332451 +0100
+++
/work/SRC/openSUSE:Factory/.python-python-ptrace.new.1770/python-python-ptrace.changes
2024-03-06 23:05:12.514786432 +0100
@@ -1,0 +2,16 @@
+Sun Mar 3 19:17:50 UTC 2024 - Ben Greiner <[email protected]>
+
+- Update to 0.9.8
+ * Added Arm 64bit (AArch64) support.
+ * Implemented ``PTRACE_GETREGSET`` and ``PTRACE_SETREGSET``
+ required on AArch64 and available on Linux.
+ * Issue #66: Fix ``SIGTRAP|0x80`` or ``SIGTRAP`` wait in
+ syscall_state.exit (``PTRACE_O_TRACESYSGOOD``).
+- Build PEP517 wheels separately in multibuild
+- Add patchtes for Python 3.12:
+ * python-ptrace-pr81-importlib.patch gh#vstinner/python-ptrace#81
+ * python-ptrace-pr83-importlib.patch gh#vstinner/python-ptrace#83
+- Remove upstreamed patch:
+ * add-aarch64-support.patch
+
+-------------------------------------------------------------------
Old:
----
add-aarch64-support.patch
python-ptrace-0.9.7.tar.gz
New:
----
_multibuild
python-ptrace-0.9.8.tar.gz
python-ptrace-pr81-importlib.patch
python-ptrace-pr83-importlib.patch
BETA DEBUG BEGIN:
Old:- Remove upstreamed patch:
* add-aarch64-support.patch
BETA DEBUG END:
BETA DEBUG BEGIN:
New:- Add patchtes for Python 3.12:
* python-ptrace-pr81-importlib.patch gh#vstinner/python-ptrace#81
* python-ptrace-pr83-importlib.patch gh#vstinner/python-ptrace#83
New: * python-ptrace-pr81-importlib.patch gh#vstinner/python-ptrace#81
* python-ptrace-pr83-importlib.patch gh#vstinner/python-ptrace#83
- Remove upstreamed patch:
BETA DEBUG END:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-python-ptrace.spec ++++++
--- /var/tmp/diff_new_pack.KUfWHz/_old 2024-03-06 23:05:14.706865971 +0100
+++ /var/tmp/diff_new_pack.KUfWHz/_new 2024-03-06 23:05:14.710866116 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-python-ptrace
#
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,50 +16,93 @@
#
-%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-%define pkg_name python-ptrace
-%define skip_python2 1
-Name: python-%{pkg_name}
-Version: 0.9.7
+%global flavor @BUILD_FLAVOR@%{nil}
+%define pyversion 0.9.8
+%define cversion 0.6.1
+%if "%{flavor}" == ""
+%define pkgname python-ptrace
+%define pkgversion %{pyversion}
+%bcond_with test
+%endif
+%if "%{flavor}" == "cptrace"
+%define pkgname cptrace
+%define pkgversion %{cversion}
+%bcond_with test
+%endif
+%if "%{flavor}" == "test"
+%define pkgname python-ptrace-test
+%define pkgversion %{pyversion}+%{cversion}
+%bcond_without test
+ExcludeArch: %arm
+%endif
+
+Name: python-%{pkgname}
+Version: %{pkgversion}
Release: 0
Summary: Python binding for ptrace
License: GPL-2.0-only
Group: Development/Languages/Python
URL: https://github.com/vstinner/python-ptrace
-Source:
https://github.com/haypo/%{pkg_name}/archive/%{version}.tar.gz#!./%{pkg_name}-%{version}.tar.gz
-# PATCH-FIX-UPSTREAM - https://github.com/vstinner/python-ptrace/pull/59
-Patch1: add-aarch64-support.patch
+Source:
https://github.com/haypo/python-ptrace/archive/%{pyversion}.tar.gz#/python-ptrace-%{pyversion}.tar.gz
+# PATCH-FIX-UPSTREAM - Add python-ptrace-pr81-importlib.patch
gh#vstinner/python-ptrace#81
+Patch0:
https://github.com/vstinner/python-ptrace/pull/81.patch#/python-ptrace-pr81-importlib.patch
+# PATCH-FIX-UPSTREAM - Add python-ptrace-pr83-importlib.patch
gh#vstinner/python-ptrace#83
+Patch1:
https://github.com/vstinner/python-ptrace/pull/83.patch#/python-ptrace-pr83-importlib.patch
+%if "%{flavor}" == "cptrace"
BuildRequires: %{python_module devel}
+%else
+BuildArch: noarch
+Recommends: python-cptrace = %{cversion}
+%endif
+BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
+BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires(post): update-alternatives
Requires(postun): update-alternatives
+%if %{with test}
+BuildRequires: %{python_module cptrace = %{cversion}}
+BuildRequires: %{python_module python-ptrace = %{pyversion}}
+%endif
%python_subpackages
%description
python-ptrace is a debugger using ptrace written in Python.
%prep
-%setup -q -n %{pkg_name}-%{version}
-%patch1 -p1
+%autosetup -p1 -n python-ptrace-%{pyversion}
sed -i 's/\x0D$//' doc/*.rst
chmod 0644 examples/*.py
%build
-%python_build
-%python_exec setup_cptrace.py build
+%if !%{with test}
+%if "%{flavor}" == "cptrace"
+mv setup.py setup_python-ptrace.py
+mv setup_cptrace.py setup.py
+%endif
+%pyproject_wheel
+%endif
%install
-%python_install
-%python_exec setup_cptrace.py install -O1 --skip-build --root %{buildroot}
+%if !%{with test}
+%pyproject_install
+%if "%{flavor}" == "cptrace"
+%python_expand %fdupes %{buildroot}%{$python_sitearch}
+%else
%python_clone -a %{buildroot}%{_bindir}/gdb.py
%python_clone -a %{buildroot}%{_bindir}/strace.py
%python_expand %fdupes %{buildroot}%{$python_sitelib}
+%endif
+%endif
+%if %{with test}
%check
-%python_exec runtests.py
+%python_exec runtests.py -v
+%endif
+%if !%{with test}
+%if "%{flavor}" == ""
%post
%python_install_alternative strace.py
%python_install_alternative gdb.py
@@ -75,7 +118,15 @@
%python_alternative %{_bindir}/gdb.py
%python_alternative %{_bindir}/strace.py
%{python_sitelib}/ptrace/
-%{python_sitelib}/python_ptrace-*-py*.egg-info
+%{python_sitelib}/python_ptrace-%{pkgversion}.dist-info
+%endif
+
+%if "%{flavor}" == "cptrace"
+%files %{python_files}
+%license COPYING
+%doc README.rst
%{python_sitearch}/cptrace*.so
-%{python_sitearch}/cptrace-*-py*.egg-info
+%{python_sitearch}/cptrace-%{pkgversion}.dist-info
+%endif
+%endif
++++++ _multibuild ++++++
<multibuild>
<package>cptrace</package>
<package>test</package>
</multibuild>
++++++ python-ptrace-0.9.7.tar.gz -> python-ptrace-0.9.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/.github/workflows/build.yml
new/python-ptrace-0.9.8/.github/workflows/build.yml
--- old/python-ptrace-0.9.7/.github/workflows/build.yml 1970-01-01
01:00:00.000000000 +0100
+++ new/python-ptrace-0.9.8/.github/workflows/build.yml 2021-03-17
21:19:45.000000000 +0100
@@ -0,0 +1,26 @@
+name: Build
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ branches: [main]
+
+jobs:
+ build:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest]
+ python: [3.9]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python }}
+ - name: Install Tox and any other packages
+ run: pip install tox
+ - name: Run Tox
+ run: tox
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/.github/workflows/setup_test.yml
new/python-ptrace-0.9.8/.github/workflows/setup_test.yml
--- old/python-ptrace-0.9.7/.github/workflows/setup_test.yml 1970-01-01
01:00:00.000000000 +0100
+++ new/python-ptrace-0.9.8/.github/workflows/setup_test.yml 2021-03-17
21:19:45.000000000 +0100
@@ -0,0 +1,25 @@
+# This workflow will install Python dependencies, run tests and lint with a
variety of Python versions
+
+name: Run tests
+
+on: [ push, pull_request ]
+
+jobs:
+ Test:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: [3.6, 3.7, 3.8, 3.9]
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Install tox
+ run: |
+ python -m pip install --upgrade pip
+ pip install tox
+ - name: Test with tox
+ run: |
+ tox
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/.travis.yml
new/python-ptrace-0.9.8/.travis.yml
--- old/python-ptrace-0.9.7/.travis.yml 2020-08-10 23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/.travis.yml 1970-01-01 01:00:00.000000000 +0100
@@ -1,10 +0,0 @@
-language: python
-env:
- - TOXENV=pep8
- - TOXENV=py3
-install: pip install -U tox
-# SYS_PTRACE capability is not available in default containers,
-# use sudo to work around the issue:
-# https://github.com/travis-ci/travis-ci/issues/9033
-sudo: required
-script: tox
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/README.rst
new/python-ptrace-0.9.8/README.rst
--- old/python-ptrace-0.9.7/README.rst 2020-08-10 23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/README.rst 2021-03-17 21:19:45.000000000 +0100
@@ -6,9 +6,9 @@
:alt: Latest release on the Python Cheeseshop (PyPI)
:target: https://pypi.python.org/pypi/python-ptrace
-.. image:: https://travis-ci.com/vstinner/python-ptrace.svg?branch=master
- :alt: Build status of python-ptrace on Travis CI
- :target: https://travis-ci.com/github/vstinner/python-ptrace
+.. image::
https://github.com/vstinner/python-ptrace/actions/workflows/build.yml/badge.svg
+ :alt: Build status of python-ptrace on GitHub Actions
+ :target: https://github.com/vstinner/python-ptrace/actions
python-ptrace is a debugger using ptrace (Linux, BSD and Darwin system call to
trace processes) written in Python.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/doc/changelog.rst
new/python-ptrace-0.9.8/doc/changelog.rst
--- old/python-ptrace-0.9.7/doc/changelog.rst 2020-08-10 23:27:31.000000000
+0200
+++ new/python-ptrace-0.9.8/doc/changelog.rst 2021-03-17 21:19:45.000000000
+0100
@@ -3,6 +3,18 @@
Changelog
=========
+python-ptrace 0.9.8
+-------------------
+
+* Added Arm 64bit (AArch64) support.
+* Implemented ``PTRACE_GETREGSET`` and ``PTRACE_SETREGSET`` required on AArch64
+ and available on Linux.
+* Issue #66: Fix ``SIGTRAP|0x80`` or ``SIGTRAP`` wait in syscall_state.exit
+ (``PTRACE_O_TRACESYSGOOD``).
+* The development branch ``master`` was renamed to ``main``.
+ See https://sfconservancy.org/news/2020/jun/23/gitbranchname/ for the
+ rationale.
+
python-ptrace 0.9.7 (2020-08-10)
--------------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/doc/conf.py
new/python-ptrace-0.9.8/doc/conf.py
--- old/python-ptrace-0.9.7/doc/conf.py 2020-08-10 23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/doc/conf.py 2021-03-17 21:19:45.000000000 +0100
@@ -41,7 +41,7 @@
# built documents.
#
# The short X.Y version.
-version = release = '0.9.7'
+version = release = '0.9.8'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/binding/__init__.py
new/python-ptrace-0.9.8/ptrace/binding/__init__.py
--- old/python-ptrace-0.9.7/ptrace/binding/__init__.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/binding/__init__.py 2021-03-17
21:19:45.000000000 +0100
@@ -1,7 +1,7 @@
from ptrace.binding.func import ( # noqa
HAS_PTRACE_SINGLESTEP, HAS_PTRACE_EVENTS,
HAS_PTRACE_IO, HAS_PTRACE_SIGINFO, HAS_PTRACE_GETREGS,
- REGISTER_NAMES,
+ HAS_PTRACE_GETREGSET, REGISTER_NAMES,
ptrace_attach, ptrace_traceme,
ptrace_detach, ptrace_kill,
ptrace_cont, ptrace_syscall,
@@ -24,5 +24,5 @@
ptrace_io_desc,
PIOD_READ_D, PIOD_WRITE_D,
PIOD_READ_I, PIOD_WRITE_I)
-if HAS_PTRACE_GETREGS:
+if HAS_PTRACE_GETREGS or HAS_PTRACE_GETREGSET:
from ptrace.binding.func import ptrace_getregs # noqa
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/binding/cpu.py
new/python-ptrace-0.9.8/ptrace/binding/cpu.py
--- old/python-ptrace-0.9.7/ptrace/binding/cpu.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/binding/cpu.py 2021-03-17
21:19:45.000000000 +0100
@@ -1,5 +1,5 @@
from ptrace.cpu_info import (
- CPU_POWERPC, CPU_INTEL, CPU_X86_64, CPU_I386, CPU_ARM)
+ CPU_POWERPC, CPU_INTEL, CPU_X86_64, CPU_I386, CPU_ARM32, CPU_AARCH64)
CPU_INSTR_POINTER = None
CPU_STACK_POINTER = None
@@ -10,10 +10,14 @@
CPU_INSTR_POINTER = "nip"
# FIXME: Is it the right register?
CPU_STACK_POINTER = 'gpr1'
-elif CPU_ARM:
+elif CPU_ARM32:
CPU_INSTR_POINTER = 'r15'
CPU_STACK_POINTER = 'r14'
CPU_FRAME_POINTER = 'r11'
+elif CPU_AARCH64:
+ CPU_INSTR_POINTER = 'pc'
+ CPU_STACK_POINTER = 'sp'
+ CPU_FRAME_POINTER = 'r29'
elif CPU_X86_64:
CPU_INSTR_POINTER = "rip"
CPU_STACK_POINTER = "rsp"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/binding/func.py
new/python-ptrace-0.9.8/ptrace/binding/func.py
--- old/python-ptrace-0.9.7/ptrace/binding/func.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/binding/func.py 2021-03-17
21:19:45.000000000 +0100
@@ -1,9 +1,9 @@
from os import strerror
-from ctypes import addressof, c_int, get_errno, set_errno
+from ctypes import addressof, c_int, get_errno, set_errno, sizeof
from ptrace import PtraceError
from ptrace.ctypes_tools import formatAddress
from ptrace.os_tools import RUNNING_LINUX, RUNNING_BSD, RUNNING_OPENBSD
-from ptrace.cpu_info import CPU_64BITS, CPU_WORD_SIZE, CPU_POWERPC
+from ptrace.cpu_info import CPU_64BITS, CPU_WORD_SIZE, CPU_POWERPC, CPU_AARCH64
if RUNNING_OPENBSD:
from ptrace.binding.openbsd_struct import (
@@ -17,7 +17,7 @@
elif RUNNING_LINUX:
from ptrace.binding.linux_struct import (
user_regs_struct as ptrace_registers_t,
- user_fpregs_struct, siginfo)
+ user_fpregs_struct, siginfo, iovec_struct)
if not CPU_64BITS:
from ptrace.binding.linux_struct import user_fpxregs_struct
else:
@@ -29,6 +29,9 @@
HAS_PTRACE_IO = False
HAS_PTRACE_SIGINFO = False
HAS_PTRACE_GETREGS = False
+HAS_PTRACE_GETREGSET = False
+HAS_PTRACE_SETREGS = False
+HAS_PTRACE_SETREGSET = False
# Special flags that are required to wait for cloned processes (threads)
# See wait(2)
@@ -79,9 +82,18 @@
PTRACE_IO = 12
else:
# Linux
- HAS_PTRACE_GETREGS = True
- PTRACE_GETREGS = 12
- PTRACE_SETREGS = 13
+ if not CPU_AARCH64:
+ HAS_PTRACE_GETREGS = True
+ HAS_PTRACE_SETREGS = True
+ PTRACE_GETREGS = 12
+ PTRACE_SETREGS = 13
+
+ HAS_PTRACE_GETREGSET = True
+ HAS_PTRACE_SETREGSET = True
+ PTRACE_GETREGSET = 0x4204
+ PTRACE_SETREGSET = 0x4205
+ NT_PRSTATUS = 1
+
PTRACE_ATTACH = 16
PTRACE_DETACH = 17
PTRACE_SYSCALL = 24
@@ -263,8 +275,25 @@
ptrace(PTRACE_GETREGS, pid, 0, addressof(regs))
return regs
- def ptrace_setregs(pid, regs):
- ptrace(PTRACE_SETREGS, pid, 0, addressof(regs))
+ elif HAS_PTRACE_GETREGSET:
+ def ptrace_getregs(pid):
+ regs = ptrace_registers_t()
+ iov = iovec_struct()
+ setattr(iov, "buf", addressof(regs))
+ setattr(iov, "len", sizeof(regs))
+ ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, addressof(iov))
+ return regs
+
+ if HAS_PTRACE_SETREGS:
+ def ptrace_setregs(pid, regs):
+ ptrace(PTRACE_SETREGS, pid, 0, addressof(regs))
+
+ elif HAS_PTRACE_SETREGSET:
+ def ptrace_setregs(pid, regs):
+ iov = iovec_struct()
+ setattr(iov, "buf", addressof(regs))
+ setattr(iov, "len", sizeof(regs))
+ ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, addressof(iov))
if HAS_PTRACE_SINGLESTEP:
def ptrace_singlestep(pid):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/binding/linux_struct.py
new/python-ptrace-0.9.8/ptrace/binding/linux_struct.py
--- old/python-ptrace-0.9.7/ptrace/binding/linux_struct.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/binding/linux_struct.py 2021-03-17
21:19:45.000000000 +0100
@@ -1,7 +1,7 @@
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, CPU_PPC64, CPU_ARM
+ c_uint16, c_uint32, c_uint64, c_size_t)
+from ptrace.cpu_info import CPU_64BITS, CPU_PPC32, CPU_PPC64, CPU_ARM32,
CPU_AARCH64
pid_t = c_int
uid_t = c_ushort
@@ -12,7 +12,15 @@
# arch/$ARCH/include/uapi/asm/ptrace.h
-class user_regs_struct(Structure):
+class register_structure(Structure):
+ def __str__(self):
+ regs = {}
+ for reg in self.__class__._fields_:
+ regs.update({reg[0]: getattr(self, reg[0])})
+ return str(regs)
+
+
+class user_regs_struct(register_structure):
if CPU_PPC32:
_fields_ = (
("gpr0", c_ulong),
@@ -107,8 +115,14 @@
("dsisr", c_ulong),
("result", c_ulong),
)
- elif CPU_ARM:
+ elif CPU_ARM32:
_fields_ = tuple(("r%i" % reg, c_ulong) for reg in range(18))
+ elif CPU_AARCH64:
+ _fields_ = tuple([*[("r%i" % reg, c_ulong) for reg in range(31)],
+ ('sp', c_ulong),
+ ('pc', c_ulong),
+ ('pstate', c_ulong)]
+ )
elif CPU_64BITS:
_fields_ = (
("r15", c_ulong),
@@ -167,7 +181,7 @@
)
-class user_fpregs_struct(Structure):
+class user_fpregs_struct(register_structure):
if CPU_64BITS:
_fields_ = (
("cwd", c_uint16),
@@ -196,7 +210,7 @@
if not CPU_64BITS:
- class user_fpxregs_struct(Structure):
+ class user_fpxregs_struct(register_structure):
_fields_ = (
("cwd", c_ushort),
("swd", c_ushort),
@@ -252,3 +266,10 @@
("_sifields", _sifields_t)
)
_anonymous_ = ("_sifields",)
+
+
+class iovec_struct(Structure):
+ _fields_ = (
+ ("buf", c_void_p),
+ ("len", c_size_t)
+ )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/cpu_info.py
new/python-ptrace-0.9.8/ptrace/cpu_info.py
--- old/python-ptrace-0.9.7/ptrace/cpu_info.py 2020-08-10 23:27:31.000000000
+0200
+++ new/python-ptrace-0.9.8/ptrace/cpu_info.py 2021-03-17 21:19:45.000000000
+0100
@@ -39,7 +39,8 @@
CPU_PPC64 = (_machine in ('ppc64', 'ppc64le'))
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')
+ CPU_ARM32 = _machine.startswith('arm')
+ CPU_AARCH64 = (_machine == 'aarch64')
del _machine
else:
# uname() fallback for Windows
@@ -48,7 +49,8 @@
CPU_PPC64 = False
CPU_I386 = False
CPU_X86_64 = False
- CPU_ARM = False
+ CPU_ARM32 = False
+ CPU_AARCH64 = False
bits, linkage = architecture()
if bits == '32bit':
CPU_I386 = True
@@ -59,3 +61,4 @@
CPU_INTEL = (CPU_I386 or CPU_X86_64)
CPU_POWERPC = (CPU_PPC32 or CPU_PPC64)
+CPU_ARM = (CPU_ARM32 or CPU_AARCH64)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/debugger/application.py
new/python-ptrace-0.9.8/ptrace/debugger/application.py
--- old/python-ptrace-0.9.7/ptrace/debugger/application.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/debugger/application.py 2021-03-17
21:19:45.000000000 +0100
@@ -56,6 +56,8 @@
exit(1)
if self.options.trace_exec:
self.debugger.traceExec()
+ if self.options.trace_clone:
+ self.debugger.traceClone()
def createProcess(self):
if self.options.pid:
@@ -79,9 +81,11 @@
def createCommonOptions(self, parser):
parser.add_option("--pid", "-p", help="Attach running process
specified by its identifier",
type="int", default=None)
- parser.add_option("--fork", "-f", help="Trace fork and child process",
+ parser.add_option("--fork", "-f", help="Trace fork() event and child
processes",
action="store_true", default=False)
parser.add_option("--trace-exec", help="Trace execve() event",
action="store_true", default=False)
+ parser.add_option("--trace-clone", help="Trace clone() event",
+ action="store_true", default=False)
parser.add_option("--no-stdout", help="Use /dev/null as stdout/stderr,
or close stdout and stderr if /dev/null doesn't exist",
action="store_true", default=False)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/debugger/debugger.py
new/python-ptrace-0.9.8/ptrace/debugger/debugger.py
--- old/python-ptrace-0.9.7/ptrace/debugger/debugger.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/debugger/debugger.py 2021-03-17
21:19:45.000000000 +0100
@@ -34,8 +34,9 @@
- waitSyscall(): wait for the next syscall event
* Options:
- - traceForks(): enable fork tracing
+ - traceFork(): enable fork() tracing
- traceExec(): enable exec() tracing
+ - traceClone(): enable clone() tracing
- enableSysgood(): enable sysgood option
* Other:
@@ -56,6 +57,7 @@
- options: ptrace options
- trace_fork (bool): fork() tracing is enabled?
- trace_exec (bool): exec() tracing is enabled?
+ - trace_clone (bool): clone() tracing is enabled?
- use_sysgood (bool): sysgood option is enabled?
"""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/debugger/process.py
new/python-ptrace-0.9.8/ptrace/debugger/process.py
--- old/python-ptrace-0.9.7/ptrace/debugger/process.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/debugger/process.py 2021-03-17
21:19:45.000000000 +0100
@@ -1,6 +1,7 @@
from ptrace.binding import (
HAS_PTRACE_SINGLESTEP, HAS_PTRACE_EVENTS,
HAS_PTRACE_SIGINFO, HAS_PTRACE_IO, HAS_PTRACE_GETREGS,
+ HAS_PTRACE_GETREGSET,
ptrace_attach, ptrace_detach,
ptrace_cont, ptrace_syscall,
ptrace_setregs,
@@ -45,7 +46,7 @@
PTRACE_EVENT_EXEC)
NEW_PROCESS_EVENT = (
PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK, PTRACE_EVENT_CLONE)
-if HAS_PTRACE_GETREGS:
+if HAS_PTRACE_GETREGS or HAS_PTRACE_GETREGSET:
from ptrace.binding import ptrace_getregs
else:
from ptrace.binding import ptrace_peekuser, ptrace_registers_t
@@ -112,7 +113,7 @@
* display status:
- - dumpCore(): display the next instructions
+ - dumpCode(): display the next instructions
- dumpStack(): display some memory words around the stack pointer
- dumpMaps(): display memory mappings
- dumpRegs(): display all registers
@@ -225,6 +226,7 @@
log("CODE: %s" % text)
return
+ log("CODE:")
if manage_bp:
address = start
for line in range(10):
@@ -411,7 +413,7 @@
raise ProcessError(self, "Unknown ptrace event: %r" % event)
def getregs(self):
- if HAS_PTRACE_GETREGS:
+ if HAS_PTRACE_GETREGS or HAS_PTRACE_GETREGSET:
return ptrace_getregs(self.pid)
else:
# FIXME: Optimize getreg() when used with this function
@@ -731,7 +733,7 @@
return self.debugger.waitProcessEvent(pid=self.pid)
def waitSignals(self, *signals):
- return self.debugger.waitSignals(*signals, **{'pid': self.pid})
+ return self.debugger.waitSignals(*signals, pid=self.pid)
def waitSyscall(self):
self.debugger.waitSyscall(self)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/debugger/syscall_state.py
new/python-ptrace-0.9.8/ptrace/debugger/syscall_state.py
--- old/python-ptrace-0.9.7/ptrace/debugger/syscall_state.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/debugger/syscall_state.py 2021-03-17
21:19:45.000000000 +0100
@@ -37,7 +37,7 @@
and not self.process.debugger.trace_exec:
# Ignore the SIGTRAP after exec() syscall exit
self.process.syscall()
- self.process.waitSignals(SIGTRAP)
+ self.process.waitSignals(SIGTRAP, SIGTRAP | 0x80)
syscall = self.syscall
self.clear()
return syscall
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/profiler.py
new/python-ptrace-0.9.8/ptrace/profiler.py
--- old/python-ptrace-0.9.7/ptrace/profiler.py 2020-08-10 23:27:31.000000000
+0200
+++ new/python-ptrace-0.9.8/ptrace/profiler.py 2021-03-17 21:19:45.000000000
+0100
@@ -1,23 +1,35 @@
-from hotshot import Profile
-from hotshot.stats import load as loadStats
+from profile import Profile
from os import unlink
from io import StringIO
+import pstats
+
+
+def calibrate(n):
+ """
+ https://docs.python.org/3/library/profile.html#calibration
+ """
+ if n > 0:
+ pr = Profile()
+ magics = []
+ for i in range(n):
+ magics.append(pr.calibrate(10000))
+ return sum(magics) / n
def runProfiler(logger, func, args=tuple(), kw={},
verbose=True, nb_func=25,
- sort_by=('time',)):
+ sort_by=('time',), nb_cal=0):
"""
Run a function in a profiler and then display the functions sorted by time.
"""
profile_filename = "/tmp/profiler"
- prof = Profile(profile_filename)
+ prof = Profile(bias=calibrate(nb_cal))
try:
logger.warning("Run profiler")
result = prof.runcall(func, *args, **kw)
- prof.close()
logger.error("Profiler: Process data...")
- stat = loadStats(profile_filename)
+ prof.dump_stats(profile_filename)
+ stat = pstats.Stats(prof)
stat.strip_dirs()
stat.sort_stats(*sort_by)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/syscall/linux/aarch64.py
new/python-ptrace-0.9.8/ptrace/syscall/linux/aarch64.py
--- old/python-ptrace-0.9.7/ptrace/syscall/linux/aarch64.py 1970-01-01
01:00:00.000000000 +0100
+++ new/python-ptrace-0.9.8/ptrace/syscall/linux/aarch64.py 2021-03-17
21:19:45.000000000 +0100
@@ -0,0 +1,317 @@
+# From https://github.com/hrw/syscalls-table/
+
+SYSCALL_NAMES = {
+ 0: "io_setup",
+ 1: "io_destroy",
+ 2: "io_submit",
+ 3: "io_cancel",
+ 4: "io_getevents",
+ 5: "setxattr",
+ 6: "lsetxattr",
+ 7: "fsetxattr",
+ 8: "getxattr",
+ 9: "lgetxattr",
+ 10: "fgetxattr",
+ 11: "listxattr",
+ 12: "llistxattr",
+ 13: "flistxattr",
+ 14: "removexattr",
+ 15: "lremovexattr",
+ 16: "fremovexattr",
+ 17: "getcwd",
+ 18: "lookup_dcookie",
+ 19: "eventfd2",
+ 20: "epoll_create1",
+ 21: "epoll_ctl",
+ 22: "epoll_pwait",
+ 23: "dup",
+ 24: "dup3",
+ 25: "fcntl",
+ 26: "inotify_init1",
+ 27: "inotify_add_watch",
+ 28: "inotify_rm_watch",
+ 29: "ioctl",
+ 30: "ioprio_set",
+ 31: "ioprio_get",
+ 32: "flock",
+ 33: "mknodat",
+ 34: "mkdirat",
+ 35: "unlinkat",
+ 36: "symlinkat",
+ 37: "linkat",
+ 38: "renameat",
+ 39: "umount2",
+ 40: "mount",
+ 41: "pivot_root",
+ 42: "nfsservctl",
+ 43: "statfs",
+ 44: "fstatfs",
+ 45: "truncate",
+ 46: "ftruncate",
+ 47: "fallocate",
+ 48: "faccessat",
+ 49: "chdir",
+ 50: "fchdir",
+ 51: "chroot",
+ 52: "fchmod",
+ 53: "fchmodat",
+ 54: "fchownat",
+ 55: "fchown",
+ 56: "openat",
+ 57: "close",
+ 58: "vhangup",
+ 59: "pipe2",
+ 60: "quotactl",
+ 61: "getdents64",
+ 62: "lseek",
+ 63: "read",
+ 64: "write",
+ 65: "readv",
+ 66: "writev",
+ 67: "pread64",
+ 68: "pwrite64",
+ 69: "preadv",
+ 70: "pwritev",
+ 71: "sendfile",
+ 72: "pselect6",
+ 73: "ppoll",
+ 74: "signalfd4",
+ 75: "vmsplice",
+ 76: "splice",
+ 77: "tee",
+ 78: "readlinkat",
+ 79: "newfstatat",
+ 80: "fstat",
+ 81: "sync",
+ 82: "fsync",
+ 83: "fdatasync",
+ 84: "sync_file_range",
+ 85: "timerfd_create",
+ 86: "timerfd_settime",
+ 87: "timerfd_gettime",
+ 88: "utimensat",
+ 89: "acct",
+ 90: "capget",
+ 91: "capset",
+ 92: "personality",
+ 93: "exit",
+ 94: "exit_group",
+ 95: "waitid",
+ 96: "set_tid_address",
+ 97: "unshare",
+ 98: "futex",
+ 99: "set_robust_list",
+ 100: "get_robust_list",
+ 101: "nanosleep",
+ 102: "getitimer",
+ 103: "setitimer",
+ 104: "kexec_load",
+ 105: "init_module",
+ 106: "delete_module",
+ 107: "timer_create",
+ 108: "timer_gettime",
+ 109: "timer_getoverrun",
+ 110: "timer_settime",
+ 111: "timer_delete",
+ 112: "clock_settime",
+ 113: "clock_gettime",
+ 114: "clock_getres",
+ 115: "clock_nanosleep",
+ 116: "syslog",
+ 117: "ptrace",
+ 118: "sched_setparam",
+ 119: "sched_setscheduler",
+ 120: "sched_getscheduler",
+ 121: "sched_getparam",
+ 122: "sched_setaffinity",
+ 123: "sched_getaffinity",
+ 124: "sched_yield",
+ 125: "sched_get_priority_max",
+ 126: "sched_get_priority_min",
+ 127: "sched_rr_get_interval",
+ 128: "restart_syscall",
+ 129: "kill",
+ 130: "tkill",
+ 131: "tgkill",
+ 132: "sigaltstack",
+ 133: "rt_sigsuspend",
+ 134: "rt_sigaction",
+ 135: "rt_sigprocmask",
+ 136: "rt_sigpending",
+ 137: "rt_sigtimedwait",
+ 138: "rt_sigqueueinfo",
+ 139: "rt_sigreturn",
+ 140: "setpriority",
+ 141: "getpriority",
+ 142: "reboot",
+ 143: "setregid",
+ 144: "setgid",
+ 145: "setreuid",
+ 146: "setuid",
+ 147: "setresuid",
+ 148: "getresuid",
+ 149: "setresgid",
+ 150: "getresgid",
+ 151: "setfsuid",
+ 152: "setfsgid",
+ 153: "times",
+ 154: "setpgid",
+ 155: "getpgid",
+ 156: "getsid",
+ 157: "setsid",
+ 158: "getgroups",
+ 159: "setgroups",
+ 160: "uname",
+ 161: "sethostname",
+ 162: "setdomainname",
+ 163: "getrlimit",
+ 164: "setrlimit",
+ 165: "getrusage",
+ 166: "umask",
+ 167: "prctl",
+ 168: "getcpu",
+ 169: "gettimeofday",
+ 170: "settimeofday",
+ 171: "adjtimex",
+ 172: "getpid",
+ 173: "getppid",
+ 174: "getuid",
+ 175: "geteuid",
+ 176: "getgid",
+ 177: "getegid",
+ 178: "gettid",
+ 179: "sysinfo",
+ 180: "mq_open",
+ 181: "mq_unlink",
+ 182: "mq_timedsend",
+ 183: "mq_timedreceive",
+ 184: "mq_notify",
+ 185: "mq_getsetattr",
+ 186: "msgget",
+ 187: "msgctl",
+ 188: "msgrcv",
+ 189: "msgsnd",
+ 190: "semget",
+ 191: "semctl",
+ 192: "semtimedop",
+ 193: "semop",
+ 194: "shmget",
+ 195: "shmctl",
+ 196: "shmat",
+ 197: "shmdt",
+ 198: "socket",
+ 199: "socketpair",
+ 200: "bind",
+ 201: "listen",
+ 202: "accept",
+ 203: "connect",
+ 204: "getsockname",
+ 205: "getpeername",
+ 206: "sendto",
+ 207: "recvfrom",
+ 208: "setsockopt",
+ 209: "getsockopt",
+ 210: "shutdown",
+ 211: "sendmsg",
+ 212: "recvmsg",
+ 213: "readahead",
+ 214: "brk",
+ 215: "munmap",
+ 216: "mremap",
+ 217: "add_key",
+ 218: "request_key",
+ 219: "keyctl",
+ 220: "clone",
+ 221: "execve",
+ 222: "mmap",
+ 223: "fadvise64",
+ 224: "swapon",
+ 225: "swapoff",
+ 226: "mprotect",
+ 227: "msync",
+ 228: "mlock",
+ 229: "munlock",
+ 230: "mlockall",
+ 231: "munlockall",
+ 232: "mincore",
+ 233: "madvise",
+ 234: "remap_file_pages",
+ 235: "mbind",
+ 236: "get_mempolicy",
+ 237: "set_mempolicy",
+ 238: "migrate_pages",
+ 239: "move_pages",
+ 240: "rt_tgsigqueueinfo",
+ 241: "perf_event_open",
+ 242: "accept4",
+ 243: "recvmmsg",
+ 260: "wait4",
+ 261: "prlimit64",
+ 262: "fanotify_init",
+ 263: "fanotify_mark",
+ 264: "name_to_handle_at",
+ 265: "open_by_handle_at",
+ 266: "clock_adjtime",
+ 267: "syncfs",
+ 268: "setns",
+ 269: "sendmmsg",
+ 270: "process_vm_readv",
+ 271: "process_vm_writev",
+ 272: "kcmp",
+ 273: "finit_module",
+ 274: "sched_setattr",
+ 275: "sched_getattr",
+ 276: "renameat2",
+ 277: "seccomp",
+ 278: "getrandom",
+ 279: "memfd_create",
+ 280: "bpf",
+ 281: "execveat",
+ 282: "userfaultfd",
+ 283: "membarrier",
+ 284: "mlock2",
+ 285: "copy_file_range",
+ 286: "preadv2",
+ 287: "pwritev2",
+ 288: "pkey_mprotect",
+ 289: "pkey_alloc",
+ 290: "pkey_free",
+ 291: "statx",
+ 292: "io_pgetevents",
+ 293: "rseq",
+ 294: "kexec_file_load",
+ 424: "pidfd_send_signal",
+ 425: "io_uring_setup",
+ 426: "io_uring_enter",
+ 427: "io_uring_register",
+ 428: "open_tree",
+ 429: "move_mount",
+ 430: "fsopen",
+ 431: "fsconfig",
+ 432: "fsmount",
+ 433: "fspick",
+ 434: "pidfd_open",
+ 435: "clone3",
+ 436: "close_range",
+ 437: "openat2",
+ 438: "pidfd_getfd",
+ 439: "faccessat2",
+}
+
+SOCKET_SYSCALL_NAMES = set((
+ "socket",
+ "socketpair",
+ "connect",
+ "sendto",
+ "recvfrom",
+ "sendmsg",
+ "recvmsg",
+ "bind",
+ "listen",
+ "accept",
+ "getsockname",
+ "getpeername",
+ "getsockopt",
+ "setsockopt",
+ "shutdown",
+))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/syscall/linux/x86_64.py
new/python-ptrace-0.9.8/ptrace/syscall/linux/x86_64.py
--- old/python-ptrace-0.9.7/ptrace/syscall/linux/x86_64.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/syscall/linux/x86_64.py 2021-03-17
21:19:45.000000000 +0100
@@ -1,4 +1,4 @@
-# Linux kernel 2.6.23 on Intel Core2 Duo E6400
+# Linux kernel 5.8.0 on Intel Xeon E5-2670
SYSCALL_NAMES = {
0: "read",
1: "write",
@@ -286,6 +286,108 @@
283: "timerfd",
284: "eventfd",
285: "fallocate",
+ 286: "timerfd_settime",
+ 287: "timerfd_gettime",
+ 288: "accept4",
+ 289: "signalfd4",
+ 290: "eventfd2",
+ 291: "epoll_create1",
+ 292: "dup3",
+ 293: "pipe2",
+ 294: "inotify_init1",
+ 295: "preadv",
+ 296: "pwritev",
+ 297: "rt_tgsigqueueinfo",
+ 298: "perf_event_open",
+ 299: "recvmmsg",
+ 300: "fanotify_init",
+ 301: "fanotify_mark",
+ 302: "prlimit64",
+ 303: "name_to_handle_at",
+ 304: "open_by_handle_at",
+ 305: "clock_adjtime",
+ 306: "syncfs",
+ 307: "sendmmsg",
+ 308: "setns",
+ 309: "getcpu",
+ 310: "process_vm_readv",
+ 311: "process_vm_writev",
+ 312: "kcmp",
+ 313: "finit_module",
+ 314: "sched_setattr",
+ 315: "sched_getattr",
+ 316: "renameat2",
+ 317: "seccomp",
+ 318: "getrandom",
+ 319: "memfd_create",
+ 320: "kexec_file_load",
+ 321: "bpf",
+ 322: "execveat",
+ 323: "userfaultfd",
+ 324: "membarrier",
+ 325: "mlock2",
+ 326: "copy_file_range",
+ 327: "preadv2",
+ 328: "pwritev2",
+ 329: "pkey_mprotect",
+ 330: "pkey_alloc",
+ 331: "pkey_free",
+ 332: "statx",
+ 333: "io_pgetevents",
+ 334: "rseq",
+ 424: "pidfd_send_signal",
+ 425: "io_uring_setup",
+ 426: "io_uring_enter",
+ 427: "io_uring_register",
+ 428: "open_tree",
+ 429: "move_mount",
+ 430: "fsopen",
+ 431: "fsconfig",
+ 432: "fsmount",
+ 433: "fspick",
+ 434: "pidfd_open",
+ 435: "clone3",
+ 436: "close_range",
+ 437: "openat2",
+ 438: "pidfd_getfd",
+ 439: "faccessat2",
+ 440: "process_madvise",
+ 512: "rt_sigaction",
+ 513: "rt_sigreturn",
+ 514: "ioctl",
+ 515: "readv",
+ 516: "writev",
+ 517: "recvfrom",
+ 518: "sendmsg",
+ 519: "recvmsg",
+ 520: "execve",
+ 521: "ptrace",
+ 522: "rt_sigpending",
+ 523: "rt_sigtimedwait",
+ 524: "rt_sigqueueinfo",
+ 525: "sigaltstack",
+ 526: "timer_create",
+ 527: "mq_notify",
+ 528: "kexec_load",
+ 529: "waitid",
+ 530: "set_robust_list",
+ 531: "get_robust_list",
+ 532: "vmsplice",
+ 533: "move_pages",
+ 534: "preadv",
+ 535: "pwritev",
+ 536: "rt_tgsigqueueinfo",
+ 537: "recvmmsg",
+ 538: "sendmmsg",
+ 539: "process_vm_readv",
+ 540: "process_vm_writev",
+ 541: "setsockopt",
+ 542: "getsockopt",
+ 543: "io_setup",
+ 544: "io_submit",
+ 545: "execveat",
+ 546: "preadv2",
+ 547: "pwritev2",
}
SOCKET_SYSCALL_NAMES = set((
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/syscall/names.py
new/python-ptrace-0.9.8/ptrace/syscall/names.py
--- old/python-ptrace-0.9.7/ptrace/syscall/names.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/syscall/names.py 2021-03-17
21:19:45.000000000 +0100
@@ -1,4 +1,4 @@
-from ptrace.cpu_info import CPU_X86_64, CPU_I386, CPU_PPC64, CPU_PPC32
+from ptrace.cpu_info import CPU_X86_64, CPU_I386, CPU_PPC64, CPU_PPC32,
CPU_AARCH64
from ptrace.os_tools import RUNNING_LINUX, RUNNING_FREEBSD
if RUNNING_LINUX:
if CPU_X86_64:
@@ -9,6 +9,8 @@
from ptrace.syscall.linux.powerpc64 import SYSCALL_NAMES,
SOCKET_SYSCALL_NAMES
elif CPU_PPC32:
from ptrace.syscall.linux.powerpc32 import SYSCALL_NAMES,
SOCKET_SYSCALL_NAMES
+ elif CPU_AARCH64:
+ from ptrace.syscall.linux.aarch64 import SYSCALL_NAMES,
SOCKET_SYSCALL_NAMES
else:
raise NotImplementedError("Unsupported CPU architecture")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/syscall/prototypes.py
new/python-ptrace-0.9.8/ptrace/syscall/prototypes.py
--- old/python-ptrace-0.9.7/ptrace/syscall/prototypes.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/syscall/prototypes.py 2021-03-17
21:19:45.000000000 +0100
@@ -1558,6 +1558,13 @@
("size_t", "sz"),
("struct statfs64 *", "buf"),
)),
+ "statx": ("long", (
+ ("int", "dirfd"),
+ ("const char *", "pathname"),
+ ("int", "flags"),
+ ("unsigned int", "mask"),
+ ("struct statx *", "statxbuf"),
+ )),
"stime": ("long", (
("time_t *", "tptr"),
)),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/syscall/ptrace_syscall.py
new/python-ptrace-0.9.8/ptrace/syscall/ptrace_syscall.py
--- old/python-ptrace-0.9.7/ptrace/syscall/ptrace_syscall.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/ptrace/syscall/ptrace_syscall.py 2021-03-17
21:19:45.000000000 +0100
@@ -1,7 +1,7 @@
from os import strerror
from errno import errorcode
-from ptrace.cpu_info import CPU_X86_64, CPU_POWERPC, CPU_I386, CPU_ARM
+from ptrace.cpu_info import CPU_X86_64, CPU_POWERPC, CPU_I386, CPU_ARM32,
CPU_AARCH64
from ptrace.ctypes_tools import ulong2long, formatAddress, formatWordHex
from ptrace.func_call import FunctionCall
from ptrace.syscall import SYSCALL_NAMES, SYSCALL_PROTOTYPES, SyscallArgument
@@ -12,8 +12,10 @@
if CPU_POWERPC:
SYSCALL_REGISTER = "gpr0"
-elif CPU_ARM:
+elif CPU_ARM32:
SYSCALL_REGISTER = "r7"
+elif CPU_AARCH64:
+ SYSCALL_REGISTER = "r8"
elif RUNNING_LINUX:
if CPU_X86_64:
SYSCALL_REGISTER = "orig_rax"
@@ -25,7 +27,9 @@
else:
SYSCALL_REGISTER = "eax"
-if CPU_ARM:
+if CPU_ARM32:
+ RETURN_VALUE_REGISTER = "r0"
+elif CPU_AARCH64:
RETURN_VALUE_REGISTER = "r0"
elif CPU_I386:
RETURN_VALUE_REGISTER = "eax"
@@ -84,8 +88,10 @@
def readArgumentValues(self, regs):
if CPU_X86_64:
return (regs.rdi, regs.rsi, regs.rdx, regs.r10, regs.r8, regs.r9)
- if CPU_ARM:
+ if CPU_ARM32:
return (regs.r0, regs.r1, regs.r2, regs.r3, regs.r4, regs.r5,
regs.r6)
+ if CPU_AARCH64:
+ return (regs.r0, regs.r1, regs.r2, regs.r3, regs.r4, regs.r5,
regs.r6, regs.r7)
if RUNNING_BSD:
sp = self.process.getStackPointer()
return [self.process.readWord(sp + index * CPU_WORD_SIZE)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/tools.py
new/python-ptrace-0.9.8/ptrace/tools.py
--- old/python-ptrace-0.9.7/ptrace/tools.py 2020-08-10 23:27:31.000000000
+0200
+++ new/python-ptrace-0.9.8/ptrace/tools.py 2021-03-17 21:19:45.000000000
+0100
@@ -153,3 +153,15 @@
for key, value in data.items():
result[value] = key
return result
+
+
+def signal_to_exitcode(signum):
+ """
+ Converts a signal number to an exit code.
+ UNIX: https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
+
+ >>> import signal
+ >>> signal_to_exitcode(signal.SIGQUIT)
+ 131
+ """
+ return 128 + signum
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/ptrace/version.py
new/python-ptrace-0.9.8/ptrace/version.py
--- old/python-ptrace-0.9.7/ptrace/version.py 2020-08-10 23:27:31.000000000
+0200
+++ new/python-ptrace-0.9.8/ptrace/version.py 2021-03-17 21:19:45.000000000
+0100
@@ -1,5 +1,5 @@
PACKAGE = "python-ptrace"
-VERSION = (0, 9, 7)
+VERSION = (0, 9, 8)
__version__ = '.'.join(map(str, VERSION))
WEBSITE = "http://python-ptrace.readthedocs.io/"
LICENSE = "GNU GPL v2"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/setup.py
new/python-ptrace-0.9.8/setup.py
--- old/python-ptrace-0.9.7/setup.py 2020-08-10 23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/setup.py 2021-03-17 21:19:45.000000000 +0100
@@ -11,8 +11,8 @@
# - Remove untracked files/dirs: git clean -fdx
# - run tests, type: tox --parallel auto
# - git push
-# - check Travis status:
-# https://travis-ci.com/github/vstinner/python-ptrace
+# - check GitHub Actions status:
+# https://github.com/vstinner/python-ptrace/actions
#
# Release a new version:
#
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/strace.py
new/python-ptrace-0.9.8/strace.py
--- old/python-ptrace-0.9.7/strace.py 2020-08-10 23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/strace.py 2021-03-17 21:19:45.000000000 +0100
@@ -10,6 +10,8 @@
from logging import getLogger, error
from ptrace.error import PTRACE_ERRORS, writeError
from ptrace.ctypes_tools import formatAddress
+from ptrace.tools import signal_to_exitcode
+import sys
import re
@@ -156,7 +158,7 @@
def syscallTrace(self, process):
# First query to break at next syscall
self.prepareProcess(process)
-
+ exitcode = 0
while True:
# No more process? Exit
if not self.debugger:
@@ -167,10 +169,13 @@
event = self.debugger.waitSyscall()
except ProcessExit as event:
self.processExited(event)
+ if event.exitcode is not None:
+ exitcode = event.exitcode
continue
except ProcessSignal as event:
event.display()
event.process.syscall(event.signum)
+ exitcode = signal_to_exitcode(event.signum)
continue
except NewProcessEvent as event:
self.newProcess(event)
@@ -181,6 +186,7 @@
# Process syscall enter or exit
self.syscall(event.process)
+ return exitcode
def syscall(self, process):
state = process.syscall_state
@@ -234,30 +240,39 @@
)
self.syscall_options.instr_pointer = self.options.show_ip
- self.syscallTrace(process)
+ return self.syscallTrace(process)
def main(self):
if self.options.profiler:
from ptrace.profiler import runProfiler
- runProfiler(getLogger(), self._main)
+ exitcode = runProfiler(getLogger(), self._main)
else:
- self._main()
+ exitcode = self._main()
if self._output is not None:
self._output.close()
+ sys.exit(exitcode)
def _main(self):
self.debugger = PtraceDebugger()
+ exitcode = 0
try:
- self.runDebugger()
+ exitcode = self.runDebugger()
except ProcessExit as event:
self.processExited(event)
+ if event.exitcode is not None:
+ exitcode = event.exitcode
except PtraceError as err:
error("ptrace() error: %s" % err)
+ if err.errno is not None:
+ exitcode = err.errno
except KeyboardInterrupt:
error("Interrupted.")
+ exitcode = 1
except PTRACE_ERRORS as err:
writeError(getLogger(), err, "Debugger error")
+ exitcode = 1
self.debugger.quit()
+ return exitcode
def createChild(self, program):
pid = Application.createChild(self, program)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/tests/test_gdb.py
new/python-ptrace-0.9.8/tests/test_gdb.py
--- old/python-ptrace-0.9.7/tests/test_gdb.py 2020-08-10 23:27:31.000000000
+0200
+++ new/python-ptrace-0.9.8/tests/test_gdb.py 2021-03-17 21:19:45.000000000
+0100
@@ -54,7 +54,7 @@
def test_where(self):
stdout = self.run_command('where')
- self.check_stdout(b'^CODE: ', stdout)
+ self.check_stdout(b'^CODE:', stdout)
def test_regs(self):
# Just check that the command doesn't raise an exception
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-ptrace-0.9.7/tests/test_strace.py
new/python-ptrace-0.9.8/tests/test_strace.py
--- old/python-ptrace-0.9.7/tests/test_strace.py 2020-08-10
23:27:31.000000000 +0200
+++ new/python-ptrace-0.9.8/tests/test_strace.py 2021-03-17
21:19:45.000000000 +0100
@@ -5,14 +5,15 @@
import sys
import tempfile
import unittest
+import signal
+STRACE = os.path.normpath(
+ os.path.join(os.path.dirname(__file__), '..', 'strace.py'))
-STRACE = os.path.normpath(os.path.join(
- os.path.dirname(__file__), '..', 'strace.py'))
+AARCH64 = (getattr(os.uname(), 'machine', None) == 'aarch64')
class TestStrace(unittest.TestCase):
-
def strace(self, *args):
""" Strace the given command and return the strace output. """
with tempfile.NamedTemporaryFile(mode='wb+') as temp:
@@ -21,32 +22,42 @@
proc = subprocess.Popen(args,
stdout=devnull,
stderr=subprocess.STDOUT)
- proc.wait()
+ exitcode = proc.wait()
temp.seek(0)
strace = temp.readlines()
strace = b''.join(strace)
self.assertIsNone(re.match(b'^Traceback', strace), strace)
- return strace
+ return strace, exitcode
def assert_syscall(self, code, regex):
"""
Strace the given python code and match the strace output against the
given regular expression.
"""
- stdout = self.strace(sys.executable, '-c', code)
+ stdout, _ = self.strace(sys.executable, '-c', code)
pattern = re.compile(regex, re.MULTILINE)
self.assertTrue(pattern.search(stdout), stdout)
def test_basic(self):
- stdout = self.strace(sys.executable, '-c', 'pass')
+ stdout, _ = self.strace(sys.executable, '-c', 'pass')
for syscall in (b'exit', b'mmap', b'open'):
pattern = re.compile(b'^' + syscall, re.MULTILINE)
self.assertTrue(pattern.search(stdout), stdout)
+ def test_exitcode(self):
+ for ec in range(2):
+ stdout, exitcode = self.strace(sys.executable, '-c', 'exit(%d)' %
ec)
+ self.assertEqual(exitcode, ec)
+
+ def test_exitsignal(self):
+ signum = int(signal.SIGQUIT)
+ stdout, exitcode = self.strace(sys.executable, '-c', 'import os;
os.kill(os.getpid(), %d)' % signum)
+ self.assertEqual(exitcode, (127 + 1) + signum)
+
def test_getcwd(self):
cwd = os.getcwd()
- stdout = self.strace(sys.executable, '-c', 'import os; os.getcwd()')
+ stdout, _ = self.strace(sys.executable, '-c', 'import os; os.getcwd()')
pattern = re.compile(b'^getcwd\\((.*),', re.MULTILINE)
match = pattern.search(stdout)
self.assertTrue(match, stdout)
@@ -56,29 +67,34 @@
def test_open(self):
code = 'open(%a).close()' % __file__
- self.assert_syscall(code,
- br"^open(at)?\(.*test_strace\.pyc?',
O_RDONLY(\|O_CLOEXEC)?")
+ self.assert_syscall(
+ code, br"^open(at)?\(.*test_strace\.pyc?', O_RDONLY(\|O_CLOEXEC)?")
def test_chdir(self):
- self.assert_syscall(
- "import os; os.chdir('directory')",
- br"^chdir\('directory'\)\s+= -2 ENOENT")
+ self.assert_syscall("import os; os.chdir('directory')",
+ br"^chdir\('directory'\)\s+= -2 ENOENT")
def test_rename(self):
- self.assert_syscall(
- "import os; os.rename('oldpath', 'newpath')",
- br"^rename\('oldpath', 'newpath'\)")
+ pattern = br"^rename\('oldpath', 'newpath'\)"
+ if AARCH64:
+ pattern = br"^renameat\(.*'oldpath'.*'newpath'\)"
+ self.assert_syscall("import os; os.rename('oldpath', 'newpath')",
+ pattern)
def test_link(self):
- self.assert_syscall(
- "import os; os.link('oldpath', 'newpath')",
- br"^link\('oldpath', 'newpath'\)")
+ pattern = br"^link\('oldpath', 'newpath'\)"
+ if AARCH64:
+ pattern = br"^linkat\(.*'oldpath'.*'newpath'.*\)"
+ self.assert_syscall("import os; os.link('oldpath', 'newpath')",
+ pattern)
def test_symlink(self):
+ pattern = br"^symlink\('target', 'linkpath'\)"
+ if AARCH64:
+ pattern = br"^symlinkat\(.*'target'.*'linkpath'\)"
try:
- self.assert_syscall(
- "import os; os.symlink('target', 'linkpath')",
- br"^symlink\('target', 'linkpath'\)")
+ self.assert_syscall("import os; os.symlink('target', 'linkpath')",
+ pattern)
finally:
try:
os.unlink('linkpath')
++++++ python-ptrace-pr81-importlib.patch ++++++
>From 80e0c97a84eccb8b82737cf40b9c5581c20c245f Mon Sep 17 00:00:00 2001
From: Mario Haustein <[email protected]>
Date: Sat, 16 Sep 2023 13:49:43 +0200
Subject: [PATCH] Remove deprecated `imp` module
---
setup.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index 4d6ba36..ad54f9a 100755
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@
# - git commit -a -m "post-release"
# - git push
-from imp import load_source
+import importlib.util
from os import path
try:
# setuptools supports bdist_wheel
@@ -55,7 +55,10 @@
with open('README.rst') as fp:
LONG_DESCRIPTION = fp.read()
-ptrace = load_source("version", path.join("ptrace", "version.py"))
+ptrace_spec = importlib.util.spec_from_file_location("version",
path.join("ptrace", "version.py"))
+ptrace = importlib.util.module_from_spec(ptrace_spec)
+ptrace_spec.loader.exec_module(ptrace)
+
PACKAGES = {}
for name in MODULES:
PACKAGES[name] = name.replace(".", "/")
++++++ python-ptrace-pr83-importlib.patch ++++++
>From 41f5378bbf4bfa75970d5cc3f6615411cff61a6c Mon Sep 17 00:00:00 2001
From: Stephen Kitt <[email protected]>
Date: Sun, 10 Dec 2023 19:07:27 +0100
Subject: [PATCH] Use importlib instead of imp in setup_cptrace.py
Signed-off-by: Stephen Kitt <[email protected]>
---
setup_cptrace.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/setup_cptrace.py b/setup_cptrace.py
index 8de9d01..f06b792 100755
--- a/setup_cptrace.py
+++ b/setup_cptrace.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+import importlib.util
+
SOURCES = ['cptrace/cptrace.c']
CLASSIFIERS = [
@@ -17,7 +19,6 @@
def main():
- from imp import load_source
from os import path
from sys import argv
@@ -29,7 +30,10 @@ def main():
cptrace_ext = Extension('cptrace', sources=SOURCES)
- cptrace = load_source("version", path.join("cptrace", "version.py"))
+ cptrace_spec = importlib.util.spec_from_file_location("version",
+ path.join("cptrace",
"version.py"))
+ cptrace = importlib.util.module_from_spec(cptrace_spec)
+ cptrace_spec.loader.exec_module(cptrace)
install_options = {
"name": cptrace.PACKAGE,