Compare commits
10 Commits
290e39055e
...
01a6558fb9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01a6558fb9 | ||
|
|
2b7588e49f | ||
|
|
64712f16e3 | ||
|
|
639f44667c | ||
|
|
55253a70c5 | ||
|
|
dad4b7ccd6 | ||
|
|
5f68644248 | ||
|
|
6e43ff670a | ||
|
|
76af888dba | ||
|
|
0a94943a84 |
24
0001-add-stdbool.h-to-fix-build-error.patch
Normal file
24
0001-add-stdbool.h-to-fix-build-error.patch
Normal file
@ -0,0 +1,24 @@
|
||||
From af9a2029b58ed47da03a884d3e1644f858e88921 Mon Sep 17 00:00:00 2001
|
||||
From: chen-jan <chen_aka_jan@163.com>
|
||||
Date: Wed, 21 Jun 2023 10:25:35 +0800
|
||||
Subject: [PATCH] add stdbool.h to fix build error
|
||||
|
||||
---
|
||||
src/libgcore/gcore_coredump.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c
|
||||
index 8eece96..b2e9bb3 100644
|
||||
--- a/src/libgcore/gcore_coredump.c
|
||||
+++ b/src/libgcore/gcore_coredump.c
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <defs.h>
|
||||
#include <gcore_defs.h>
|
||||
+#include <stdbool.h>
|
||||
|
||||
static struct elf_note_info *elf_note_info_init(void);
|
||||
|
||||
--
|
||||
2.39.1
|
||||
|
||||
244
0002-add-riscv64-support.patch
Normal file
244
0002-add-riscv64-support.patch
Normal file
@ -0,0 +1,244 @@
|
||||
From 21b7d6492cf0a77a74c09a370c206df623930c43 Mon Sep 17 00:00:00 2001
|
||||
From: wangjunqiang <wangjunqiang@iscas.ac.cn>
|
||||
Date: Fri, 16 Sep 2022 10:37:54 +0800
|
||||
Subject: [PATCH] add riscv64 support
|
||||
|
||||
---
|
||||
src/gcore.mk | 10 ++++
|
||||
src/libgcore/gcore_coredump.c | 2 +-
|
||||
src/libgcore/gcore_defs.h | 47 ++++++++++++++++--
|
||||
src/libgcore/gcore_riscv64.c | 91 +++++++++++++++++++++++++++++++++++
|
||||
4 files changed, 145 insertions(+), 5 deletions(-)
|
||||
create mode 100644 src/libgcore/gcore_riscv64.c
|
||||
|
||||
diff --git a/src/gcore.mk b/src/gcore.mk
|
||||
index 4af292b..e986871 100644
|
||||
--- a/src/gcore.mk
|
||||
+++ b/src/gcore.mk
|
||||
@@ -60,6 +60,12 @@ ifeq ($(shell arch), ppc64le)
|
||||
ARCH=SUPPORTED
|
||||
endif
|
||||
|
||||
+ifeq ($(shell arch), riscv64)
|
||||
+ TARGET=RISCV64
|
||||
+ TARGET_CFLAGS=
|
||||
+ ARCH=SUPPORTED
|
||||
+endif
|
||||
+
|
||||
ifeq ($(shell /bin/ls /usr/include/crash/defs.h 2>/dev/null), /usr/include/crash/defs.h)
|
||||
INCDIR=/usr/include/crash
|
||||
endif
|
||||
@@ -99,6 +105,10 @@ ifneq (,$(findstring $(TARGET), PPC64))
|
||||
GCORE_CFILES += libgcore/gcore_ppc64.c
|
||||
endif
|
||||
|
||||
+ifneq (,$(findstring $(TARGET), RISCV64))
|
||||
+GCORE_CFILES += libgcore/gcore_riscv64.c
|
||||
+endif
|
||||
+
|
||||
GCORE_OFILES = $(patsubst %.c,%.o,$(GCORE_CFILES))
|
||||
|
||||
COMMON_CFLAGS=-Wall -I$(INCDIR) -I./libgcore -fPIC -D$(TARGET) \
|
||||
diff --git a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c
|
||||
index 3d0c0fc..e9ba91a 100644
|
||||
--- a/src/libgcore/gcore_coredump.c
|
||||
+++ b/src/libgcore/gcore_coredump.c
|
||||
@@ -752,7 +752,7 @@ fill_prstatus_note(struct elf_note_info *info, struct task_context *tc,
|
||||
struct memelfnote *memnote)
|
||||
{
|
||||
struct elf_prstatus *prstatus;
|
||||
-#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS) || defined(PPC64)
|
||||
+#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS) || defined(PPC64) || defined(RISCV64)
|
||||
struct user_regs_struct *regs = (struct user_regs_struct *)memnote->data;
|
||||
#endif
|
||||
#ifdef ARM64
|
||||
diff --git a/src/libgcore/gcore_defs.h b/src/libgcore/gcore_defs.h
|
||||
index df87851..32d6553 100644
|
||||
--- a/src/libgcore/gcore_defs.h
|
||||
+++ b/src/libgcore/gcore_defs.h
|
||||
@@ -166,6 +166,34 @@
|
||||
#define Elf_Nhdr Elf64_Nhdr
|
||||
#endif
|
||||
|
||||
+#ifdef RISCV64
|
||||
+#define ELF_EXEC_PAGESIZE PAGESIZE()
|
||||
+
|
||||
+#define ELF_MACHINE EM_RISCV
|
||||
+#define ELF_OSABI ELFOSABI_NONE
|
||||
+
|
||||
+#define ELF_CLASS ELFCLASS64
|
||||
+
|
||||
+#ifndef ELF_DATA
|
||||
+#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
+#define ELF_DATA ELFDATA2LSB
|
||||
+#else
|
||||
+#define ELF_DATA ELFDATA2MSB
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+#define ELF_ARCH EM_RISCV
|
||||
+
|
||||
+#define Elf_Half Elf64_Half
|
||||
+#define Elf_Word Elf64_Word
|
||||
+#define Elf_Off Elf64_Off
|
||||
+
|
||||
+#define Elf_Ehdr Elf64_Ehdr
|
||||
+#define Elf_Phdr Elf64_Phdr
|
||||
+#define Elf_Shdr Elf64_Shdr
|
||||
+#define Elf_Nhdr Elf64_Nhdr
|
||||
+#endif
|
||||
+
|
||||
#ifndef NT_FILE
|
||||
#define NT_FILE 0x46494c45
|
||||
#endif
|
||||
@@ -329,6 +357,11 @@ extern void gcore_default_regsets_init(void);
|
||||
#define REGSET_VIEW_MACHINE EM_PPC64
|
||||
#endif
|
||||
|
||||
+#ifdef RISCV64
|
||||
+#define REGSET_VIEW_NAME "riscv64"
|
||||
+#define REGSET_VIEW_MACHINE EM_RISCV
|
||||
+#endif
|
||||
+
|
||||
extern int gcore_arch_get_fp_valid(struct task_context *tc);
|
||||
|
||||
/*
|
||||
@@ -669,7 +702,13 @@ struct user_regs_struct {
|
||||
};
|
||||
#endif
|
||||
|
||||
-#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS)
|
||||
+#ifdef RISCV64
|
||||
+struct user_regs_struct {
|
||||
+ unsigned long gregs[32];
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
+#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS) || defined(RISCV64)
|
||||
typedef ulong elf_greg_t;
|
||||
#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
|
||||
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
|
||||
@@ -678,7 +717,7 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
|
||||
#if defined(X86) || defined(ARM) || defined(MIPS)
|
||||
#define PAGE_SIZE 4096
|
||||
#endif
|
||||
-#if defined(ARM64) || defined(PPC64)
|
||||
+#if defined(ARM64) || defined(PPC64) || defined(RISCV64)
|
||||
#define PAGE_SIZE PAGESIZE()
|
||||
#endif
|
||||
|
||||
@@ -837,12 +876,12 @@ typedef unsigned short __kernel_old_uid_t;
|
||||
typedef unsigned short __kernel_old_gid_t;
|
||||
#endif
|
||||
|
||||
-#if defined(X86_64) || defined(ARM64) || defined(PPC64)
|
||||
+#if defined(X86_64) || defined(ARM64) || defined(PPC64) || defined(RISCV64)
|
||||
typedef unsigned int __kernel_uid_t;
|
||||
typedef unsigned int __kernel_gid_t;
|
||||
#endif
|
||||
|
||||
-#ifdef ARM64
|
||||
+#if defined(ARM64) || defined(RISCV64)
|
||||
#ifndef __kernel_old_uid_t
|
||||
typedef __kernel_uid_t __kernel_old_uid_t;
|
||||
typedef __kernel_gid_t __kernel_old_gid_t;
|
||||
diff --git a/src/libgcore/gcore_riscv64.c b/src/libgcore/gcore_riscv64.c
|
||||
new file mode 100644
|
||||
index 0000000..7578cdf
|
||||
--- /dev/null
|
||||
+++ b/src/libgcore/gcore_riscv64.c
|
||||
@@ -0,0 +1,91 @@
|
||||
+/* gcore_riscv64.c
|
||||
+ *
|
||||
+ * Copyright (C) 2014 Red Hat, Inc. All rights reserved
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ */
|
||||
+
|
||||
+#ifdef RISCV64
|
||||
+
|
||||
+#include "defs.h"
|
||||
+#include <gcore_defs.h>
|
||||
+#include <stdint.h>
|
||||
+#include <elf.h>
|
||||
+
|
||||
+static int gpr_get(struct task_context *target,
|
||||
+ const struct user_regset *regset,
|
||||
+ unsigned int size, void *buf)
|
||||
+{
|
||||
+ struct user_regs_struct *regs = (struct user_regs_struct *)buf;
|
||||
+
|
||||
+ BZERO(regs, sizeof(*regs));
|
||||
+
|
||||
+ readmem(machdep->get_stacktop(target->task) -
|
||||
+ SIZE(pt_regs), KVADDR,
|
||||
+ regs, SIZE(pt_regs), "gpr_get: pt_regs",
|
||||
+ gcore_verbose_error_handle());
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+enum gcore_regset {
|
||||
+ REGSET_GPR,
|
||||
+};
|
||||
+
|
||||
+static struct user_regset riscv64_regsets[] = {
|
||||
+ [REGSET_GPR] = {
|
||||
+ .core_note_type = NT_PRSTATUS,
|
||||
+ .name = "CORE",
|
||||
+ .size = ELF_NGREG * sizeof(unsigned int),
|
||||
+ .get = gpr_get,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static const struct user_regset_view riscv64_regset_view = {
|
||||
+ .name = "riscv64",
|
||||
+ .regsets = riscv64_regsets,
|
||||
+ .n = 1,
|
||||
+ .e_machine = EM_RISCV,
|
||||
+};
|
||||
+
|
||||
+const struct user_regset_view *
|
||||
+task_user_regset_view(void)
|
||||
+{
|
||||
+ return &riscv64_regset_view;
|
||||
+}
|
||||
+
|
||||
+int gcore_is_arch_32bit_emulation(struct task_context *tc)
|
||||
+{
|
||||
+ return FALSE;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Return an address to gate_vma.
|
||||
+ */
|
||||
+ulong gcore_arch_get_gate_vma(void)
|
||||
+{
|
||||
+ if (!symbol_exists("gate_vma"))
|
||||
+ return 0UL;
|
||||
+
|
||||
+ return symbol_value("gate_vma");
|
||||
+}
|
||||
+
|
||||
+char *gcore_arch_vma_name(ulong vma)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+int gcore_arch_vsyscall_has_vm_alwaysdump_flag(void)
|
||||
+{
|
||||
+ return FALSE;
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
--
|
||||
2.25.1
|
||||
|
||||
30
0003-support-clang-build.patch
Normal file
30
0003-support-clang-build.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From e190d749ee2d77acea0feadd628a793f9648c2c8 Mon Sep 17 00:00:00 2001
|
||||
From: luofeng <luofeng13@huawei.com>
|
||||
Date: Thu, 28 Mar 2024 16:29:04 +0800
|
||||
Subject: [PATCH] support clang build
|
||||
|
||||
---
|
||||
src/gcore.mk | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/gcore.mk b/src/gcore.mk
|
||||
index 9f3d56e..7da33c5 100644
|
||||
--- a/src/gcore.mk
|
||||
+++ b/src/gcore.mk
|
||||
@@ -112,11 +112,11 @@ gcore.so: gcore.c $(INCDIR)/defs.h
|
||||
echo "gcore: architecture not supported"; \
|
||||
else \
|
||||
make -f gcore.mk $(GCORE_OFILES) && \
|
||||
- gcc $(RPM_OPT_FLAGS) $(CFLAGS) $(TARGET_CFLAGS) $(COMMON_CFLAGS) $(ARCH_CFLAGS) -nostartfiles -shared -rdynamic $(GCORE_OFILES) -Wl,-soname,$@ -o $@ $< ; \
|
||||
+ $(CC) $(RPM_OPT_FLAGS) $(CFLAGS) $(TARGET_CFLAGS) $(COMMON_CFLAGS) $(ARCH_CFLAGS) -nostartfiles -shared -rdynamic $(GCORE_OFILES) -Wl,-soname,$@ -o $@ $< ; \
|
||||
fi;
|
||||
|
||||
%.o: %.c $(INCDIR)/defs.h
|
||||
- gcc $(RPM_OPT_FLAGS) $(CFLAGS) $(TARGET_CFLAGS) $(COMMON_CFLAGS) $(ARCH_CFLAGS) -c -o $@ $<
|
||||
+ $(CC) $(RPM_OPT_FLAGS) $(CFLAGS) $(TARGET_CFLAGS) $(COMMON_CFLAGS) $(ARCH_CFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f gcore.so
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
From 33f3c97f7d45c8bb1b43a8d551cb01a9873bb123 Mon Sep 17 00:00:00 2001
|
||||
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
Date: Tue, 28 Feb 2023 03:59:16 -0500
|
||||
Subject: [PATCH] coredump: fix building failure due to undefined macros
|
||||
MAPLE_TREE_{COUNT,GATHER}
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
As of the commit 13794ace3830bf0274fe7b2e0e579ad72e31848f (coredump:
|
||||
fix failure of executing gcore command due to introduction of maple
|
||||
tree management on vma list), gcore.so fails to get built with the
|
||||
following error messages with defs.h without maple tree API support:
|
||||
|
||||
libgcore/gcore_coredump.c:189:50: error: ‘MAPLE_TREE_COUNT’ undeclared (first use in this function); did you mean ‘RADIX_TREE_COUNT’?
|
||||
189 | entry_num = do_maple_tree(mm_mt, MAPLE_TREE_COUNT, NULL);
|
||||
| ^~~~~~~~~~~~~~~~
|
||||
| RADIX_TREE_COUNT
|
||||
libgcore/gcore_coredump.c:189:50: note: each undeclared identifier is reported only once for each function it appears in
|
||||
libgcore/gcore_coredump.c:191:38: error: ‘MAPLE_TREE_GATHER’ undeclared (first use in this function); did you mean ‘RADIX_TREE_GATHER’?
|
||||
191 | do_maple_tree(mm_mt, MAPLE_TREE_GATHER, entry_list);
|
||||
| ^~~~~~~~~~~~~~~~~
|
||||
| RADIX_TREE_GATHER
|
||||
|
||||
This is caused by the missing macros MAPLE_TREE_COUNT and
|
||||
MAPLE_TREE_GATHER.
|
||||
|
||||
To fix the issue, define the two macros within crash gcore so that
|
||||
build is successfully done expecting the resulting binary works well
|
||||
when it is ran against new crash utility that has maple tree API
|
||||
support.
|
||||
|
||||
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
|
||||
---
|
||||
src/libgcore/gcore_coredump.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c
|
||||
index fa744d4..8eece96 100644
|
||||
--- a/src/libgcore/gcore_coredump.c
|
||||
+++ b/src/libgcore/gcore_coredump.c
|
||||
@@ -128,6 +128,14 @@ void gcore_readmem_user(ulong addr, void *buf, long size, char *type)
|
||||
}
|
||||
}
|
||||
|
||||
+#if !defined(MAPLE_TREE_COUNT)
|
||||
+#define MAPLE_TREE_COUNT (1)
|
||||
+#endif
|
||||
+
|
||||
+#if !defined(MAPLE_TREE_GATHER)
|
||||
+#define MAPLE_TREE_GATHER (4)
|
||||
+#endif
|
||||
+
|
||||
ulong __attribute__((weak))
|
||||
do_maple_tree(ulong root, int flag, struct list_pair *lp)
|
||||
{
|
||||
--
|
||||
2.39.2
|
||||
|
||||
Binary file not shown.
BIN
crash-gcore-command-1.6.4.tar.gz
Normal file
BIN
crash-gcore-command-1.6.4.tar.gz
Normal file
Binary file not shown.
@ -1,29 +1,37 @@
|
||||
%global reponame crash-gcore
|
||||
Name: crash-gcore-command
|
||||
Version: 1.3.1
|
||||
Release: 1
|
||||
Version: 1.6.4
|
||||
Release: 3
|
||||
Summary: Command of Gcore for Crash utility
|
||||
|
||||
License: GPLv2
|
||||
URL: http://people.redhat.com/anderson/extensions/%{name}-%{version}.tar.gz
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
URL: https://github.com/fujitsu/crash-gcore
|
||||
Source: https://github.com/fujitsu/crash-gcore/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||
|
||||
Buildroot: %{_tmppath}/%{name}-root
|
||||
BuildRequires: zlib-devel lzo-devel snappy-devel crash-devel >= 5.1.5
|
||||
BuildRequires: zlib-devel lzo-devel snappy-devel crash-devel >= 5.1.5 gcc make
|
||||
Requires: crash >= 5.1.5
|
||||
|
||||
Patch0: crash-gcore-1.6.4-coredump-fix-building-failure-due-to-undefined-macro.patch
|
||||
Patch1: 0001-add-stdbool.h-to-fix-build-error.patch
|
||||
%ifarch riscv64
|
||||
Patch2: 0002-add-riscv64-support.patch
|
||||
%endif
|
||||
Patch3: 0003-support-clang-build.patch
|
||||
|
||||
%description
|
||||
The crash-gcore-command packages contain an extension module for the crash utility
|
||||
that adds a "gcore" command which can create a core dump file of a user-space task
|
||||
that was running in a kernel dumpfile.
|
||||
|
||||
%prep
|
||||
%autosetup -n %{name}-%{version} -p1
|
||||
%autosetup -n %{reponame}-%{version} -p1
|
||||
|
||||
%build
|
||||
%make_build -f gcore.mk
|
||||
%make_build -C src -f gcore.mk
|
||||
|
||||
%install
|
||||
install -D %{_builddir}/%{name}-%{version}/gcore.so %{buildroot}%{_libdir}/crash/extensions/gcore.so
|
||||
install -D %{_builddir}/%{reponame}-%{version}/src/gcore.so %{buildroot}%{_libdir}/crash/extensions/gcore.so
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
@ -31,8 +39,20 @@ install -D %{_builddir}/%{name}-%{version}/gcore.so %{buildroot}%{_libdir}/crash
|
||||
%{_libdir}/crash/extensions/gcore.so
|
||||
|
||||
%changelog
|
||||
* Fri Mar 1 2024 luofeng <luofeng13@huawei.com> - 1.6.4-3
|
||||
- support clang build
|
||||
|
||||
* Wed Jul 12 2023 EastDong <xudong23@iscas.ac.cn> - 1.6.4-2
|
||||
- add riscv64 support
|
||||
|
||||
* Wed Jun 21 2023 chenchen <chen_aka_jan@163.com> - 1.6.4-1
|
||||
- Upgrade to version 1.6.4
|
||||
|
||||
* Tue Jan 18 2022 SimpleUpdate Robot <tc@openeuler.org> - 1.6.3-1
|
||||
- Upgrade to version 1.6.3
|
||||
|
||||
* Mon May 31 2021 baizhonggui <baizhonggui@huawei.com> - 1.3.1-2
|
||||
- Add gcc in BuildRequires
|
||||
|
||||
* Thu Nov 28 2019 daiqianwen <daiqianwen@huawei.com> - 1.3.1-1
|
||||
- Package init
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user