From c3a1193deaa3a46b90c82aa59a5acf9cff2942b4 Mon Sep 17 00:00:00 2001
From: fritzkink <96341974+fritzkink@users.noreply.github.com>
Date: Tue, 26 Dec 2023 20:30:13 +0100
Subject: [PATCH] valgrind - update to version 3.22.0

---
 components/developer/valgrind/test/results-all.master          |  131 --------------
 components/developer/valgrind/pkg5                             |    7 
 components/developer/valgrind/patches/04-execve.patch          |   18 ++
 components/developer/valgrind/valgrind.p5m                     |   13 +
 components/developer/valgrind/patches/05-dtrace-fix.patch      |   33 +++
 components/developer/valgrind/patches/06-mremap.patch          |   61 ++++++
 components/developer/valgrind/Makefile                         |   24 +-
 components/developer/valgrind/patches/08-gdbserver_tests.patch |   53 +++++
 components/developer/valgrind/manifests/sample-manifest.p5m    |  100 +++++-----
 components/developer/valgrind/patches/07-dtrace-section.patch  |   50 +++++
 10 files changed, 293 insertions(+), 197 deletions(-)

diff --git a/components/developer/valgrind/Makefile b/components/developer/valgrind/Makefile
index cdfbee1..08a9f33 100644
--- a/components/developer/valgrind/Makefile
+++ b/components/developer/valgrind/Makefile
@@ -23,20 +23,18 @@
 # Copyright (c) 2015-2017 Aurelien Larcher. All rights reserved.
 # Copyright (c) 2019 Michal Nowak
 # Copyright (c) 2021 David Stes
-# Copyright (c) 2022 Friedrich Kink
+# Copyright (c) 2022,2023 Friedrich Kink
 #
-
-BUILD_BITS= 64
 
 include ../../../make-rules/shared-macros.mk
 
 COMPONENT_NAME=		valgrind
-COMPONENT_VERSION=	3.19.0
+COMPONENT_VERSION=	3.22.0
 COMPONENT_FMRI=		developer/debug/valgrind
 COMPONENT_CLASSIFICATION=Development/System
 COMPONENT_SRC=		$(COMPONENT_NAME)-$(COMPONENT_VERSION)
 COMPONENT_ARCHIVE=	$(COMPONENT_SRC).tar.bz2
-COMPONENT_ARCHIVE_HASH=	sha256:dd5e34486f1a483ff7be7300cc16b4d6b24690987877c3278d797534d6738f02
+COMPONENT_ARCHIVE_HASH=	sha256:c811db5add2c5f729944caf47c4e7a65dcaabb9461e472b578765dd7bf6d2d4c
 COMPONENT_ARCHIVE_URL=	https://sourceware.org/pub/valgrind/$(COMPONENT_ARCHIVE)
 COMPONENT_PROJECT_URL =	https://valgrind.org
 COMPONENT_SUMMARY=	Valgrind: instrumentation framework and tools to detect memory and threading problems
@@ -51,10 +49,6 @@
 COMPONENT_PRE_CONFIGURE_ACTION = \
 	( $(CLONEY) $(SOURCE_DIR) $(@D) )
 
-# Force use of GCC with given arch support
-CC=$(CC.gcc.$(BITS)) $(CC_BITS) -std=gnu99
-CXX=$(CC.g++.$(BITS)) $(CC_BITS)
-
 # Flags are inferred from CC and tests rely on sigaction
 CFLAGS= -D__EXTENSIONS__
 CXXFLAGS= -D__EXTENSIONS__
@@ -66,6 +60,9 @@
 CONFIGURE_OPTIONS += --sbindir=$(USRSBINDIR)
 CONFIGURE_OPTIONS += --libdir=$(CONFIGURE_LIBDIR.$(BITS))
 CONFIGURE_OPTIONS += --libexecdir=$(CONFIGURE_LIBDIR.$(BITS))
+CONFIGURE_OPTIONS += --enable-inner
+CONFIGURE_OPTIONS += --enable-tls
+CONFIGURE_OPTIONS += --with-mpicc=$(USRLIBDIR)/openmpi/gcc/bin/mpicc
 
 COMPONENT_PREP_ACTION += ( cd $(@D) && ./autogen.sh )
 
@@ -76,8 +73,8 @@
 	( cd $(@D)/docs && $(ENV) $(GMAKE) man-pages )
 
 #
-# currently 3.17.0
-# == 787 tests, 95 stderr failures, 18 stdout failures, 3 stderrB failures, 6 stdoutB failures, 7 post failures ==
+# currently 3.22.0
+# == 835 tests, 62 stderr failures, 14 stdout failures, 0 stderrB failures, 0 stdoutB failures, 6 post failures ==
 #
 COMPONENT_TEST_TARGETS = regtest
 # check just overal test results
