Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
48046202b3
!28 add support sw_64
From: @maqi77 
Reviewed-by: @wk333 
Signed-off-by: @wk333
2025-02-19 08:58:13 +00:00
maqi
64ff73b2d2 add support sw_64 2025-02-17 13:18:08 +08:00
openeuler-ci-bot
7b2e13fdc6
!24 Resolve compilation errors for loongarch64
From: @fuowang 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
2024-05-20 09:28:15 +00:00
wangshuo
4376fb0387 Resolve compilation errors for loongarch64 2024-05-13 23:19:29 +08:00
openeuler-ci-bot
e0f5e0952b
!14 Add riscv64 support
From: @a-xiang-and-shanhaijing 
Reviewed-by: @overweight 
Signed-off-by: @overweight
2023-08-17 07:39:59 +00:00
zhangxiang
35c6cdd3c4 add riscv64 support Co-authored-by: EastDong <xudong23@iscas.ac.cn> 2023-06-30 17:34:05 +08:00
openeuler-ci-bot
8bd4dadce8
!10 add loongarch64 support
From: @dpdwaj 
Reviewed-by: @myeuler 
Signed-off-by: @myeuler
2022-12-14 03:48:52 +00:00
doupengda
8604295567 add loongarch64 support 2022-12-14 03:20:40 +00:00
openeuler-ci-bot
b13238c700 !8 memleax delete BuildRequires gdb
From: @chenyanpanHW
Reviewed-by: @myeuler
Signed-off-by: @myeuler
2021-08-19 08:08:40 +00:00
chenyanpanHW
314959566d
delete BuildRequires gdb 2021-08-04 21:09:43 +08:00
4 changed files with 304 additions and 3 deletions

View File

@ -0,0 +1,74 @@
From 26cf0d75eda1c2530640b8bf9699785a47c78a24 Mon Sep 17 00:00:00 2001
From: doupengda <doupengda@loongson.cn>
Date: Tue, 14 May 2024 11:07:07 +0800
Subject: [PATCH] add loongarch64 support
---
configure | 6 +++++-
machines.h | 31 +++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
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..3e184d5 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->regs[3]);
+}
+static inline uintptr_t call_return_value(registers_info_t *regs)
+{
+ return regs->regs[1];
+}
+static inline uintptr_t call_arg1(pid_t pid, registers_info_t *regs)
+{
+ return regs->regs[6];
+}
+static inline uintptr_t call_arg2(pid_t pid, registers_info_t *regs)
+{
+ return regs->regs[7];
+}
+static inline uintptr_t pc_unwind(pid_t pid, registers_info_t *regs)
+{
+ return regs->csr_era;
+}
+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)
{
--
2.43.0

View File

@ -0,0 +1,78 @@
diff -ur memleax-1.1.1/configure memleax-1.1.1/configure
--- memleax-1.1.1/configure 2023-06-30 16:52:49.401032162 +0800
+++ memleax-1.1.1/configure 2023-06-30 16:56:52.793616961 +0800
@@ -63,9 +63,13 @@
machine="loongarch64"
CFLAGS="$CFLAGS -DMLX_LOONGARCH64"
;;
+'riscv64')
+ machine="riscv"
+ CFLAGS="$CFLAGS -DMLX_RISCV64"
+ ;;
*)
echo "Error: unsupported machine: `uname -m`."
- echo "Only x86, x86_64, arm, loongarch and aarch64 are supported."
+ echo "Only x86, x86_64, arm, loongarch, riscv and aarch64 are supported."
exit 2
;;
esac
@@ -159,7 +163,7 @@
cat << EOF > Makefile
CFLAGS = $CFLAGS -g -O2 -Wall
-LDLIBS = $LDLIBS
+LDLIBS = $LDLIBS -llzma
LDFLAGS = $LDFLAGS
PREFIX = $prefix
DESTDIR =
diff -ur memleax-1.1.1/machines.h memleax-1.1.1/machines.h
--- memleax-1.1.1/machines.h 2023-06-30 16:52:49.401032162 +0800
+++ memleax-1.1.1/machines.h 2023-06-30 16:30:58.889630806 +0800
@@ -177,6 +177,35 @@
{
return ptrace_get_data(pid, address) == 0xd4200000;
}
+#elif defined(MLX_RISCV64)
+static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs)
+{
+ return regs->ra;
+}
+static inline uintptr_t call_return_value(registers_info_t *regs)
+{
+ return regs->a0;
+}
+static inline uintptr_t call_arg1(pid_t pid, registers_info_t *regs)
+{
+ return regs->a0;
+}
+static inline uintptr_t call_arg2(pid_t pid, registers_info_t *regs)
+{
+ return regs->a1;
+}
+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, 0x00100073);
+}
+static inline int is_breakpoint(pid_t pid, uintptr_t address)
+{
+ return ptrace_get_data(pid, address) == 0x00100073;
+}
#endif
#endif
diff -ur memleax-1.1.1/ptrace_utils.h memleax-1.1.1/ptrace_utils.h
--- memleax-1.1.1/ptrace_utils.h 2018-01-04 06:05:08.000000000 +0800
+++ memleax-1.1.1/ptrace_utils.h 2023-06-30 16:31:47.693773352 +0800
@@ -16,7 +16,7 @@
#include <elf.h>
#include <sys/uio.h>
-
+#include <asm/ptrace.h>
#ifdef MLX_ARMv7
typedef struct user_regs registers_info_t;
#else

