summary refs log tree commit diff stats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/empty.txt1
-rwxr-xr-xbin/nim-gdb25
-rw-r--r--bin/nim-gdb.bat14
3 files changed, 40 insertions, 0 deletions
diff --git a/bin/empty.txt b/bin/empty.txt
new file mode 100644
index 000000000..666142073
--- /dev/null
+++ b/bin/empty.txt
@@ -0,0 +1 @@
+This file keeps several tools from deleting this subdirectory.
diff --git a/bin/nim-gdb b/bin/nim-gdb
new file mode 100755
index 000000000..d4d60e432
--- /dev/null
+++ b/bin/nim-gdb
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+# Exit if anything fails
+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 || (echo "readlink not in PATH."; exit 1)
+
+if [[ $(uname -s) == Darwin || $(uname -s) == *BSD ]]; then
+  NIM_SYSROOT=$(dirname $(dirname $(readlink -f $(which nim))))
+else
+  NIM_SYSROOT=$(dirname $(dirname $(readlink -e $(which nim))))
+fi
+
+# Find out where the pretty printer Python module is
+GDB_PYTHON_MODULE_PATH="$NIM_SYSROOT/tools/debug/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}"
+# 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" "$@"
diff --git a/bin/nim-gdb.bat b/bin/nim-gdb.bat
new file mode 100644
index 000000000..b5537dd9d
--- /dev/null
+++ b/bin/nim-gdb.bat
@@ -0,0 +1,14 @@
+@echo off
+for %%i in (nim.exe) do (set NIM_BIN=%%~dp$PATH:i)
+
+for %%i in ("%NIM_BIN%\..\") do (set NIM_ROOT=%%~fi)
+
+set @GDB_PYTHON_MODULE_PATH=%NIM_ROOT%\tools\debug\nim-gdb.py
+set @NIM_GDB=gdb.exe
+
+@echo source %@GDB_PYTHON_MODULE_PATH%> wingdbcommand.txt
+%@NIM_GDB% --command="wingdbcommand.txt" %*
+del wingdbcommand.txt /f /q
+
+EXIT /B %ERRORLEVEL%
+@echo on