diff --git a/0001-add-loongarch64-support.patch b/0001-add-loongarch64-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..f5fdb7829f8a1ff7ef67d1b0471edb506bcb6bc1 --- /dev/null +++ b/0001-add-loongarch64-support.patch @@ -0,0 +1,74 @@ +From e82e3332d36a97a86cc1e23e7f3c6e953a1ada2c Mon Sep 17 00:00:00 2001 +From: doupengda +Date: Wed, 14 Dec 2022 02:58:36 +0000 +Subject: [PATCH] add loongarch64 support + +--- + configure | 6 +- + machines.h | 31 +++++++ + tags | 252 +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 288 insertions(+), 1 deletion(-) + create mode 100644 tags + +diff --git a/configure b/configure +index 7c7280f..60fd170 100755 +--- a/configure ++++ b/configure +@@ -59,9 +59,13 @@ case `uname -m` in + machine="aarch64" + CFLAGS="$CFLAGS -DMLX_AARCH64" + ;; ++'loongarch64') ++ machine="loongarch64" ++ CFLAGS="$CFLAGS -DMLX_LOONGARCH64" ++ ;; + *) + echo "Error: unsupported machine: `uname -m`." +- echo "Only x86, x86_64, arm, and aarch64 are supported." ++ echo "Only x86, x86_64, arm, loongarch and aarch64 are supported." + exit 2 + ;; + esac +diff --git a/machines.h b/machines.h +index cbbe69d..4472bd1 100644 +--- a/machines.h ++++ b/machines.h +@@ -87,6 +87,37 @@ static inline int is_breakpoint(pid_t pid, uintptr_t address) + return (ptrace_get_data(pid, address) & 0xFF) == 0xCC; + } + ++#elif defined(MLX_LOONGARCH64) ++static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs) ++{ ++ return ptrace_get_data(pid, regs->gpr[3]); ++} ++static inline uintptr_t call_return_value(registers_info_t *regs) ++{ ++ return regs->gpr[1]; ++} ++static inline uintptr_t call_arg1(pid_t pid, registers_info_t *regs) ++{ ++ return regs->gpr[6]; ++} ++static inline uintptr_t call_arg2(pid_t pid, registers_info_t *regs) ++{ ++ return regs->gpr[7]; ++} ++static inline uintptr_t pc_unwind(pid_t pid, registers_info_t *regs) ++{ ++ return regs->pc; ++} ++static inline void set_breakpoint(pid_t pid, uintptr_t address, uintptr_t code) ++{ ++ ptrace_set_data(pid, address, (code & 0x002a0000)); ++} ++static inline int is_breakpoint(pid_t pid, uintptr_t address) ++{ ++ return ptrace_get_data(pid, address) == 0x002a0000; ++} ++ ++ + #elif defined(MLX_ARMv7) + static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs) + { + diff --git a/memleax.spec b/memleax.spec index e25adad95cb42ae24f882fea8ce33151f05d335b..d2aee0d483d944ed864f9491a9f240b34c3d00d7 100644 --- a/memleax.spec +++ b/memleax.spec @@ -1,10 +1,11 @@ Name: memleax Version: 1.1.1 -Release: 5 +Release: 6 Summary: Memory lead detection tool License: GPLv2 URL: https://github.com/WuBingzheng/memleax Source0: https://github.com/WuBingzheng/memleax/archive/v%{version}.tar.gz#/memleax-%{version}.tar.gz +Patch0: 0001-add-loongarch64-support.patch BuildRequires: make libunwind-devel elfutils-devel gcc @@ -24,7 +25,8 @@ memleax follows new threads, but not forked processes. If you want to debug multiple processes, just run multiple memleax. %prep -%setup -q -n %{name}-%{version}/ +%setup -q +%autosetup -n %{name}-%{version} -p1 %build ./configure @@ -46,6 +48,9 @@ make install DESTDIR="%{buildroot}" %{_mandir}/man1/%{name}.1* %changelog +* Wed Dec 14 2022 doupengda - 1.1.1-6 +- add loongarch64 support + * Wed Aug 04 2021 chenyanpanHW - 1.1.1-5 - DESC: delete BuildRequires gdb