summary refs log tree commit diff stats
path: root/bin/nim-gdb
diff options
context:
space:
mode:
authorJoey <jyapayne@gmail.com>2020-02-21 00:53:05 -0700
committerGitHub <noreply@github.com>2020-02-21 08:53:05 +0100
commit3667fd9f426eac968c326b3dc9571b7b7e8fef67 (patch)
treef975bd3cb208dc8145cf515804482827df679ab7 /bin/nim-gdb
parent7a2b623d2a160f2a9a9464a29a51a343dec303ec (diff)
downloadNim-3667fd9f426eac968c326b3dc9571b7b7e8fef67.tar.gz
Make gdb script work on mac and linux; add windows gdb script (#13453)
Diffstat (limited to 'bin/nim-gdb')
-rwxr-xr-xbin/nim-gdb16
1 files changed, 12 insertions, 4 deletions
diff --git a/bin/nim-gdb b/bin/nim-gdb
index 9d6f462bb..e6e3a1c49 100755
--- a/bin/nim-gdb
+++ b/bin/nim-gdb
@@ -5,17 +5,25 @@ 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"
+}
 
 # Find out where the pretty printer Python module is
-NIM_SYSROOT=$(dirname $(dirname $(readlink -e $(which nim))))
+NIM_SYSROOT=$(dirname $(dirname $(nreadlink -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} \
-  -eval-command "source $GDB_PYTHON_MODULE_PATH" \
-  "$@"
+exec ${NIM_GDB} --command="gdbcommands.txt" "$@"
+
+rm gdbcommands.txt