nim-gdb 932 B

1234567891011121314151617181920212223242526
  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. which readlink > /dev/null || (echo "readlink not in PATH."; exit 1)
  7. if [[ "$(uname -s)" == "Darwin" || "(uname -s)" == *"BSD" ]]; then
  8. NIM_SYSROOT=$(dirname $(dirname $(readlink -f $(which nim))))
  9. else
  10. NIM_SYSROOT=$(dirname $(dirname $(readlink -e $(which nim))))
  11. fi
  12. # Find out where the pretty printer Python module is
  13. GDB_PYTHON_MODULE_PATH="$NIM_SYSROOT/tools/nim-gdb.py"
  14. # Run GDB with the additional arguments that load the pretty printers
  15. # Set the environment variable `NIM_GDB` to overwrite the call to a
  16. # different/specific command (defaults to `gdb`).
  17. NIM_GDB="${NIM_GDB:-gdb}"
  18. # exec replaces the new process of bash with gdb. It is always good to
  19. # have fewer processes.
  20. exec "${NIM_GDB}" -eval-command="source $GDB_PYTHON_MODULE_PATH" "$@"