Source: reptyr
Version: 0.9.0-1
Severity: normal
Tags: patch
User: debian-loonga...@lists.debian.org
Usertags: loong64
Dear maintainers,
The reptyr source package lacks LoongArch64 architecture support.
I have added support for loongarch64 in reptyr package and built
successfully on my local ENV.
Please consider the patch I attached.
The support for loongarch64 since python3.* in the Debian Package
Auto-Building environment.
I modify the PYTHON_CMD version in Makefile locally.
```
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man
PKG_CONFIG ?= pkg-config
-PYTHON_CMD ?= python2
+PYTHON_CMD ?= python3 //Local modify
```
Please consider to update the PYTHON_CMD version in reptyr source package.
Could you add loongarch64 support in the next upload?
Your opinions are welcome.
Thanks
Dandan Zhang
diff -Nru reptyr-0.9.0/debian/control reptyr-0.9.0/debian/control
--- reptyr-0.9.0/debian/control 2022-06-15 23:11:19.000000000 +0000
+++ reptyr-0.9.0/debian/control 2022-06-15 23:11:19.000000000 +0000
@@ -13,7 +13,7 @@
Vcs-Browser: https://github.com/nelhage/reptyr/tree/debian
Package: reptyr
-Architecture: i386 amd64 armel armhf arm64 powerpc ppc64el riscv64
+Architecture: i386 amd64 armel armhf arm64 powerpc ppc64el riscv64 loong64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Tool for moving running programs between ptys
reptyr is a utility for taking an existing running program and
diff -Nru reptyr-0.9.0/debian/patches/reptyr-add-loongarch64-support.patch
reptyr-0.9.0/debian/patches/reptyr-add-loongarch64-support.patch
--- reptyr-0.9.0/debian/patches/reptyr-add-loongarch64-support.patch
1970-01-01 00:00:00.000000000 +0000
+++ reptyr-0.9.0/debian/patches/reptyr-add-loongarch64-support.patch
2022-06-15 23:11:19.000000000 +0000
@@ -0,0 +1,104 @@
+Description: Add loongarch64 support
+Last-Update: 2024-07-11
+
+--- reptyr-0.9.0.orig/Makefile
++++ reptyr-0.9.0/Makefile
+@@ -18,7 +18,7 @@ BINDIR=$(PREFIX)/bin
+ MANDIR=$(PREFIX)/share/man
+
+ PKG_CONFIG ?= pkg-config
+-PYTHON_CMD ?= python2
++PYTHON_CMD ?= python3 //Local modify
+
+ all: reptyr
+
+--- /dev/null
++++ reptyr-0.9.0/platform/linux/arch/loongarch64.h
+@@ -0,0 +1,64 @@
++/*
++ * Copyright (C) 2023 by Nelson Elhage
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
copy
++ * of this software and associated documentation files (the "Software"), to
deal
++ * in the Software without restriction, including without limitation the
rights
++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the Software is
++ * furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
++ * THE SOFTWARE.
++ */
++static struct ptrace_personality arch_personality[1] = {
++ {
++ offsetof(struct user_regs_struct, regs[4]),
++ offsetof(struct user_regs_struct, regs[4]),
++ offsetof(struct user_regs_struct, regs[5]),
++ offsetof(struct user_regs_struct, regs[6]),
++ offsetof(struct user_regs_struct, regs[7]),
++ offsetof(struct user_regs_struct, regs[8]),
++ offsetof(struct user_regs_struct, regs[9]),
++ offsetof(struct user_regs_struct, csr_era),
++ }
++};
++
++static inline void arch_fixup_regs(struct ptrace_child *child) {
++ child->regs.csr_era -= 4;
++}
++
++static inline int arch_set_syscall(struct ptrace_child *child,
++ unsigned long sysno) {
++ unsigned long syscall_reg = sysno;
++ struct iovec reg_iovec = {
++ .iov_base = &syscall_reg,
++ .iov_len = sizeof(syscall_reg)
++ };
++ return ptrace_command(child, PTRACE_SETREGSET, NT_PRSTATUS, ®_iovec);
++}
++
++static inline int arch_save_syscall(struct ptrace_child *child) {
++ unsigned long syscall_reg;
++ struct iovec reg_iovec = {
++ .iov_base = &syscall_reg,
++ .iov_len = sizeof(syscall_reg)
++ };
++ if (ptrace_command(child, PTRACE_GETREGSET, NT_PRSTATUS, ®_iovec) < 0)
++ return -1;
++
++ child->saved_syscall = syscall_reg;
++ return 0;
++}
++
++static inline int arch_restore_syscall(struct ptrace_child *child) {
++ return arch_set_syscall(child, child->saved_syscall);
++}
+--- reptyr-0.9.0.orig/platform/linux/linux_ptrace.c
++++ reptyr-0.9.0/platform/linux/linux_ptrace.c
+@@ -86,6 +86,8 @@ static struct ptrace_personality *person
+ #include "arch/powerpc.h"
+ #elif defined(__riscv) && __riscv_xlen == 64
+ #include "arch/riscv64.h"
++#elif defined(__loongarch64)
++#include "arch/loongarch64.h"
+ #else
+ #error Unsupported architecture.
+ #endif
+--- reptyr-0.9.0.orig/ptrace.h
++++ reptyr-0.9.0/ptrace.h
+@@ -28,6 +28,9 @@
+ #ifdef __riscv
+ #include <asm/ptrace.h>
+ #endif
++#ifdef __loongarch64
++#include <asm/ptrace.h>
++#endif
+ #include <sys/ptrace.h>
+ #include <sys/types.h>
+ #include <sys/user.h>
diff -Nru reptyr-0.9.0/debian/patches/series reptyr-0.9.0/debian/patches/series
--- reptyr-0.9.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000
+++ reptyr-0.9.0/debian/patches/series 2022-06-15 23:11:19.000000000 +0000
@@ -0,0 +1 @@
+reptyr-add-loongarch64-support.patch