download_and_compile.sh: add core file support to run_fgfs_debug.sh
Usage of run_fgfs_debug.sh is slightly changed: you now need to put a '--' argument before all arguments that you want to pass to fgfs. For instance: ./run_fgfs_debug.sh -- --aircraft=ufo --airport=PMDY There is also a new option: -c, alias --core-file. This option allows one to start gdb from an existing fgfs core dump, with appropriate LD_LIBRARY_PATH setting and --directory options; in this case, don't specify any fgfs argument (the fgfs arguments used when the core file was produced have been recorded therein). Example: ./run_fgfs_debug.sh -c /path/to/core All this is documented with './run_fgfs_debug.sh --help'.
This commit is contained in:
+59
-4
@@ -1500,7 +1500,7 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \
|
|||||||
../../flightgear 2>&1 | _logOutput
|
../../flightgear 2>&1 | _logOutput
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ `uname` == 'OpenBSD' ]]; then
|
if [[ "$(uname)" == 'OpenBSD' ]]; then
|
||||||
# _make will end up running fgrcc, which was built with our zlib, so we
|
# _make will end up running fgrcc, which was built with our zlib, so we
|
||||||
# need to set LD_LIBRARY_PATH, otherwise things will fail because the
|
# need to set LD_LIBRARY_PATH, otherwise things will fail because the
|
||||||
# system zlib is too old.
|
# system zlib is too old.
|
||||||
@@ -1519,7 +1519,7 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \
|
|||||||
common="${common}cd \"\$(dirname \"\$0\")\"\n"
|
common="${common}cd \"\$(dirname \"\$0\")\"\n"
|
||||||
common="${common}cd '$SUB_INSTALL_DIR/$FGFS_INSTALL_DIR/bin'\n"
|
common="${common}cd '$SUB_INSTALL_DIR/$FGFS_INSTALL_DIR/bin'\n"
|
||||||
|
|
||||||
if [[ `uname` == 'OpenBSD' ]]; then
|
if [[ "$(uname)" == 'OpenBSD' ]]; then
|
||||||
# Force use of our zlib.
|
# Force use of our zlib.
|
||||||
paths="$paths:../../$ZLIB_INSTALL_DIR/lib"
|
paths="$paths:../../$ZLIB_INSTALL_DIR/lib"
|
||||||
# OpenBSD's base gdb is too old; `pkg_add egdb` gives one that we can use.
|
# OpenBSD's base gdb is too old; `pkg_add egdb` gives one that we can use.
|
||||||
@@ -1536,8 +1536,63 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \
|
|||||||
chmod 755 $SCRIPT
|
chmod 755 $SCRIPT
|
||||||
|
|
||||||
SCRIPT=run_fgfs_debug.sh
|
SCRIPT=run_fgfs_debug.sh
|
||||||
echo -en "$common" > $SCRIPT
|
cat >"$SCRIPT" <<EndOfScriptText
|
||||||
echo "$gdb --directory='$CBD/flightgear/src' --args ./fgfs --fg-root=\"\$PWD/../fgdata\" \"\$@\"" >> $SCRIPT
|
#! /bin/sh
|
||||||
|
|
||||||
|
PROGNAME=\$(basename "\$0")
|
||||||
|
GETOPT=getopt
|
||||||
|
|
||||||
|
USAGE="\$PROGNAME [OPTION...] [-- FGFS_ARG...]
|
||||||
|
Run FlightGear under GDB.
|
||||||
|
|
||||||
|
Note the need for a '--' argument before all fgfs arguments. Examples:
|
||||||
|
|
||||||
|
./run_fgfs_debug.sh -- --aircraft=ufo --airport=PMDY
|
||||||
|
./run_fgfs_debug.sh -c /path/to/core
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-c, --core-file=FILE instruct GDB to examine FILE as a core dump (no need
|
||||||
|
for the '--' and fgfs arguments in this case)
|
||||||
|
--help display this help message and exit"
|
||||||
|
|
||||||
|
CORE_FILE=
|
||||||
|
|
||||||
|
if [ "\$(uname)" = "OpenBSD" ]; then
|
||||||
|
GETOPT=gnugetopt
|
||||||
|
fi
|
||||||
|
TEMP=\$("\$GETOPT" -o '+c:' --longoptions 'core-file:,help' -n "\$PROGNAME" -- "\$@")
|
||||||
|
|
||||||
|
case \$? in
|
||||||
|
0) : ;;
|
||||||
|
1) echo "\$USAGE" >&2; exit 1 ;;
|
||||||
|
*) exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
eval set -- "\$TEMP"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
case "\$1" in
|
||||||
|
-c|--core-file) CORE_FILE="\$2"; shift 2 ;;
|
||||||
|
--help) echo "\$USAGE"; exit 0 ;;
|
||||||
|
--) shift; break ;;
|
||||||
|
*) echo "\$PROGNAME: unexpected option '\$1'; please report a bug." >&2
|
||||||
|
exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
cd "\$(dirname "\$0")/$SUB_INSTALL_DIR/$FGFS_INSTALL_DIR/bin"
|
||||||
|
${set_ld_library_path}
|
||||||
|
|
||||||
|
if [ -z "\$CORE_FILE" ]; then
|
||||||
|
gdb --directory="$INSTALL_DIR_SIMGEAR" \\
|
||||||
|
--directory="$INSTALL_DIR_FGFS" \\
|
||||||
|
--args ./fgfs --fg-root="$INSTALL_DIR_FGFS/fgdata" "\$@"
|
||||||
|
else
|
||||||
|
gdb --directory="$INSTALL_DIR_SIMGEAR" \\
|
||||||
|
--directory="$INSTALL_DIR_FGFS" \\
|
||||||
|
--core="\$CORE_FILE" ./fgfs
|
||||||
|
fi
|
||||||
|
EndOfScriptText
|
||||||
chmod 755 $SCRIPT
|
chmod 755 $SCRIPT
|
||||||
|
|
||||||
# Useful for debugging library problems.
|
# Useful for debugging library problems.
|
||||||
|
|||||||
Reference in New Issue
Block a user