From a2a607599ecd6c858c87dead5eac22d4820f93cd Mon Sep 17 00:00:00 2001
From: Simon Rose <simon.rose@ess.eu>
Date: Tue, 16 Jun 2020 14:16:57 +0200
Subject: [PATCH] Added options for gdb/valgrind

---
 tools/iocsh.bash      |  5 +----
 tools/iocsh_functions | 10 ++++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/iocsh.bash b/tools/iocsh.bash
index 1f268e3c..8ff75540 100755
--- a/tools/iocsh.bash
+++ b/tools/iocsh.bash
@@ -121,15 +121,12 @@ ulimit -c unlimited
 
 if [ "$REALTIME" == "RT" ]; then
     export LD_BIND_NOW=1;
-    __CHRT__="chrt --fifo 1 ";
     printf "## \n";
     printf "## Better support for Real-Time IOC Application.\n"
     printf "## Now we set 'export LD_BIND_NOW=%s'\n" "$LD_BIND_NOW";
     printf "## If one may meet the 'Operation not permitted' message, \n";
     printf "## please run %s without the real-time option\n" "$SC_SCRIPTNAME";
     printf "##\n";
-else
-    __CHRT__="";
 fi
 
 if [[ ${BASECODE} -ge  07000101 ]]; then
@@ -140,5 +137,5 @@ fi
 
 #
 #
-${__CHRT__}${EPICS_BASE}/bin/${EPICS_HOST_ARCH}/softIoc${__PVA__} -D ${EPICS_BASE}/dbd/softIoc${__PVA__}.dbd "${IOC_STARTUP}" 2>&1
+${__LOADER__}${EPICS_BASE}/bin/${EPICS_HOST_ARCH}/softIoc${__PVA__} -D ${EPICS_BASE}/dbd/softIoc${__PVA__}.dbd "${IOC_STARTUP}" 2>&1
 
diff --git a/tools/iocsh_functions b/tools/iocsh_functions
index 22931839..3184bde0 100644
--- a/tools/iocsh_functions
+++ b/tools/iocsh_functions
@@ -28,6 +28,7 @@ E_NOTROOT=101
 EXIST=1
 NON_EXIST=0
 REALTIME=
+__LOADER__=
 
 function pushd { builtin pushd "$@" > /dev/null; }
 function popd  { builtin popd  "$@" > /dev/null; }
@@ -384,6 +385,7 @@ function loadFiles
 	    ;;
 	    ( -rt | -RT | -realtime | --realtime )
 	    REALTIME="RT"
+        __LOADER__="chrt --fifo 1 "
 	    ;;
 	    ( @* )
   	    loadFiles $(cat ${file#@})
@@ -422,6 +424,14 @@ function loadFiles
 	    shift
 	    printf "epicsEnvSet EPICS_DRIVER_PATH %s:${EPICS_DRIVER_PATH}\n", $1
 	    ;;
+        ( -dg )
+        shift
+        __LOADER__="gdb --eval-command run --args "
+        ;;
+        ( -dv )
+        shift
+        __LOADER__="valgrind --leak-check=full "
+        ;;
 	    ( -* )
 	    printf "Unknown option $1\n\n" >&2
 	    help
-- 
GitLab