[PATCH] ct-ng build debug shell
Johannes Stezenbach
js@sig21.net
Mon Oct 15 15:31:00 GMT 2012
Add experimental debug config option to make crosstool-NG
drop into shell prompt on build errors instead of
just aborting the build.
Signed-off-by: Johannes Stezenbach <js@sig21.net>
diff -r c94bf1e11db2 config/global/ct-behave.in
--- a/config/global/ct-behave.in Mon Oct 15 11:48:02 2012 +0200
+++ b/config/global/ct-behave.in Mon Oct 15 17:24:08 2012 +0200
@@ -71,6 +71,25 @@
further doesn't gain much, and takes far more time (believe me, I've
got figures here! :-) ).
+config DEBUG_CT_FIXUP_SHELL
+ bool
+ prompt "Drop into shell prompt on build errors"
+ depends on EXPERIMENTAL
+ help
+ By default. crosstool-NG terminates the build when a build
+ command fails. When this option is selected, crosstool-NG
+ instead drops into a shell prompt, with the environment set
+ up appropriately to re-run build commands manually to debug
+ the failure or even hot-fix it. You then have three choices,
+ which you select by the shell exit code:
+ exit 1: you hot-fixed the issue, continue with the next build command
+ exit 2: ask crosstool-NG to re-run the failed build command
+ exit 3: ask crosstool-NG to abort the build
+ Other exit codes and ^D just cause crosstool-NG to restart the
+ shell and print a helpful message.
+ Note that this feature is disabled if stdin, stdout or stderr
+ are not to a terminal.
+
config NO_OVERIDE_LC_MESSAGES
bool
prompt "Do *not* overide LC_MESSAGES (EXPERIMENTAL)"
diff -r c94bf1e11db2 scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in Mon Oct 15 11:48:02 2012 +0200
+++ b/scripts/crosstool-NG.sh.in Mon Oct 15 17:24:08 2012 +0200
@@ -25,6 +25,15 @@
. .config.2
# Yes! We can do full logging from now on!
+if [ "${CT_DEBUG_CT_FIXUP_SHELL}" = "y" ]; then
+ # Note: stdout is saved in fd 6
+ if [ -t 0 -a -t 6 -a -t 2 ]; then
+ CT_DoExecLog() { CT_DoExecLog_WithFixupShell "$@"; }
+ else
+ CT_DoLog WARN "CT_DEBUG_CT_FIXUP_SHELL disabled due to I/O redirection"
+ fi
+fi
+
# Override the locale early, in case we ever translate crosstool-NG messages
if [ -z "${CT_NO_OVERIDE_LC_MESSAGES}" ]; then
export LC_ALL=C
diff -r c94bf1e11db2 scripts/functions
--- a/scripts/functions Mon Oct 15 11:48:02 2012 +0200
+++ b/scripts/functions Mon Oct 15 17:24:08 2012 +0200
@@ -175,6 +175,61 @@
[ $? -eq 0 ]
}
+# Variant of CT_DoExecLog for CT_DEBUG_CT_FIXUP_SHELL=y
+CT_DoExecLog_WithFixupShell() {
+ local level="$1"
+ local result
+ shift
+ (
+ for i in "$@"; do
+ tmp_log+="'${i}' "
+ done
+ while true; do
+ case "${1}" in
+ *=*) eval export "'${1}'"; shift;;
+ *) break;;
+ esac
+ done
+ 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 ]
+}
+
# Tail message to be logged whatever happens
# Usage: CT_DoEnd <level>
CT_DoEnd()
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list