File 0154-Fix-ETP-new-fun-arity-format.patch of Package erlang

From 4f0cea4957f270a5d15c982b23140dd59fa0ee97 Mon Sep 17 00:00:00 2001
From: Raimo Niskanen <raimo@erlang.org>
Date: Fri, 26 Sep 2025 13:39:37 +0200
Subject: [PATCH] Fix ETP new fun arity format

---
 erts/emulator/beam/erl_etp.c  |  2 ++
 erts/etc/unix/etp-commands.in | 13 ++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/erts/emulator/beam/erl_etp.c b/erts/emulator/beam/erl_etp.c
index 2bcf767d94..085aaaf7d7 100644
--- a/erts/emulator/beam/erl_etp.c
+++ b/erts/emulator/beam/erl_etp.c
@@ -131,6 +131,8 @@ const Eterm etp_tag_header_map = _TAG_HEADER_MAP;
 const Eterm etp_tag_header_mask = _TAG_HEADER_MASK;
 const Eterm etp_header_subtag_mask = _HEADER_SUBTAG_MASK;
 const Eterm etp_header_arity_offs = _HEADER_ARITY_OFFS;
+const Eterm etp_header_fun_kind_offs = FUN_HEADER_KIND_OFFS;
+const Eterm etp_header_fun_env_size_offs = FUN_HEADER_ENV_SIZE_OFFS;
 
 const Eterm etp_tag_primary_size = _TAG_PRIMARY_SIZE;
 const Eterm etp_tag_primary_mask = _TAG_PRIMARY_MASK;
diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in
index 3f4bd8812a..da2cee3244 100644
--- a/erts/etc/unix/etp-commands.in
+++ b/erts/etc/unix/etp-commands.in
@@ -426,8 +426,17 @@ define etp-boxed-immediate-1
                 else
                   # Hexdump the rest
                   if ($etp_boxed_immediate_h == etp_fun_subtag)
-                    printf "#Fun<"
+                    set $etp_boxed_immediate_arity = \
+                      ((($etp_boxed_immediate_p[0] >> \
+                         etp_header_fun_env_size_offs) & 0xff) + 1)
+                    if ($etp_boxed_immediate_p[0] >> etp_header_fun_kind_offs)
+                      printf "#FunX<"
+                    else
+                      printf "#FunL<"
+                    end
                   else
+                    set $etp_boxed_immediate_arity = \
+                      ($etp_boxed_immediate_p[0] >> etp_header_arity_offs)
                     if ($etp_boxed_immediate_h == etp_bin_ref_subtag)
                       printf "#BinRef<"
                     else
@@ -442,8 +451,6 @@ define etp-boxed-immediate-1
                       end
                     end
                   end
-                  set $etp_boxed_immediate_arity = \
-                    ($etp_boxed_immediate_p[0] >> etp_header_arity_offs)
                   while $etp_boxed_immediate_arity > 0
                     set $etp_boxed_immediate_p++
                     if $etp_boxed_immediate_arity > 1
-- 
2.51.0

openSUSE Build Service is sponsored by