@@ -85,5 +82,8 @@
 
 # Build dependencies
 # Auto-generated dependencies
-REQUIRED_PACKAGES += runtime/perl-534
+REQUIRED_PACKAGES += $(GCC_RUNTIME_PKG)
+REQUIRED_PACKAGES += SUNWcs
+REQUIRED_PACKAGES += developer/gcc-13
+REQUIRED_PACKAGES += runtime/perl
 REQUIRED_PACKAGES += system/library
diff --git a/components/developer/valgrind/manifests/sample-manifest.p5m b/components/developer/valgrind/manifests/sample-manifest.p5m
index 4fb9b32..fb9204f 100644
--- a/components/developer/valgrind/manifests/sample-manifest.p5m
+++ b/components/developer/valgrind/manifests/sample-manifest.p5m
@@ -10,10 +10,11 @@
 #
 
 #
-# Copyright 2022 <contributor>
+# Copyright 2023 <contributor>
 #
 
 set name=pkg.fmri value=pkg:/$(COMPONENT_FMRI)@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)
+set name=pkg.human-version value=$(HUMAN_VERSION)
 set name=pkg.summary value="$(COMPONENT_SUMMARY)"
 set name=info.classification value="$(COMPONENT_CLASSIFICATION)"
 set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
@@ -32,6 +33,7 @@
 file path=usr/bin/valgrind-di-server
 file path=usr/bin/valgrind-listener
 file path=usr/bin/vgdb
+file path=usr/include/valgrind/cachegrind.h
 file path=usr/include/valgrind/callgrind.h
 file path=usr/include/valgrind/config.h
 file path=usr/include/valgrind/dhat.h
@@ -301,6 +303,8 @@
 file path=usr/lib/$(MACH64)/valgrind/s390x-linux64.xml
 file path=usr/lib/$(MACH64)/valgrind/s390x-vx-linux-valgrind.xml
 file path=usr/lib/$(MACH64)/valgrind/s390x-vx-linux.xml
+file path=usr/lib/$(MACH64)/valgrind/valgrind-monitor-def.py
+file path=usr/lib/$(MACH64)/valgrind/valgrind-monitor.py
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_core-amd64-solaris.so
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_core-x86-solaris.so
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_dhat-amd64-solaris.so
@@ -314,99 +318,99 @@
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_memcheck-amd64-solaris.so
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_memcheck-x86-solaris.so
 link path=usr/share/doc/valgrind/html/FAQ.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/FAQ.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/FAQ.html
 link path=usr/share/doc/valgrind/html/QuickStart.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/QuickStart.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/QuickStart.html
 link path=usr/share/doc/valgrind/html/bbv-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/bbv-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/bbv-manual.html
 link path=usr/share/doc/valgrind/html/cg-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/cg-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/cg-manual.html
 link path=usr/share/doc/valgrind/html/cl-format.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/cl-format.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/cl-format.html
 link path=usr/share/doc/valgrind/html/cl-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/cl-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/cl-manual.html
 link path=usr/share/doc/valgrind/html/design-impl.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/design-impl.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/design-impl.html
 link path=usr/share/doc/valgrind/html/dh-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dh-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dh-manual.html
 link path=usr/share/doc/valgrind/html/dist.authors.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.authors.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.authors.html
 link path=usr/share/doc/valgrind/html/dist.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.html
 link path=usr/share/doc/valgrind/html/dist.news.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.news.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.news.html
 link path=usr/share/doc/valgrind/html/dist.news.old.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.news.old.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.news.old.html
 link path=usr/share/doc/valgrind/html/dist.readme-android.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme-android.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme-android.html
 link path=usr/share/doc/valgrind/html/dist.readme-android_emulator.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme-android_emulator.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme-android_emulator.html
 link path=usr/share/doc/valgrind/html/dist.readme-developers.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme-developers.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme-developers.html
 link path=usr/share/doc/valgrind/html/dist.readme-freebsd.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme-freebsd.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme-freebsd.html
 link path=usr/share/doc/valgrind/html/dist.readme-mips.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme-mips.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme-mips.html
 link path=usr/share/doc/valgrind/html/dist.readme-missing.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme-missing.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme-missing.html
 link path=usr/share/doc/valgrind/html/dist.readme-packagers.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme-packagers.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme-packagers.html
 link path=usr/share/doc/valgrind/html/dist.readme-s390.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme-s390.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme-s390.html
 link path=usr/share/doc/valgrind/html/dist.readme-solaris.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme-solaris.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme-solaris.html
 link path=usr/share/doc/valgrind/html/dist.readme.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/dist.readme.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/dist.readme.html
 link path=usr/share/doc/valgrind/html/drd-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/drd-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/drd-manual.html
 link path=usr/share/doc/valgrind/html/faq.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/faq.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/faq.html
 link path=usr/share/doc/valgrind/html/hg-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/hg-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/hg-manual.html
 link path=usr/share/doc/valgrind/html/images/dh-tree.png \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/images/dh-tree.png
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/images/dh-tree.png
 link path=usr/share/doc/valgrind/html/images/home.png \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/images/home.png
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/images/home.png
 link path=usr/share/doc/valgrind/html/images/kcachegrind_xtree.png \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/images/kcachegrind_xtree.png
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/images/kcachegrind_xtree.png
 link path=usr/share/doc/valgrind/html/images/next.png \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/images/next.png
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/images/next.png
 link path=usr/share/doc/valgrind/html/images/prev.png \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/images/prev.png
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/images/prev.png
 link path=usr/share/doc/valgrind/html/images/up.png \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/images/up.png
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/images/up.png
 link path=usr/share/doc/valgrind/html/index.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/index.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/index.html
 link path=usr/share/doc/valgrind/html/license.gfdl.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/license.gfdl.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/license.gfdl.html
 link path=usr/share/doc/valgrind/html/license.gpl.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/license.gpl.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/license.gpl.html
 link path=usr/share/doc/valgrind/html/licenses.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/licenses.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/licenses.html
 link path=usr/share/doc/valgrind/html/lk-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/lk-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/lk-manual.html
 link path=usr/share/doc/valgrind/html/manual-core-adv.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/manual-core-adv.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/manual-core-adv.html
 link path=usr/share/doc/valgrind/html/manual-core.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/manual-core.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/manual-core.html
 link path=usr/share/doc/valgrind/html/manual-intro.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/manual-intro.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/manual-intro.html
 link path=usr/share/doc/valgrind/html/manual-writing-tools.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/manual-writing-tools.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/manual-writing-tools.html
 link path=usr/share/doc/valgrind/html/manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/manual.html
 link path=usr/share/doc/valgrind/html/mc-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/mc-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/mc-manual.html
 link path=usr/share/doc/valgrind/html/ms-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/ms-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/ms-manual.html
 link path=usr/share/doc/valgrind/html/nl-manual.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/nl-manual.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/nl-manual.html
 link path=usr/share/doc/valgrind/html/quick-start.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/quick-start.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/quick-start.html
 link path=usr/share/doc/valgrind/html/tech-docs.html \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/tech-docs.html
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/tech-docs.html
 link path=usr/share/doc/valgrind/html/vg_basic.css \
