From patchwork Fri Sep 28 16:35:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [RFC] ct-ng build debugging Date: Fri, 28 Sep 2012 06:35:47 -0000 From: Johannes Stezenbach X-Patchwork-Id: 187836 Message-Id: <20120928163547.GB17447@sig21.net> To: crossgcc@sourceware.org Hi, I hacked up the patch below which drops into a shell prompt when the ct-ng build breaks, with the environment properly set up. It allows one to check what went wrong and possibly hot-fix it. Of course a real patch should use a developer config option, but I'm out of time atm and can't finish it. If you find it useful it would be nice if someone could pick it up and polish it for inclusion. (The "backtrace" change at the top is actually a seperate bugfix for when things go wrong early in crosstool-NG.sh before CT_BUILD_DIR is set.) Signed-off-by: Johannes Stezenbach PS: I'm not good at writing bash scripts, maybe there's a better way to do it. It's also not much tested but it worked for re-running make and changing the gcc command to look at the cpp output from the glibc breakage I just reported. --- For unsubscribe information see http://sourceware.org/lists.html#faq diff -r 43ace4bb005e scripts/functions --- a/scripts/functions Wed Sep 26 16:37:31 2012 +0200 +++ b/scripts/functions Fri Sep 28 18:15:49 2012 +0200 @@ -11,8 +11,8 @@ # To avoid printing the backtace for each sub-shell # up to the top-level, just remember we've dumped it - if [ ! -f "${CT_BUILD_DIR}/backtrace" ]; then - touch "${CT_BUILD_DIR}/backtrace" + if [ ! -f "${CT_WORK_DIR}/backtrace" ]; then + touch "${CT_WORK_DIR}/backtrace" # Print steps backtrace step_depth=${CT_STEP_COUNT} @@ -50,7 +50,7 @@ CT_DoLog ERROR "" CT_DoEnd ERROR - rm -f "${CT_BUILD_DIR}/backtrace" + rm -f "${CT_WORK_DIR}/backtrace" fi exit $ret } @@ -157,6 +157,7 @@ # Usage: CT_DoExecLog [VAR=val...] [parameters...] CT_DoExecLog() { local level="$1" + local result shift ( for i in "$@"; do @@ -168,8 +169,41 @@ *) break;; esac done - CT_DoLog DEBUG "==> Executing: ${tmp_log}" - "${@}" 2>&1 |CT_DoLog "${level}" + trap ERR + while true; do + CT_DoLog DEBUG "==> Executing: ${tmp_log}" + "${@}" 2>&1 |CT_DoLog "${level}" + result=$? + if [ $result -eq 0 ]; then + break + fi + ( + exec >&6 + echo "command error $result:" + echo "$@" + echo "please fix it up and finish by exiting the shell" + while true; do + bash --rcfile <(echo "PS1='ct-ng:\w> '") -i + result=$? + case $result in + 1) result=0; break;; + 2) break;; + 3) break;; + *) echo "please exit with one of these values:" + echo "1 fixed, continue with next build command" + echo "2 repeat this build command" + echo "3 abort build" + ;; + esac + done + exit $result + ) + result=$? + if [ $result -ne 2 ]; then + break + fi + done + exit $result ) # Catch failure of the sub-shell [ $? -eq 0 ]