File 8051-cerl-start-GDB-w-commands-file-like-GDB-in-Emacs.patch of Package erlang
From e81c27586545ff840ba7ba141a1619907cb32e82 Mon Sep 17 00:00:00 2001
From: Daniel Finke <danielfinke2011@gmail.com>
Date: Wed, 18 Sep 2024 10:47:45 -0700
Subject: [PATCH] cerl: start GDB w/ commands file like GDB in Emacs
When calling `cerl -rgdb`, start GDB with the same commands file as when
calling `cerl -gdb`. Uses the same changes as introduced in cc6b223.
---
erts/etc/unix/cerl.src | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/erts/etc/unix/cerl.src b/erts/etc/unix/cerl.src
index bf64654a2c..af63ee1599 100644
--- a/erts/etc/unix/cerl.src
+++ b/erts/etc/unix/cerl.src
@@ -438,23 +438,24 @@ elif [ "x$GDB" = "xgdb" ]; then
case "x$core" in
x)
# Get emu args to use from erlexec...
- beam_args=`$EXEC -emu_args_exit $xargs ${1+"$@"}`
- gdbcmd="--args $EMU_NAME $beam_args"
+ beam_args=`$EXEC -emu_args_exit $xargs ${1+"$@"} | sed 's/"/\\\\"/g' | tr '\n' ' '`
+ gdbcmd="set args $beam_args"
;;
x/*)
- gdbcmd="$EMU_NAME ${core}"
+ gdbcmd="core ${core}"
GDBBP=
;;
*)
- dir=`pwd`
- gdbcmd="$EMU_NAME ${dir}/${core}"
+ gdbcmd="core `pwd`/${core}"
GDBBP=
;;
esac
+ # Fire up gdb
cmdfile="/tmp/.cerlgdb.$$"
- echo "source $ROOTDIR/erts/etc/unix/etp-commands" > $cmdfile
- # Fire up gdb in emacs...
- exec gdb $GDBBP -x $cmdfile $gdbcmd
+ echo "file $BINDIR/$EMU_NAME" > $cmdfile
+ echo "$gdbcmd" >> $cmdfile
+ echo "source $ROOTDIR/erts/etc/unix/etp-commands" >> $cmdfile
+ exec gdb $GDBBP -x $cmdfile
elif [ "x$GDB" = "xlldb" ]; then
case "x$core" in
x)
@@ -481,11 +482,11 @@ elif [ "x$GDB" = "xegdb" ]; then
gdbcmd="set args $beam_args"
;;
x/*)
- gdbcmd="core $core"
+ gdbcmd="core ${core}"
GDBBP=
;;
*)
- gdbcmd="core `pwd`/$core"
+ gdbcmd="core `pwd`/${core}"
GDBBP=
;;
esac
--
2.43.0