mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +00:00
Estimated hours taken: 0.2 Branches: main tools/gdbrun: Do not tell gdb to run the program immediately. Instead, just tell it what command line arguments it should eventually be run with. This allows the user to issue some commands (e.g. to place breakpoints) before running the program.
35 lines
1.1 KiB
Bash
Executable File
35 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
#---------------------------------------------------------------------------#
|
|
# Copyright (C) 2001 The University of Melbourne.
|
|
# This file may only be copied under the terms of the GNU General
|
|
# Public License - see the file COPYING in the Mercury distribution.
|
|
#---------------------------------------------------------------------------#
|
|
#
|
|
# Usage: gdbrun <program> <arguments>
|
|
# Invokes gdb on <program>, and runs the program with the given <arguments>.
|
|
#
|
|
program="$1"
|
|
tmpfile=/tmp/gdbrun.$$
|
|
trap "rm -f $tmpfile" 0 1 2 3 13 15
|
|
shift
|
|
|
|
runargs=""
|
|
for arg in "$@"
|
|
do
|
|
# This quotes spaces properly, which is necessary to handle some of
|
|
# the arguments created by lmc. We do not quote other special
|
|
# characters (e.g. #, >, and \) properly. At the moment there is
|
|
# no need to do so, since lmc does not pass us strings containing
|
|
# such characters (in the usual case that the workspace name has no
|
|
# such characters).
|
|
|
|
case "$arg" in
|
|
*" "*) runargs="$runargs \"$arg\"" ;;
|
|
*) runargs="$runargs $arg" ;;
|
|
esac
|
|
done
|
|
echo "set args $runargs" > "$tmpfile"
|
|
|
|
echo gdb --command="$tmpfile" $program
|
|
gdb --command="$tmpfile" $program
|