File 0925-erts-Make-cerl-dump-use-file-to-find-core-file-execu.patch of Package erlang

From 779235fba7defaea223e08e0786348ecfb8781da Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Tue, 1 Feb 2022 17:34:08 +0100
Subject: [PATCH 2/3] erts: Make cerl -dump use file to find core file
 executable if possible

---
 erts/etc/unix/cerl.src | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/erts/etc/unix/cerl.src b/erts/etc/unix/cerl.src
index 14e8cc3172..85396e3d81 100644
--- a/erts/etc/unix/cerl.src
+++ b/erts/etc/unix/cerl.src
@@ -486,6 +486,12 @@ elif [ "x$GDB" = "xegdb" ]; then
     exec $EMACS --eval "$EVAL"
 elif [ "x$GDB" = "xdump" ]; then
     cmdfile="/tmp/.cerlgdb.$$"
+    ## Examine the result of "file $core" in case it is not the emulator
+    ## that created the dump
+    fileCore=$(file "$core" | sed "s@.*execfn:\\s*'\([^']*\).*@\\1@g")
+    if [ -f "${fileCore}" ] && [ "$(basename ${fileCore})" != "${EMU_NAME}" ]; then
+        EMU_NAME="${fileCore}"
+    fi
     case "x$core" in
 	x/*)
 	    ;;
@@ -505,11 +511,11 @@ quit
         *)
 	    echo "set width 0
 set height 0
-set verbose off
-
-source $ROOTDIR/erts/etc/unix/etp-commands
-thread apply all bt
-" > $cmdfile
+set verbose off" > $cmdfile
+            if echo "${EMU_NAME}" | grep "beam."; then
+                echo "source $ROOTDIR/erts/etc/unix/etp-commands" >> $cmdfile
+            fi
+            echo "thread apply all bt" >> $cmdfile
 	    exec gdb --batch --command=$cmdfile $EMU_NAME $core
 	    ;;
     esac
-- 
2.34.1

openSUSE Build Service is sponsored by