View File

@ -0,0 +1,130 @@
diff --git a/configure b/configure
index 583efbc..1bd90c5 100755
--- a/configure
+++ b/configure
@@ -67,9 +67,14 @@ case `uname -m` in
machine="riscv"
CFLAGS="$CFLAGS -DMLX_RISCV64"
;;
+'sw_64')
+ machine="sw_64"
+ CFLAGS="$CFLAGS -DMLX_SW_64"
+ LDFLAGS="$LDFLAGS -llzma"
+ ;;
*)
echo "Error: unsupported machine: `uname -m`."
- echo "Only x86, x86_64, arm, loongarch, riscv and aarch64 are supported."
+ echo "Only x86, x86_64, arm, loongarch, riscv, sw_64 and aarch64 are supported."
exit 2
;;
esac
diff --git a/machines.h b/machines.h
index c92da46..97eb696 100644
--- a/machines.h
+++ b/machines.h
@@ -206,6 +206,35 @@ static inline int is_breakpoint(pid_t pid, uintptr_t address)
{
return ptrace_get_data(pid, address) == 0x00100073;
}
+#elif defined(MLX_SW_64)
+static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs)
+{
+ return regs->regs[30];
+}
+static inline uintptr_t call_return_value(registers_info_t *regs)
+{
+ return regs->regs[0];
+}
+static inline uintptr_t call_arg1(pid_t pid, registers_info_t *regs)
+{
+ return regs->regs[0];
+}
+static inline uintptr_t call_arg2(pid_t pid, registers_info_t *regs)
+{
+ return regs->regs[1];
+}
+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, 0x00000080);
+}
+static inline int is_breakpoint(pid_t pid, uintptr_t address)
+{
+ return ptrace_get_data(pid, address) == 0x00000080;
+}
#endif
#endif
diff --git a/ptrace_utils.h b/ptrace_utils.h
index a9ef0f4..9a10327 100644
--- a/ptrace_utils.h
+++ b/ptrace_utils.h
@@ -17,8 +17,65 @@
#include <elf.h>
#include <sys/uio.h>
#include <asm/ptrace.h>
+
+#ifdef MLX_SW_64
+#ifndef __ASSEMBLY__
+
+struct pt_regs {
+ union {
+ struct user_pt_regs user_regs;
+ struct {
+ unsigned long r0;
+ unsigned long r1;
+ unsigned long r2;
+ unsigned long r3;
+ unsigned long r4;
+ unsigned long r5;
+ unsigned long r6;
+ unsigned long r7;
+ unsigned long r8;
+ unsigned long r9;
+ unsigned long r10;
+ unsigned long r11;
+ unsigned long r12;
+ unsigned long r13;
+ unsigned long r14;
+ unsigned long r15;
+ unsigned long r16;
+ unsigned long r17;
+ unsigned long r18;
+ unsigned long r19;
+ unsigned long r20;
+ unsigned long r21;
+ unsigned long r22;
+ unsigned long r23;
+ unsigned long r24;
+ unsigned long r25;
+ unsigned long r26;
+ unsigned long r27;
+ unsigned long r28;
+ unsigned long gp;
+ unsigned long sp;
+ unsigned long pc;
+ unsigned long ps;
+ };
+ };
+ /* These are saved by HMcode: */
+ unsigned long hm_ps;
+ unsigned long hm_pc;
+ unsigned long hm_gp;
+ unsigned long hm_r16;
+ unsigned long hm_r17;
+ unsigned long hm_r18;
+};
+
+#endif
+#endif
+
#ifdef MLX_ARMv7
typedef struct user_regs registers_info_t;
+ #elif (defined MLX_SW_64)
+typedef struct user_pt_regs registers_info_t;
#else
typedef struct user_regs_struct registers_info_t;
#endif

View File

@ -1,12 +1,15 @@
Name: memleax
Version: 1.1.1
Release: 4
Release: 9
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
Patch1: 0002-add-riscv64-support.patch
Patch2: 0003-add-sw_64-support-not-upstream-modified.patch
BuildRequires: make libunwind-devel elfutils-devel gdb gcc
BuildRequires: make libunwind-devel elfutils-devel gcc
%description
memleax debugs memory leak of a running process by attaching it.
@ -24,7 +27,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 +50,21 @@ make install DESTDIR="%{buildroot}"
%{_mandir}/man1/%{name}.1*
%changelog
* Mon Feb 17 2025 maqi <maqi@uniontech.com> - 1.1.1-9
- add support sw_64
* Tue May 14 2024 wangshuo <wangshuo@kylinos.cn> - 1.1.1-8
- Resolve compilation errors for loongarch64
* Fri Jun 30 2023 zhangxiang <zhangxiang@iscas.ac.cn> - 1.1.1-7
- add riscv64 support
* Wed Dec 14 2022 doupengda <doupengda@loongson.cn> - 1.1.1-6
- add loongarch64 support
* Wed Aug 04 2021 chenyanpanHW <chenyanpan@huawei.com> - 1.1.1-5
- DESC: delete BuildRequires gdb
* Mon Jun 28 2021 wulei <wulei80@huawei.com> - 1.1.1-4
- fix missing gcc