mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
* 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
28 lines
996 B
Bash
Executable File
28 lines
996 B
Bash
Executable File
#!/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)
|
|
|
|
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 $($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}"
|
|
# 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" "$@"
|