nim-gdb 996 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. # Exit if anything fails
  3. set -e
  4. which nim > /dev/null || (echo "nim not in PATH"; exit 1)
  5. which gdb > /dev/null || (echo "gdb not in PATH"; exit 1)
  6. if [[ "$(uname -s)" == "Darwin" ]]; then
  7. which greadlink > /dev/null || (echo "readlink not in PATH. Please install coreutils from homebrew."; exit 1)
  8. READLINK=greadlink
  9. else
  10. which readlink > /dev/null || (echo "readlink not in PATH."; exit 1)
  11. READLINK=readlink
  12. fi
  13. # Find out where the pretty printer Python module is
  14. NIM_SYSROOT=$(dirname $(dirname $($READLINK -e $(which nim))))
  15. GDB_PYTHON_MODULE_PATH="$NIM_SYSROOT/tools/nim-gdb.py"
  16. # Run GDB with the additional arguments that load the pretty printers
  17. # Set the environment variable `NIM_GDB` to overwrite the call to a
  18. # different/specific command (defaults to `gdb`).
  19. NIM_GDB="${NIM_GDB:-gdb}"
  20. # exec replaces the new process of bash with gdb. It is always good to
  21. # have fewer processes.
  22. exec "${NIM_GDB}" -eval-command="source $GDB_PYTHON_MODULE_PATH" "$@"