add GDB support
This commit is contained in:
parent
075173185d
commit
7edefbf281
9
cscript
9
cscript
@ -6,9 +6,13 @@ if [ -z "$1" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
|
|||||||
echo " $(basename "$0") <source.c>... <-option>... [-- <args>...]"
|
echo " $(basename "$0") <source.c>... <-option>... [-- <args>...]"
|
||||||
echo "Or at the beginning of a C file:"
|
echo "Or at the beginning of a C file:"
|
||||||
echo " #!$(basename "$0") -s [<options>...]"
|
echo " #!$(basename "$0") -s [<options>...]"
|
||||||
|
echo
|
||||||
|
echo "To debug the program in GDB, just set CSCRIPT_GDB=1."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ -n "$CSCRIPT_GDB" ] && ([ "$CSCRIPT_GDB" = "0" ] || [ "$CSCRIPT_GDB" = "false" ]) && unset CSCRIPT_GDB
|
||||||
|
|
||||||
# Get file names, options and passed-through args
|
# Get file names, options and passed-through args
|
||||||
basedir="."
|
basedir="."
|
||||||
files=""
|
files=""
|
||||||
@ -53,6 +57,7 @@ arg() {
|
|||||||
for a in "$@"; do
|
for a in "$@"; do
|
||||||
arg "$a"
|
arg "$a"
|
||||||
done
|
done
|
||||||
|
[ -n "$CSCRIPT_GDB" ] && opts="$(printf "%s\n%s" "$opts" "-ggdb")"
|
||||||
# Remove empty lines
|
# Remove empty lines
|
||||||
files="$(printf "%s" "$files" | grep '.')"
|
files="$(printf "%s" "$files" | grep '.')"
|
||||||
opts="$(printf "%s" "$opts" | grep '.')"
|
opts="$(printf "%s" "$opts" | grep '.')"
|
||||||
@ -82,6 +87,10 @@ if ! printf "%s\n%s" "$files" "$opts" | xargs -d'\n' cc -Wall -pedantic -o "$tmp
|
|||||||
cleanup
|
cleanup
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$CSCRIPT_GDB" ]; then
|
||||||
|
printf "%s" "$args" | xargs -o -d'\n' gdb --args "$tmpfile"
|
||||||
|
else
|
||||||
printf "%s" "$args" | xargs -d'\n' "$tmpfile"
|
printf "%s" "$args" | xargs -d'\n' "$tmpfile"
|
||||||
|
fi
|
||||||
trap - INT
|
trap - INT
|
||||||
cleanup
|
cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user