Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
e6d5eb4fd8
!22 [sync] PR-20: 添加龙芯和申威架构支持
From: @openeuler-sync-bot 
Reviewed-by: @overweight 
Signed-off-by: @overweight
2023-09-27 01:57:16 +00:00
herengui
6d61ec045c 添加龙芯和申威架构支持
Signed-off-by: herengui <herengui@kylinsec.com.cn>
(cherry picked from commit f9dd70d0d108c5cdd48ddb677ef291ccc65c07c2)
2023-09-12 09:01:07 +08:00
openeuler-ci-bot
254500df2c !6 依赖补齐-修复因缺少依赖导致编译失败问题
From: @wu-leilei
Reviewed-by: @myeuler
Signed-off-by: @myeuler
2021-06-28 11:31:29 +00:00
wu-leilei
22f7248198 add buildrequires gcc 2021-06-28 17:21:24 +08:00
openeuler-ci-bot
1e4916a3f3 !5 【轻量级 PR】:fix source0’s url
From: @liqingqing_1229
Reviewed-by: @love_hangzhou
Signed-off-by: @love_hangzhou
2020-10-19 19:44:37 +08:00
liqingqing_1229
801b81ed0c fix source 2020-10-19 10:36:55 +08:00
openeuler-ci-bot
9b3b2bdf72 !4 【轻量级 PR】:update source0
From: @liqingqing_1229
Reviewed-by: @love_hangzhou
Signed-off-by: @love_hangzhou
2020-10-15 14:43:23 +08:00
liqingqing_1229
754eeeacbd update source0 2020-10-13 16:20:16 +08:00
openeuler-ci-bot
67f8b4c34b !3 add yaml file for memleax
Merge pull request !3 from fcwicky/master
2020-08-13 14:13:55 +08:00
fcwicky
a4a306409e add yml file for WuBingzheng/memleax 2020-08-13 12:00:30 +08:00
4 changed files with 250 additions and 4 deletions

View File

@ -0,0 +1,74 @@
From 3546fafed9fb09e653f72f5f47034d0eba97e270 Mon Sep 17 00:00:00 2001
From: herengui <herengui@kylinsec.com.cn>
Date: Tue, 16 May 2023 15:36:25 +0800
Subject: [PATCH] add loongarch64 support
Signed-off-by: herengui <herengui@kylinsec.com.cn>
---
configure | 6 +++++-
machines.h | 30 ++++++++++++++++++++++++++++++
2 files changed, 35 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..477f060 100644
--- a/machines.h
+++ b/machines.h
@@ -87,6 +87,36 @@ 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.40.1

View File

@ -0,0 +1,153 @@
From 2ffd47cc031947d85da9f2f11139b9bbadba5daa Mon Sep 17 00:00:00 2001
From: herengui <herengui@kylinsec.com.cn>
Date: Tue, 29 Aug 2023 13:53:15 +0800
Subject: [PATCH] add sw_64 support not upstream modified
Signed-off-by: herengui <herengui@kylinsec.com.cn>
---
configure | 7 +++++-
machines.h | 30 +++++++++++++++++++++++
ptrace_utils.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 100 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 60fd170..a68210f 100755
--- a/configure
+++ b/configure
@@ -63,9 +63,14 @@ case `uname -m` in
machine="loongarch64"
CFLAGS="$CFLAGS -DMLX_LOONGARCH64"
;;
+'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 and aarch64 are supported."
+ echo "Only x86, x86_64, arm, loongarch, sw_64 and aarch64 are supported."
exit 2
;;
esac
diff --git a/machines.h b/machines.h
index 477f060..24d8ce0 100644
--- a/machines.h
+++ b/machines.h
@@ -117,6 +117,36 @@ static inline int is_breakpoint(pid_t pid, uintptr_t address)
return ptrace_get_data(pid, address) == 0x002a0000;
}
+#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;
+}
+
#elif defined(MLX_ARMv7)
static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs)
{
diff --git a/ptrace_utils.h b/ptrace_utils.h
index 5fc1cd6..1a3b888 100644
--- a/ptrace_utils.h
+++ b/ptrace_utils.h
@@ -17,8 +17,71 @@
#include <elf.h>
#include <sys/uio.h>
- #ifdef MLX_ARMv7
+#ifdef MLX_SW_64
+#ifndef __ASSEMBLY__
+
+typedef uint64_t __u64;
+struct user_pt_regs {
+ __u64 regs[31];
+ __u64 pc;
+ __u64 pstate;
+};
+
+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
+
+ #if (defined 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
--
2.41.0

View File

@ -1,12 +1,15 @@
Name: memleax
Version: 1.1.1
Release: 1
Release: 5
Summary: Memory lead detection tool
License: GPLv2
URL: https://github.com/WuBingzheng/memleax
Source0: https://github.com/WuBingzheng/memleax/archive/memleax-%{version}.tar.gz
Source0: https://github.com/WuBingzheng/memleax/archive/v%{version}.tar.gz#/memleax-%{version}.tar.gz
BuildRequires: make libunwind-devel elfutils-devel gdb
Patch1000: 1000-add-loongarch-support-not-upstream-modified.patch
Patch1001: 1001-add-sw_64-support-not-upstream-modified.patch
BuildRequires: make libunwind-devel elfutils-devel gdb gcc
%description
memleax debugs memory leak of a running process by attaching it.
@ -24,7 +27,7 @@ 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}/
%autosetup -p1
%build
./configure
@ -46,6 +49,18 @@ make install DESTDIR="%{buildroot}"
%{_mandir}/man1/%{name}.1*
%changelog
* Tue Aug 29 2023 herengui <herengui@kylinsec.com.cn> - 1.1.1-5
- add support for loongarch64 and sw_64
* Mon Jun 28 2021 wulei <wulei80@huawei.com> - 1.1.1-4
- fix missing gcc
* Mon Oct 19 2020 Qingqing Li <liqingqing3@huawei.com>
- fix source0 error
* Tue Oct 13 2020 Qingqing Li <liqingqing3@huawei.com>
- update source0
* Sun Mar 29 2020 Wei Xiong <myeuler@163.com>
- Package init

4
memleax.yaml Normal file
View File

@ -0,0 +1,4 @@
version_control: github
src_repo: WuBingzheng/memleax
tag_prefix: "^v"
separator: "."