This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See crosstool-NG for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] ct-ng build debugging


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 <js@sig21.net>

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.


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 <level> [VAR=val...] <command> [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 ]

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]