Skip to contentSkip to conversation

package/heaptrack: new package

PATCH Superseded Luca Ceresoli via buildroot 1 participant 2 messages Aug 21

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 package/heaptrack: new package

Add heaptrack, a memory allocation tracer toolkit.

This implementation builds all the command line components, not the heaptrack_gui graphical visualization program.

---
Changes in v4:
- Disable for uclibc (dlmopen)
- Sort _DEPENDENCIES
- Use '=' instead of '+=' on first assignment
- Add more complex test cases
- Runtime tested on:
- qemu_arm_vexpress, Bootlin armv7-eabihf glibc stable 2025.08-1 toolchain
- qemu_aarch64_virt, Bootlin aarch64 musl bleeding-edge 2025.08-1 toolchain
- Note: heaptrack_print for 'ls -la /' OOMs with the default qemu cmdline; adding '-m 512' it worked (the qemu default is 128 MB of RAM)
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- Removed 'linux' from _DEPENDENCIES
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- removed unnecessary depends on BR2_LINUX_KERNEL
- added missing recursive 'depends on'
- sort alphabetically the 'select' lines
- completed 'depends on' list for comment line
- Add "Locally calculated" for the hash
- Add hashes of license files
- Use single tab for indentation
- Add test case
- Update DEVELOPERS file
- Link to v1: https://patch.msgid.link/[email protected]

---
 DEVELOPERS                                      |  2 ++
 package/Config.in                               |  1 +
 package/heaptrack/Config.in                     | 39 +++++++++++++++++++++++
 package/heaptrack/heaptrack.hash                | 10 ++++++
 package/heaptrack/heaptrack.mk                  | 26 +++++++++++++++
 support/testing/tests/package/test_heaptrack.py | 42 +++++++++++++++++++++++++
 6 files changed, 120 insertions(+)
DEVELOPERS +2 -0
index 98c9ee55d31b..3a288afb1a00 100644
@@ -2192,6 +2192,7 @@ F:	configs/zynq_zc706_defconfig
 F:	configs/zynqmp_zcu106_defconfig
 F:	package/agentpp/
 F:	package/exim/
+F:	package/heaptrack/
 F:	package/libpjsip/
 F:	package/linux-tools/linux-tool-usbtools.mk.in
 F:	package/qpid-proton/
@@ -2200,6 +2201,7 @@ F:	package/snmppp/
 F:	package/stm32flash/
 F:	package/unzip/
 F:	support/legal-info/
+F:	support/testing/tests/package/test_heaptrack.py
 
 N:	Lucas De Marchi <[email protected]>
 F:	package/fswebcam/
package/Config.in +1 -0
index 6058800682b4..307f7ce86a3e 100644
@@ -106,6 +106,7 @@ menu "Debugging, profiling and benchmark"
 	source "package/fwts/Config.in"
 	source "package/gdb/Config.in"
 	source "package/google-breakpad/Config.in"
+	source "package/heaptrack/Config.in"
 	source "package/hyperfine/Config.in"
 	source "package/iozone/Config.in"
 	source "package/k3conf/Config.in"