-    target=/usr/src/myoi-userland/components/developer/valgrind/valgrind-$(COMPONENT_VERSION)/docs/html/vg_basic.css
+    target=/usr/src/oi-userland/components/developer/valgrind/valgrind-$(HUMAN_VERSION)/docs/html/vg_basic.css
 file path=usr/share/doc/valgrind/valgrind_manual.pdf
 file path=usr/share/doc/valgrind/valgrind_manual.ps
 file path=usr/share/man/man1/callgrind_annotate.1
diff --git a/components/developer/valgrind/patches/04-execve.patch b/components/developer/valgrind/patches/04-execve.patch
new file mode 100644
index 0000000..88c8415
--- /dev/null
+++ b/components/developer/valgrind/patches/04-execve.patch
@@ -0,0 +1,18 @@
+On Solaris, calling execve with -1 as a first argument causes segfault.
+
+Not intended for upstream.
+
+--- valgrind-3.22.0/none/tests/execve.c	2023-10-31 18:25:52.000000000 +0100
++++ valgrind-3.22.0/none/tests/execve.c.new	2023-12-26 17:42:45.810898858 +0100
+@@ -28,8 +28,11 @@
+ 	 doesn't actually exists, so execve doesn't accidentally succeeds.  */
+       if (execve("/%/", NULL, NULL) >= 0)
+ 	printf ("WHAT?");
++#if !defined(VGO_solaris)
++      /* On Solaris, execve segfaults when -1 is given as an argument. */
+       if (execve("/%/", (void *)-1, NULL) >= 0)
+ 	printf ("WHAT?");
++#endif
+       if (execve("/%/", v_null, NULL) >= 0)
+ 	printf ("WHAT?");
+       if (execve("/%/", v_null, v_null) >= 0)
diff --git a/components/developer/valgrind/patches/05-dtrace-fix.patch b/components/developer/valgrind/patches/05-dtrace-fix.patch
new file mode 100644
index 0000000..088c9ab
--- /dev/null
+++ b/components/developer/valgrind/patches/05-dtrace-fix.patch
@@ -0,0 +1,33 @@
+The change that added this code did not take Solaris only block (hidden
+behind define macro) into consideration.
+
+Should be reported upstream.
+
+--- valgrind-3.22.0/coregrind/m_debuginfo/readelf.c
++++ valgrind-3.22.0/coregrind/m_debuginfo/readelf.c
+@@ -2386,6 +2386,12 @@ Bool ML_(read_elf_debug_info) ( struct _
+ 
+       /* Accept .data where mapped as rw (data), even if zero-sized */
+       if (0 == VG_(strcmp)(name, ".data")) {
++        if (inrw2) {
++           inrw = inrw2;
++        } else {
++           inrw = inrw1;
++        }
++
+ #        if defined(SOLARIS_PT_SUNDWTRACE_THRP)
+          if ((size == VKI_PT_SUNWDTRACE_SIZE) && (svma == dtrace_data_vaddr)) {
+             TRACE_SYMTAB("ignoring .data section for dtrace_data "
+@@ -2393,12 +2399,6 @@ Bool ML_(read_elf_debug_info) ( struct _
+          } else
+ #        endif /* SOLARIS_PT_SUNDWTRACE_THRP */
+ 
+-        if (inrw2) {
+-           inrw = inrw2;
+-        } else {
+-           inrw = inrw1;
+-        }
+-
+          if (inrw && !di->data_present) {
+             di->data_present = True;
+             di->data_svma = svma;
diff --git a/components/developer/valgrind/patches/06-mremap.patch b/components/developer/valgrind/patches/06-mremap.patch
new file mode 100644
index 0000000..177b5ce
--- /dev/null
+++ b/components/developer/valgrind/patches/06-mremap.patch
@@ -0,0 +1,61 @@
+Add support for new mremap syscall.
+
+This can be offered upstream.
+
+--- valgrind-3.22.0/coregrind/m_aspacemgr/aspacemgr-common.c
++++ valgrind-3.22.0/coregrind/m_aspacemgr/aspacemgr-common.c
+@@ -223,7 +223,7 @@ SysRes ML_(am_do_extend_mapping_NO_NOTIF
+    /* Extend the mapping old_addr .. old_addr+old_len-1 to have length
+       new_len, WITHOUT moving it.  If it can't be extended in place,
+       fail. */
+-#  if defined(VGO_linux)
++#  if defined(VGO_linux) || defined(VGO_solaris)
+    return VG_(do_syscall5)(
+              __NR_mremap, 
+              old_addr, old_len, new_len, 
+@@ -244,7 +244,7 @@ SysRes ML_(am_do_relocate_nooverlap_mapp
+       location and with the new length.  Only needs to handle the case
+       where the two areas do not overlap, neither length is zero, and
+       all args are page aligned. */
+-#  if defined(VGO_linux)
++#  if defined(VGO_linux) || defined(VGO_solaris)
+    return VG_(do_syscall5)(
+              __NR_mremap, 
+              old_addr, old_len, new_len, 
+--- valgrind-3.22.0/include/vki/vki-solaris.h
++++ valgrind-3.22.0/include/vki/vki-solaris.h
+@@ -664,6 +664,11 @@ typedef struct vki_kcf_door_arg_s {
+ #define vki_meminfo_t meminfo_t
+ 
+ 
++#include <sys/mman.h>
++#define VKI_MREMAP_FIXED MREMAP_FIXED
++#define VKI_MREMAP_MAYMOVE MREMAP_MAYMOVE
++
++
+ #include <sys/mntio.h>
+ #define VKI_MNTIOC_GETEXTMNTENT MNTIOC_GETEXTMNTENT
+ #define VKI_MNTIOC_GETMNTANY MNTIOC_GETMNTANY
+--- valgrind-3.22.0/include/vki/vki-scnums-solaris.h
++++ valgrind-3.22.0/include/vki/vki-scnums-solaris.h
+@@ -178,6 +178,7 @@
+ #if defined(SOLARIS_UUIDSYS_SYSCALL)
+ #define __NR_uuidsys                    SYS_uuidsys
+ #endif /* SOLARIS_UUIDSYS_SYSCALL */
++#define __NR_mremap                     SYS_mremap
+ #define __NR_mmapobj                    SYS_mmapobj
+ #define __NR_setrlimit                  SYS_setrlimit
+ #define __NR_getrlimit                  SYS_getrlimit
+--- valgrind-3.21.0/coregrind/m_syswrap/syswrap-solaris.c
++++ valgrind-3.21.0/coregrind/m_syswrap/syswrap-solaris.c
+@@ -10951,6 +10951,9 @@ static SyscallTableEntry syscall_table[]
+ #if defined(SOLARIS_UUIDSYS_SYSCALL)
+    SOLXY(__NR_uuidsys,              sys_uuidsys),               /* 124 */
+ #endif /* SOLARIS_UUIDSYS_SYSCALL */
++#if defined(HAVE_MREMAP)
++   GENX_(__NR_mremap,               sys_mremap),                /* 126 */
++#endif /* HAVE_MREMAP */
+    SOLX_(__NR_mmapobj,              sys_mmapobj),               /* 127 */
+    GENX_(__NR_setrlimit,            sys_setrlimit),             /* 128 */
+    GENXY(__NR_getrlimit,            sys_getrlimit),             /* 129 */
+
diff --git a/components/developer/valgrind/patches/07-dtrace-section.patch b/components/developer/valgrind/patches/07-dtrace-section.patch
new file mode 100644
index 0000000..70aeb8d
--- /dev/null
+++ b/components/developer/valgrind/patches/07-dtrace-section.patch
@@ -0,0 +1,50 @@
+Solaris ELF objects can contain additional DTrace related .data section,
+which can confuse Valgrind.
+
+Previously, this was handled by detecting an ELF section outside all
+mapped regions. However, it seems that even this DTrace related section
+can be mapped into an existing region. This patch changes this detection
+such that section mapping is no longer relevant.
+
+Original fix:
+https://sourceware.org/git/?p=valgrind.git;h=6260274e4ed84f02d3fbe73adbd3b65893e73bd8
+
+Should be reported upstream.
+
+--- valgrind-3.22.0/coregrind/m_debuginfo/readelf.c
++++ valgrind-3.22.0/coregrind/m_debuginfo/readelf.c
+@@ -2153,17 +2153,24 @@ Bool ML_(read_elf_debug_info) ( struct _
+                      }
+                   }
+                }
+-               if (!loaded) {
+-#                 if defined(SOLARIS_PT_SUNDWTRACE_THRP)
+-                  if ((a_phdr.p_memsz == VKI_PT_SUNWDTRACE_SIZE)
+-                     && ((a_phdr.p_flags & (PF_R | PF_W | PF_X)) == PF_R)) {
+-                     TRACE_SYMTAB("PT_LOAD[%ld]:   ignore dtrace_data program "
+-                                  "header\n", i);
+-                     dtrace_data_vaddr = a_phdr.p_vaddr;
+-                     continue;
++#              if defined(SOLARIS_PT_SUNDWTRACE_THRP)
++               if ((a_phdr.p_memsz == VKI_PT_SUNWDTRACE_SIZE)
++                  && ((a_phdr.p_flags & (PF_R | PF_W | PF_X)) == PF_R)) {
++                  if (dtrace_data_vaddr != 0) {
++                     ML_(symerr)(di, True, "Multiple dtrace_data headers detected");
++                     goto out;
+                   }
+-#                 endif /* SOLARIS_PT_SUNDWTRACE_THRP */
++                  dtrace_data_vaddr = a_phdr.p_vaddr;
+ 
++                  /* DTrace related section might be outside all mapped regions. */
++                  if (!loaded) {
++                     TRACE_SYMTAB("PT_LOAD[%ld]:   ignore dtrace_data program "
++                                  "header\n", i);
++                     continue;
++                  }
++               }
++#              endif /* SOLARIS_PT_SUNDWTRACE_THRP */
++               if (!loaded) {
+                   ML_(symerr)(di, False,
+                               "ELF section outside all mapped regions");
+                   /* This problem might be solved by further memory mappings.
+
diff --git a/components/developer/valgrind/patches/08-gdbserver_tests.patch b/components/developer/valgrind/patches/08-gdbserver_tests.patch
new file mode 100644
index 0000000..d57544d
--- /dev/null
+++ b/components/developer/valgrind/patches/08-gdbserver_tests.patch
@@ -0,0 +1,53 @@
+gdbserver_tests test does not work at all
+simply waits for eternity
+
+--- valgrind-3.22.0/Makefile.in	2023-12-26 18:16:46.161022244 +0100
++++ valgrind-3.22.0/Makefile.in.new	2023-12-26 19:05:09.563683141 +0100
+@@ -1435,18 +1435,18 @@
+ 
+ regtest: check
+ 	$(top_srcdir)/gdbserver_tests/make_local_links $(GDB)
+-	if @PERL@ tests/vg_regtest gdbserver_tests $(TOOLS) $(EXP_TOOLS) ; then \
+-	   tests/post_regtest_checks $(abs_top_srcdir) gdbserver_tests $(TOOLS) $(EXP_TOOLS); \
++	if @PERL@ tests/vg_regtest $(TOOLS) $(EXP_TOOLS) ; then \
++	   tests/post_regtest_checks $(abs_top_srcdir) $(TOOLS) $(EXP_TOOLS); \
+ 	else \
+ 	   tests/post_regtest_checks $(abs_top_srcdir) gdbserver_tests $(TOOLS) $(EXP_TOOLS); \
+ 	   false; \
+ 	fi
+ post-regtest-checks:
+-	tests/post_regtest_checks $(abs_top_srcdir) gdbserver_tests $(TOOLS) $(EXP_TOOLS)
++	tests/post_regtest_checks $(abs_top_srcdir) $(TOOLS) $(EXP_TOOLS)
+ nonexp-regtest: check
+ 	@PERL@ tests/vg_regtest $(TOOLS)
+ exp-regtest: check
+-	@PERL@ tests/vg_regtest gdbserver_tests $(EXP_TOOLS)
++	@PERL@ tests/vg_regtest $(EXP_TOOLS)
+ # Nb: gdbserver_tests are put in exp-regtest rather than nonexp-regtest
+ # because they are tested with various valgrind tools, so might be using
+ # an experimental tool.
+--- valgrind-3.22.0/Makefile.am	2023-10-31 18:25:52.000000000 +0100
++++ valgrind-3.22.0/Makefile.am.new	2023-12-26 19:06:33.986624317 +0100
+@@ -76,18 +76,18 @@
+ ## Ensure make exits with error if PERL fails or post_regtest_checks fails.
+ regtest: check
+ 	$(top_srcdir)/gdbserver_tests/make_local_links $(GDB)
+-	if @PERL@ tests/vg_regtest gdbserver_tests $(TOOLS) $(EXP_TOOLS) ; then \
+-	   tests/post_regtest_checks $(abs_top_srcdir) gdbserver_tests $(TOOLS) $(EXP_TOOLS); \
++	if @PERL@ tests/vg_regtest $(TOOLS) $(EXP_TOOLS) ; then \
++	   tests/post_regtest_checks $(abs_top_srcdir) $(TOOLS) $(EXP_TOOLS); \
+ 	else \
+ 	   tests/post_regtest_checks $(abs_top_srcdir) gdbserver_tests $(TOOLS) $(EXP_TOOLS); \
+ 	   false; \
+ 	fi
+ post-regtest-checks:
+-	tests/post_regtest_checks $(abs_top_srcdir) gdbserver_tests $(TOOLS) $(EXP_TOOLS)
++	tests/post_regtest_checks $(abs_top_srcdir) $(TOOLS) $(EXP_TOOLS)
+ nonexp-regtest: check
+ 	@PERL@ tests/vg_regtest $(TOOLS)
+ exp-regtest: check
+-	@PERL@ tests/vg_regtest gdbserver_tests $(EXP_TOOLS)
++	@PERL@ tests/vg_regtest $(EXP_TOOLS)
+ # Nb: gdbserver_tests are put in exp-regtest rather than nonexp-regtest
+ # because they are tested with various valgrind tools, so might be using
+ # an experimental tool.
diff --git a/components/developer/valgrind/pkg5 b/components/developer/valgrind/pkg5
index 61867eb..ee92cbb 100644
--- a/components/developer/valgrind/pkg5
+++ b/components/developer/valgrind/pkg5
@@ -1,9 +1,10 @@
 {
     "dependencies": [
         "SUNWcs",
-        "runtime/perl-534",
-        "shell/ksh93",
-        "system/library"
+        "developer/gcc-13",
+        "runtime/perl",
+        "system/library",
+        "system/library/gcc-13-runtime"
     ],
     "fmris": [
         "developer/debug/valgrind"
diff --git a/components/developer/valgrind/test/results-all.master b/components/developer/valgrind/test/results-all.master
index 7a77db8..cb12b1b 100644
--- a/components/developer/valgrind/test/results-all.master
+++ b/components/developer/valgrind/test/results-all.master
@@ -1,130 +1 @@
-== 787 tests, 95 stderr failures, 18 stdout failures, 3 stderrB failures, 6 stdoutB failures, 7 post failures ==
-gdbserver_tests/hginfo                   (stderrB)
-gdbserver_tests/mcinvokeWS               (stdoutB)
-gdbserver_tests/mcinvokeWS               (stderrB)
-gdbserver_tests/mcsignopass              (stderr)
-gdbserver_tests/mcsignopass              (stdoutB)
-gdbserver_tests/mcsigpass                (stderr)
-gdbserver_tests/mcsigpass                (stdoutB)
-gdbserver_tests/nlgone_abrt              (stderr)
-gdbserver_tests/nlpasssigalrm            (stderr)
-gdbserver_tests/nlpasssigalrm            (stdoutB)
-gdbserver_tests/nlpasssigalrm            (stderrB)
-gdbserver_tests/nlvgdbsigqueue           (stderr)
-gdbserver_tests/nlvgdbsigqueue           (stdoutB)
-gdbserver_tests/solaris/nlcontrolc       (stderr)
-gdbserver_tests/solaris/nlcontrolc       (stdoutB)
-memcheck/tests/amd64-solaris/context_fpu (stdout)
-memcheck/tests/amd64-solaris/context_fpu (stderr)
-memcheck/tests/amd64-solaris/context_gpr (stdout)
-memcheck/tests/amd64-solaris/context_gpr (stderr)
-memcheck/tests/amd64-solaris/context_rflags (stdout)
-memcheck/tests/amd64-solaris/context_rflags (stderr)
-memcheck/tests/amd64-solaris/context_rflags2 (stderr)
-memcheck/tests/amd64-solaris/context_sse (stdout)
-memcheck/tests/amd64-solaris/context_sse (stderr)
-memcheck/tests/badjump                   (stderr)
-memcheck/tests/badjump2                  (stderr)
-memcheck/tests/big_debuginfo_symbol      (stderr)
-memcheck/tests/deep-backtrace            (stderr)
-memcheck/tests/demangle                  (stderr)
-memcheck/tests/descr_belowsp             (stderr)
-memcheck/tests/dw4                       (stderr)
-memcheck/tests/execve1                   (stderr)
-memcheck/tests/execve2                   (stderr)
-memcheck/tests/gone_abrt_xml             (stderr)
-memcheck/tests/inltemplate               (stderr)
-memcheck/tests/leak-autofreepool-0       (stderr)
-memcheck/tests/leak-autofreepool-1       (stderr)
-memcheck/tests/leak-autofreepool-4       (stderr)
-memcheck/tests/leak_cpp_interior         (stderr)
-memcheck/tests/long_namespace_xml        (stdout)
-memcheck/tests/long_namespace_xml        (stderr)
-memcheck/tests/mismatches                (stderr)
-memcheck/tests/new_nothrow               (stderr)
-memcheck/tests/new_override              (stdout)
-memcheck/tests/new_override              (stderr)
-memcheck/tests/post-syscall              (stderr)
-memcheck/tests/sem                       (stderr)
-memcheck/tests/sigaltstack               (stderr)
-memcheck/tests/signal2                   (stdout)
-memcheck/tests/signal2                   (stderr)
-memcheck/tests/solaris/context_stack_die (stderr)
-memcheck/tests/solaris/door_data         (stderr)
-memcheck/tests/solaris/door_kill         (stdout)
-memcheck/tests/solaris/door_kill         (stderr)
-memcheck/tests/solaris/lsframe2          (stderr)
-memcheck/tests/solaris/scalar_getrandom  (stderr)
-memcheck/tests/supp_unknown              (stderr)
-memcheck/tests/threadname                (stderr)
-memcheck/tests/threadname_xml            (stderr)
-memcheck/tests/vcpu_fnfns                (stdout)
-helgrind/tests/bar_bad                   (stderr)
-helgrind/tests/bar_trivial               (stderr)
-helgrind/tests/bug322621                 (stderr)
-helgrind/tests/free_is_write             (stderr)
-helgrind/tests/pth_barrier1              (stderr)
-helgrind/tests/pth_barrier2              (stderr)
-helgrind/tests/pth_barrier3              (stderr)
-helgrind/tests/tc21_pthonce              (stderr)
-helgrind/tests/tc22_exit_w_lock          (stderr)
-drd/tests/bar_bad                        (stderr)
-drd/tests/bar_bad_xml                    (stderr)
-drd/tests/concurrent_close               (stderr)
-drd/tests/monitor_example                (stderr)
-drd/tests/new_delete                     (stderr)
-drd/tests/omp_matinv                     (stderr)
-drd/tests/omp_matinv_racy                (stderr)
-drd/tests/omp_printf                     (stderr)
-drd/tests/pth_cancel_locked              (stderr)
-drd/tests/sigalrm                        (stderr)
-drd/tests/sigaltstack                    (stderr)
-drd/tests/swapcontext                    (stderr)
-drd/tests/tc22_exit_w_lock               (stderr)
-massif/tests/deep-D                      (post)
-massif/tests/new-cpp                     (stderr)
-massif/tests/new-cpp                     (post)
-massif/tests/overloaded-new              (stderr)
-massif/tests/overloaded-new              (post)
-none/tests/amd64/fxtract                 (stdout)
-none/tests/amd64/ssse3_misaligned        (stderr)
-none/tests/amd64-solaris/coredump_single_thread (stderr)
-none/tests/amd64-solaris/coredump_single_thread (post)
-none/tests/amd64-solaris/coredump_single_thread_sse (stderr)
-none/tests/amd64-solaris/coredump_single_thread_sse (post)
-none/tests/async-sigs                    (stderr)
-none/tests/bug234814                     (stdout)
-none/tests/bug234814                     (stderr)
-none/tests/faultstatus                   (stderr)
-none/tests/gxx304                        (stderr)
-none/tests/pending                       (stdout)
-none/tests/pending                       (stderr)
-none/tests/ppoll_alarm                   (stderr)
-none/tests/pselect_alarm                 (stderr)
-none/tests/pth_2sig                      (stderr)
-none/tests/pth_cancel1                   (stdout)
-none/tests/pth_cancel1                   (stderr)
-none/tests/pth_cancel2                   (stderr)
-none/tests/pth_self_kill_9               (stderr)
-none/tests/sem                           (stderr)
-none/tests/sigstackgrowth                (stdout)
-none/tests/sigstackgrowth                (stderr)
-none/tests/solaris/blockfault            (stderr)
-none/tests/solaris/context_link          (stdout)
-none/tests/solaris/context_link          (stderr)
-none/tests/solaris/context_link2         (stderr)
-none/tests/solaris/context_stack         (stderr)
-none/tests/solaris/coredump_many_threads (stderr)
-none/tests/solaris/coredump_many_threads (post)
-none/tests/solaris/pthread-stack         (stderr)
-none/tests/solaris/sigresend             (stdout)
-none/tests/solaris/sigresend             (stderr)
-none/tests/solaris/stack-overflow        (stderr)
-none/tests/syscall-restart1              (stderr)
-none/tests/syscall-restart2              (stderr)
-none/tests/thread-exits                  (stdout)
-none/tests/thread-exits                  (stderr)
-none/tests/x86/fxtract                   (stdout)
-none/tests/x86-solaris/coredump_single_thread (stderr)
-none/tests/x86-solaris/coredump_single_thread (post)
-none/tests/x86-solaris/coredump_single_thread_sse (stderr)
+== 835 tests, 62 stderr failures, 14 stdout failures, 0 stderrB failures, 0 stdoutB failures, 6 post failures ==
diff --git a/components/developer/valgrind/valgrind.p5m b/components/developer/valgrind/valgrind.p5m
index dda80b7..43e664d 100644
--- a/components/developer/valgrind/valgrind.p5m
+++ b/components/developer/valgrind/valgrind.p5m
@@ -13,10 +13,11 @@
 # Copyright 2015-2017 Aurelien Larcher
 # Copyright 2019 Michal Nowak
 # Copyright 2021-2022 David Stes
-# Copyright 2022 Friedrich Kink
+# Copyright 2022,2023 Friedrich Kink
 #
 
 set name=pkg.fmri value=pkg:/$(COMPONENT_FMRI)@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)
+set name=pkg.human-version value=$(HUMAN_VERSION)
 set name=pkg.summary value="$(COMPONENT_SUMMARY)"
 set name=info.classification value="$(COMPONENT_CLASSIFICATION)"
 set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
@@ -30,14 +31,15 @@
 
 file path=usr/bin/callgrind_annotate
 file path=usr/bin/callgrind_control
-file path=usr/bin/cg_annotate
-file path=usr/bin/cg_diff
-file path=usr/bin/cg_merge
+file path=usr/bin/cg_annotate pkg.depend.bypass-generate=.*
+file path=usr/bin/cg_diff pkg.depend.bypass-generate=.*
+file path=usr/bin/cg_merge pkg.depend.bypass-generate=.*
 file path=usr/bin/ms_print
 file path=usr/bin/valgrind
 file path=usr/bin/valgrind-di-server
 file path=usr/bin/valgrind-listener
 file path=usr/bin/vgdb
+file path=usr/include/valgrind/cachegrind.h
 file path=usr/include/valgrind/callgrind.h
 file path=usr/include/valgrind/config.h
 file path=usr/include/valgrind/dhat.h
@@ -297,6 +299,8 @@
 file path=usr/lib/$(MACH64)/valgrind/s390x-linux64.xml
 file path=usr/lib/$(MACH64)/valgrind/s390x-vx-linux-valgrind.xml
 file path=usr/lib/$(MACH64)/valgrind/s390x-vx-linux.xml
+file path=usr/lib/$(MACH64)/valgrind/valgrind-monitor-def.py
+file path=usr/lib/$(MACH64)/valgrind/valgrind-monitor.py
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_core-amd64-solaris.so
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_core-x86-solaris.so
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_dhat-amd64-solaris.so
@@ -309,6 +313,7 @@
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_massif-x86-solaris.so
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_memcheck-amd64-solaris.so
 file path=usr/lib/$(MACH64)/valgrind/vgpreload_memcheck-x86-solaris.so
+file path=usr/share/doc/valgrind/valgrind_manual.pdf
 file path=usr/share/man/man1/callgrind_annotate.1
 file path=usr/share/man/man1/callgrind_control.1
 file path=usr/share/man/man1/cg_annotate.1

--
Gitblit v1.9.3