From 11949b1e8e9c90a5ff3d86c84f504a8d09f1068f Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Thu, 24 Nov 2022 23:52:55 +0100 Subject: [PATCH] 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'. --- download_and_compile.sh | 63 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/download_and_compile.sh b/download_and_compile.sh index 38796f6..42223d7 100755 --- a/download_and_compile.sh +++ b/download_and_compile.sh @@ -1500,7 +1500,7 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \ ../../flightgear 2>&1 | _logOutput fi - if [[ `uname` == 'OpenBSD' ]]; then + if [[ "$(uname)" == 'OpenBSD' ]]; then # _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 # system zlib is too old. @@ -1519,7 +1519,7 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \ common="${common}cd \"\$(dirname \"\$0\")\"\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. paths="$paths:../../$ZLIB_INSTALL_DIR/lib" # 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 SCRIPT=run_fgfs_debug.sh - echo -en "$common" > $SCRIPT - echo "$gdb --directory='$CBD/flightgear/src' --args ./fgfs --fg-root=\"\$PWD/../fgdata\" \"\$@\"" >> $SCRIPT + cat >"$SCRIPT" <&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 # Useful for debugging library problems.