package/heaptrack/Config.in new file +39 -0
new file mode 100644
index 000000000000..808193a73f68
@@ -0,0 +1,39 @@
+config BR2_PACKAGE_HEAPTRACK
+	bool "heaptrack"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_TOOLCHAIN_HAS_THREADS # boost, libunwind, elfutils
+	depends on BR2_USE_WCHAR # boost, elfutils
+	depends on BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS # boost-filesystem
+	depends on BR2_PACKAGE_LIBUNWIND_ARCH_SUPPORTS # libunwind
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # libunwind
+	depends on !BR2_STATIC_LIBS # libunwind, elfutils
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC # no dlmopen() support
+	select BR2_PACKAGE_BOOST
+	select BR2_PACKAGE_BOOST_IOSTREAMS
+	select BR2_PACKAGE_BOOST_PROGRAM_OPTIONS
+	# For heaptrack_print
+	select BR2_PACKAGE_BOOST_FILESYSTEM
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_LIBUNWIND
+	select BR2_PACKAGE_ZLIB
+	help
+	  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 find hotspots,
+	  memory leaks, allocation hotspots and temporary allocations.
+
+	  Zstandard offers better (de)compression performance compared
+	  with gzip/zlib, making heaptrack faster and datafiles smaller,
+	  so enabling BR2_PACKAGE_ZSTD is recommended.
+
+	  https://apps.kde.org/heaptrack/
+
+comment "heaptrack needs a glibc or musl toolchain w/ C++, threads, wchar, gcc >= 4.9, dynamic library"
+	depends on BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS
+	depends on BR2_PACKAGE_LIBUNWIND_ARCH_SUPPORTS
+	depends on !BR2_INSTALL_LIBSTDCPP \
+		|| !BR2_TOOLCHAIN_HAS_THREADS \
+		|| !BR2_USE_WCHAR \
+		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 \
+		|| BR2_STATIC_LIBS \
+		|| BR2_TOOLCHAIN_USES_UCLIBC
package/heaptrack/heaptrack.hash new file +10 -0
new file mode 100644
index 000000000000..6ad9619f23b9
@@ -0,0 +1,10 @@
+# Locally calculated
+sha256  e69de2209ab0e16c8e26c1b60feeb852b3a88e46a4f16588c08254e1bd81a183  heaptrack-3e6cce3d210a6672fe6f92de0bed567c49b7a9c5-git4.tar.gz
+
+sha256  fa6f36630bb1e0c571d34b2bbdf188d08495c9dbf58f28cac112f303fc1f58fb  LICENSES/LGPL-2.1-only.txt
+sha256  aaf135472f81c5b4a0dca9367e5bb5e9750032b5bebe5442b36e4c0a47430df3  LICENSES/GPL-2.0-or-later.txt
+sha256  6aee5c3d7c55f3d8ff45b1245b8427efaf0a59e9c52d7139c79bff7056e9a611  LICENSES/LGPL-2.1-or-later.txt
+sha256  84c6ef3ea9e3254a54d0acf5d3e0c61ae011b8fef7dd6940591cf060e6380a8f  LICENSES/BSL-1.0.txt
+sha256  b85dcd3e453d05982552c52b5fc9e0bdd6d23c6f8e844b984a88af32570b0cc0  LICENSES/MIT.txt
+sha256  074e6e32c86a4c0ef8b3ed25b721ca23aca83df277cd88106ef7177c354615ff  LICENSES/Apache-2.0.txt
+sha256  42639b2e5507163d35069be166e37a784f48a5f17e3577c16eb48fab215247cd  LICENSES/BSD-3-Clause.txt
package/heaptrack/heaptrack.mk new file +26 -0
new file mode 100644
index 000000000000..6ae49ba1a88f
@@ -0,0 +1,26 @@
+################################################################################
+#
+# heaptrack
+#
+################################################################################
+
+HEAPTRACK_SITE_METHOD = git
+HEAPTRACK_SITE = https://invent.kde.org/sdk/heaptrack.git
+HEAPTRACK_VERSION = 3e6cce3d210a6672fe6f92de0bed567c49b7a9c5
+HEAPTRACK_LICENSE = LGPL-2.1-or-later, GPL-2.0-or-later (heaptrack_interpret)
+HEAPTRACK_LICENSE_FILES = \
+	LICENSES/LGPL-2.1-only.txt \
+	LICENSES/GPL-2.0-or-later.txt \
+	LICENSES/LGPL-2.1-or-later.txt \
+	LICENSES/BSL-1.0.txt \
+	LICENSES/MIT.txt \
+	LICENSES/Apache-2.0.txt \
+	LICENSES/BSD-3-Clause.txt
+HEAPTRACK_DEPENDENCIES = host-pkgconf boost elfutils libunwind zlib
+HEAPTRACK_CONF_OPTS = -DHEAPTRACK_BUILD_GUI=OFF -DHEAPTRACK_BUILD_PRINT=ON
+
+ifeq ($(BR2_PACKAGE_ZSTD),y)
+HEAPTRACK_DEPENDENCIES += zstd
+endif
+
+$(eval $(cmake-package))
support/testing/tests/package/test_heaptrack.py new file +42 -0

