summary refs log tree commit diff stats
path: root/bin/nim-gdb
diff options
context:
space:
mode:
authorJoey <jyapayne@gmail.com>2020-03-16 01:59:16 -0600
committerGitHub <noreply@github.com>2020-03-16 08:59:16 +0100
commitfd3583803e8e310c2c6f60c79aab42a56b931a56 (patch)
tree9a9aff91944fd892aefc8245ead4e0842f0c48eb /bin/nim-gdb
parentae5094e1432cef8c32575915ae1e19deffe7df61 (diff)
downloadNim-fd3583803e8e310c2c6f60c79aab42a56b931a56.tar.gz
Fix gdb scripts (#13658)
* Fix nim-gdb and rename to nim-gdb.bash
* Add symlink to nim-gdb.bash
* Fix windows debug script
* Add PR suggestions
* Make readlink check easier to maintain/understand
* Swap symlinks
Diffstat (limited to 'bin/nim-gdb')
-rwxr-xr-xbin/nim-gdb20
1 files changed, 9 insertions, 11 deletions
diff --git a/bin/nim-gdb b/bin/nim-gdb
index e6e3a1c49..b9956073b 100755
--- a/bin/nim-gdb
+++ b/bin/nim-gdb
@@ -5,25 +5,23 @@ set -e
 
 which nim > /dev/null || (echo "nim not in PATH"; exit 1)
 which gdb > /dev/null || (echo "gdb not in PATH"; exit 1)
-which readlink > /dev/null || which greadlink > /dev/null || (echo "readlink not in PATH. Please install coreutils from brew if on Mac."; exit 1)
 
-nreadlink () {
-    (which greadlink > /dev/null && greadlink "$@") || (which readlink > /dev/null && readlink "$@") || echo "Readlink could not be found"
-}
+if [[ "$(uname -s)" == "Darwin" ]]; then
+  which greadlink > /dev/null || (echo "readlink not in PATH. Please install coreutils from homebrew."; exit 1)
+  READLINK=greadlink
+else
+  which readlink > /dev/null || (echo "readlink not in PATH."; exit 1)
+  READLINK=readlink
+fi
 
 # Find out where the pretty printer Python module is
-NIM_SYSROOT=$(dirname $(dirname $(nreadlink -e $(which nim))))
+NIM_SYSROOT=$(dirname $(dirname $($READLINK -e $(which nim))))
 GDB_PYTHON_MODULE_PATH="$NIM_SYSROOT/tools/nim-gdb.py"
 
 # Run GDB with the additional arguments that load the pretty printers
 # Set the environment variable `NIM_GDB` to overwrite the call to a
 # different/specific command (defaults to `gdb`).
 NIM_GDB="${NIM_GDB:-gdb}"
-
-# This is needed for some reason. I can't get -eval-command to work ever
-echo "source $GDB_PYTHON_MODULE_PATH" > gdbcommands.txt
 # exec replaces the new process of bash with gdb. It is always good to
 # have fewer processes.
-exec ${NIM_GDB} --command="gdbcommands.txt" "$@"
-
-rm gdbcommands.txt
+exec "${NIM_GDB}" -eval-command="source $GDB_PYTHON_MODULE_PATH" "$@"