[PATCH 1/2] gnu: libbacktrace: Add patch.

  • Open
  • quality assurance status badge
Details
One participant
  • phodina
Owner
unassigned
Submitted by
phodina
Severity
normal
P
P
phodina wrote on 14 Dec 2022 00:52
QpZ0euHuA8KX3tXkr0GYx7W8rFzYloWqNjDNlH9WiFMcPT8MWrpMir0wyDdjA0ID3SlQFvDCJdUciu5zu7i4Zj7PeVSQMO9RAaOt5aEcKfg=@protonmail.com
Hi,

this adds memory analyzer tool from the KDE project.

Unfortunately heaptrack uses some functions from libbacktrack directly even tough they are private. Therefore I had to create a patch.

----
Petr
Attachment: file
From 1f6d4a702a9e125d29bedf3250d26ba45ee96dba Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Wed, 14 Dec 2022 00:38:51 +0100
Subject: [PATCH 1/2] gnu: libbacktrace: Add patch.

* gnu/packages/debug.scm (libbacktrace)[source]: Add patch.
* gnu/local.mk: Add patch.
* patches/libbacktrace-remove-static-keyword.patch: New variable.

Toggle diff (73 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 3329801fa6..6a70b4b48d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1418,6 +1418,7 @@ dist_patch_DATA = \
%D%/packages/patches/liba52-link-with-libm.patch \
%D%/packages/patches/liba52-set-soname.patch \
%D%/packages/patches/liba52-use-mtune-not-mcpu.patch \
+ %D%/packages/patches/libbacktrace-remove-static-keyword.patch \
%D%/packages/patches/libbase-fix-includes.patch \
%D%/packages/patches/libbase-use-own-logging.patch \
%D%/packages/patches/libbonobo-activation-test-race.patch \
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index 1c4f570fe4..4c0e7c58be 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -695,6 +695,8 @@ (define-public libbacktrace
(uri (git-reference
(url "https://github.com/ianlancetaylor/libbacktrace")
(commit commit)))
+ (patches
+ (search-patches "libbacktrace-remove-static-keyword.patch"))
(file-name (git-file-name name version))
(sha256
(base32
diff --git a/gnu/packages/patches/libbacktrace-remove-static-keyword.patch b/gnu/packages/patches/libbacktrace-remove-static-keyword.patch
new file mode 100644
index 0000000000..05ae3dddcd
--- /dev/null
+++ b/gnu/packages/patches/libbacktrace-remove-static-keyword.patch
@@ -0,0 +1,40 @@
+From c866f91b07d6d366a88c3fb50f69cfa8eefa10d3 Mon Sep 17 00:00:00 2001
+From: Petr Hodina <phodina@protonmail.com>
+Date: Mon, 12 Dec 2022 22:16:37 +0100
+Subject: [PATCH] Remove static keyword from several function.
+
+
+diff --git a/elf.c b/elf.c
+index ab21d2e..e62b328 100644
+--- a/elf.c
++++ b/elf.c
+@@ -557,7 +557,7 @@ elf_crc32_file (struct backtrace_state *state, int descriptor,
+ /* A dummy callback function used when we can't find a symbol
+ table. */
+
+-static void
++void
+ elf_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED,
+ uintptr_t addr ATTRIBUTE_UNUSED,
+ backtrace_syminfo_callback callback ATTRIBUTE_UNUSED,
+@@ -758,7 +758,7 @@ elf_add_syminfo_data (struct backtrace_state *state,
+
+ /* Return the symbol name and value for an ADDR. */
+
+-static void
++void
+ elf_syminfo (struct backtrace_state *state, uintptr_t addr,
+ backtrace_syminfo_callback callback,
+ backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
+@@ -6467,7 +6467,7 @@ backtrace_uncompress_lzma (struct backtrace_state *state,
+ elf_add will need to be called on the descriptor again after
+ base_address is determined. */
+
+-static int
++int
+ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
+ const unsigned char *memory, size_t memory_size,
+ uintptr_t base_address, backtrace_error_callback error_callback,
+--
+2.38.1
+
--
2.38.1
From 556a1e6b4a9cae02012554bc30ac31accc968070 Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Wed, 14 Dec 2022 00:40:30 +0100
Subject: [PATCH 2/2] gnu: Add heaptrack.

* gnu/packages/kde-systemtools.scm (heaptrack): New variable.

Toggle diff (92 lines)
diff --git a/gnu/packages/kde-systemtools.scm b/gnu/packages/kde-systemtools.scm
index 96ed5cb777..02b1775eb0 100644
--- a/gnu/packages/kde-systemtools.scm
+++ b/gnu/packages/kde-systemtools.scm
@@ -21,15 +21,20 @@
(define-module (gnu packages kde-systemtools)
#:use-module (guix build-system qt)
+ #:use-module (guix build-system cmake)
#:use-module (guix download)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (gnu packages)
+ #:use-module (gnu packages boost)
#:use-module (gnu packages compression)
+ #:use-module (gnu packages debug)
+ #:use-module (gnu packages datastructures)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages kde)
#:use-module (gnu packages kde-frameworks)
+ #:use-module (gnu packages libunwind)
#:use-module (gnu packages linux)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages qt)
@@ -331,6 +336,64 @@ (define-public ksystemlog
This package is part of the KDE administration module.")
(license license:gpl2+)))
+(define-public heaptrack
+ (package
+ (name "heaptrack")
+ (version "1.4")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://invent.kde.org/sdk/heaptrack/-/archive/" version
+ "/heaptrack-" version ".tar.gz"))
+ (modules '((guix build utils)))
+ (snippet '(begin
+ delete-file-recursively "3rdparty"))
+ (sha256
+ (base32
+ "0r6fha800iisg2vqgaaj05h11a96rcgavavx7s7vng6kd47rsj1j"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:tests? #f ;fails due to missing zstd (tst_parser)
+ #:phases (modify-phases %standard-phases
+ (add-after 'unpack 'fix-cmake-3rdparty-files
+ (lambda* _
+ (substitute* "CMakeLists.txt"
+ (("add_subdirectory\\(3rdparty\\)")
+ "")
+ (("include_directories\\(3rdparty/robin-map/include\\)")
+ "")))))))
+ (native-inputs (list pkg-config extra-cmake-modules))
+ (inputs (list boost
+ ;; elfutils
+ libbacktrace
+ libunwind
+ kcoreaddons
+ ki18n
+ kitemmodels
+ threadweaver
+ kconfigwidgets
+ kio
+ kdiagram
+ kiconthemes
+ qtbase-5
+ qtsvg-5
+ robin-map
+ zstd
+ zlib))
+ (synopsis "Heap memory profiler for Linux")
+ (description
+ "Heaptrack traces all memory allocations and annotates these
+events with stack traces. Dedicated analysis tools then allow you to interpret
+the heap memory profile to:
+@enumerate
+@item to optimize memory footprint
+@item find memory leaks
+@item find allocation hotspots
+@item find temporary allocations
+@end enumerate")
+ (home-page "https://github.com/KDE/heaptrack")
+ (license license:lgpl2.1+)))
+
(define-public yakuake
(package
(name "yakuake")
--
2.38.1
?