summaryrefslogtreecommitdiff
path: root/erts/etc/unix/cerl.src
diff options
context:
space:
mode:
Diffstat (limited to 'erts/etc/unix/cerl.src')
-rw-r--r--erts/etc/unix/cerl.src48
1 files changed, 33 insertions, 15 deletions
diff --git a/erts/etc/unix/cerl.src b/erts/etc/unix/cerl.src
index faf54e2bdc..8046cee347 100644
--- a/erts/etc/unix/cerl.src
+++ b/erts/etc/unix/cerl.src
@@ -2,7 +2,7 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2003-2022. All Rights Reserved.
+# Copyright Ericsson AB 2003-2023. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -81,9 +81,28 @@ run_asan=no
run_rr=no
skip_erlexec=no
+prog="$0"
+progdir="`dirname ${prog}`"
+dyn_erl_path="${progdir}/%DYN_ERL_PATH%"
+if [ -f "$dyn_erl_path" ]
+then
+ dyn_rootdir=`${dyn_erl_path} --realpath`
+ dyn_rootdir=`dirname ${dyn_rootdir}`
+ dyn_rootdir=`dirname ${dyn_rootdir}`
+else
+ dyn_rootdir=""
+fi
+
# Default rootdir
ROOTDIR=%SRC_ROOTDIR%
-BINDIR="$ROOTDIR/bin/`$ROOTDIR/erts/autoconf/config.guess`"
+
+if [ "$dyn_rootdir" != "$ROOTDIR" ] && [ "$dyn_rootdir" != "" ]
+then
+ # It is likely that the files have been copied or moved
+ ROOTDIR="$dyn_rootdir"
+fi
+
+BINDIR="$ROOTDIR/bin/`$ROOTDIR/make/autoconf/config.guess`"
TARGET=%TARGET%
#BINDIR="$ROOTDIR/bin/%TARGET%"
PROGNAME=$ROOTDIR/bin/cerl
@@ -414,7 +433,7 @@ elif [ "x$GDB" = "xgdb" ]; then
case "x$core" in
x)
# Get emu args to use from erlexec...
- beam_args=`$EXEC -emu_args_exit ${1+"$@"}`
+ beam_args=`$EXEC -emu_args_exit $xargs ${1+"$@"}`
gdbcmd="--args $EMU_NAME $beam_args"
;;
x/*)
@@ -434,7 +453,7 @@ elif [ "x$GDB" = "xgdb" ]; then
elif [ "x$GDB" = "xlldb" ]; then
case "x$core" in
x)
- beam_args=`$EXEC -emu_args_exit ${1+"$@"}`
+ beam_args=`$EXEC -emu_args_exit $xargs ${1+"$@"}`
lldbcmd="-- $beam_args"
;;
*)
@@ -453,18 +472,15 @@ elif [ "x$GDB" = "xegdb" ]; then
case "x$core" in
x)
# Get emu args to use from erlexec...
- beam_args=`$EXEC -emu_args_exit ${1+"$@"} | tr '\n' ' '`
- gdbcmd="(insert-string \"set args $beam_args\") \
- (comint-send-input)"
+ beam_args=`$EXEC -emu_args_exit $xargs ${1+"$@"} | sed 's/"/\\\\"/g' | tr '\n' ' '`
+ gdbcmd="set args $beam_args"
;;
x/*)
- gdbcmd="(insert-string \"core ${core}\") (comint-send-input)"
+ gdbcmd="core $core"
GDBBP=
;;
*)
- dir=`pwd`
- gdbcmd="(insert-string \"core ${dir}/${core}\") \
- (comint-send-input)"
+ gdbcmd="core `pwd`/$core"
GDBBP=
;;
esac
@@ -483,11 +499,13 @@ elif [ "x$GDB" = "xegdb" ]; then
GDBARGS="--annotate=1 "
fi
fi
- gdbcmd="$gdbcmd $GDBBP \
- (insert-string \"source $ROOTDIR/erts/etc/unix/etp-commands\") \
- (comint-send-input)"
# Fire up gdb in emacs...
- exec $EMACS --eval "(progn (gdb \"gdb $GDBARGS$EMU_NAME\") $gdbcmd)"
+ cmdfile="/tmp/.cerlgdb.$$"
+ echo "file $BINDIR/$EMU_NAME" > $cmdfile
+ echo "$gdbcmd" >> $cmdfile
+ echo "source $ROOTDIR/erts/etc/unix/etp-commands" >> $cmdfile
+ EVAL="(progn (gdb \"gdb $GDBARGS -x $cmdfile\"))"
+ 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