42 lines not on this page · raw message

---
base-commit: 7aba8c3f90da93d138493fe4eb24953731b1e7a2
change-id: 20260731-heaptrack-cd4f6f8fcec8

Best regards,

Signature · 8 lines
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hi Luca,

Thanks for the update.

Quoted 7 lines · Luca Ceresoli via buildroot

Add heaptrack, a memory allocation tracer toolkit.

This implementation builds all the command line components, not the heaptrack_gui graphical visualization program.

---

[...]

Quoted 13 lines
package/heaptrack/Config.in new file +6 -0
new file mode 100644
index 000000000000..808193a73f68
@@ -0,0 +1,39 @@
+config BR2_PACKAGE_HEAPTRACK
+	bool "heaptrack"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_TOOLCHAIN_HAS_THREADS # boost, libunwind, elfutils
+	depends on BR2_USE_WCHAR # boost, elfutils
+	depends on BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS # 

boost-filesystem

package/heaptrack/Config.in line 8

Quoted 2 lines
package/heaptrack/Config.in new file +2 -0
+	depends on BR2_PACKAGE_LIBUNWIND_ARCH_SUPPORTS # libunwind
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # libunwind

There is one last build failure with test-pkg:
https://gitlab.com/jolivain/buildroot/-/jobs/16041509274

It seems that heaptrack is using std::filesystem:
https://invent.kde.org/sdk/heaptrack/-/blob/master/src/interpret/heaptrack_interpret.cpp?ref_type=heads#L15

which is a C++17 feature which was fully implemented in gcc 8.1:
https://gcc.gnu.org/gcc-8/changes.html#libstdcxx

So I believe this gcc version should be raised at gcc >= 8.

depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8 # C++17 filesystem

The comment should also be updated below.

Quoted 23 lines
package/heaptrack/Config.in new file +23 -0
+	depends on !BR2_STATIC_LIBS # libunwind, elfutils
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC # no dlmopen() support
+	select BR2_PACKAGE_BOOST
+	select BR2_PACKAGE_BOOST_IOSTREAMS
+	select BR2_PACKAGE_BOOST_PROGRAM_OPTIONS
+	# For heaptrack_print
+	select BR2_PACKAGE_BOOST_FILESYSTEM
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_LIBUNWIND
+	select BR2_PACKAGE_ZLIB
+	help
+	  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 find hotspots,
+	  memory leaks, allocation hotspots and temporary allocations.
+
+	  Zstandard offers better (de)compression performance compared
+	  with gzip/zlib, making heaptrack faster and datafiles smaller,
+	  so enabling BR2_PACKAGE_ZSTD is recommended.
+
+	  https://apps.kde.org/heaptrack/
+
+comment "heaptrack needs a glibc or musl toolchain w/ C++, threads, 
Quoted 1 line

wchar, gcc >= 4.9, dynamic library"

"needs gcc >= 8"

package/heaptrack/Config.in line 37

Quoted 6 lines
package/heaptrack/Config.in new file +6 -0
+	depends on BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS
+	depends on BR2_PACKAGE_LIBUNWIND_ARCH_SUPPORTS
+	depends on !BR2_INSTALL_LIBSTDCPP \
+		|| !BR2_TOOLCHAIN_HAS_THREADS \
+		|| !BR2_USE_WCHAR \
+		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 \
		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_8 \

package/heaptrack/Config.in line 39

Quoted 2 lines
package/heaptrack/Config.in new file +2 -0
+		|| BR2_STATIC_LIBS \
+		|| BR2_TOOLCHAIN_USES_UCLIBC

[...]

Could you send an updated patch please?

Best regards,

Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot