From patchwork Mon Oct 15 15:31:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Stezenbach X-Patchwork-Id: 191571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 6F9792C00A7 for ; Tue, 16 Oct 2012 02:31:31 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sourceware.org; s=default; x=1350919892; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-Help: Sender:Delivered-To; bh=yY5x6M1AHjkDbf7sZZI1OW5TaV0=; b=C91f6akY tW8UUZ5cSt3E9XV9tTVQuLexhTro68S018rGpAS+tS479ZpL/o1LBYx43pBIen74 o5CxuzFX6AJew93QthTLuHOYO8E387P7sv9wPykkCZGz5ZzpWuWBAP/rtXmF572W I/93wqctN0doxrVll2Erdqp3pzWtjjtmLkY= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=sourceware.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-Spam-21-Score:X-Spam-21-Report:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=FJ8R9EsboqLqHgcR6/WihBXH1YX8xYdpcHcYMruvwJC/AdmuuD5ED8YNiwl0xw iZyQpgjLWmNNuuff1ItAAPwoF9DHa8fQcYDmDO4zWGesV1QBNFhCts3I0QUJilmb mt8udIFbMR7GRPjaIoY/iuVfyrS1HsuzZUIpOVGYIr2qo=; Received: (qmail 21035 invoked by alias); 15 Oct 2012 15:31:22 -0000 Received: (qmail 21019 invoked by uid 22791); 15 Oct 2012 15:31:21 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from bar.sig21.net (HELO bar.sig21.net) (80.81.252.164) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Oct 2012 15:31:14 +0000 Received: from p5099b351.dip0.t-ipconnect.de ([80.153.179.81] helo=zzz.local) by bar.sig21.net with esmtpsa (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.72) (envelope-from ) id 1TNmdL-0001Fs-Bv for crossgcc@sourceware.org; Mon, 15 Oct 2012 17:31:13 +0200 Received: from js by zzz.local with local (Exim 4.80) (envelope-from ) id 1TNmdK-0002us-U5 for crossgcc@sourceware.org; Mon, 15 Oct 2012 17:31:10 +0200 Date: Mon, 15 Oct 2012 17:31:10 +0200 From: Johannes Stezenbach To: crossgcc@sourceware.org Subject: [PATCH] ct-ng build debug shell Message-ID: <20121015153110.GA31836@sig21.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-21-Score: -2.9 (--) X-Spam-21-Report: No, score=-2.9 required=8.0 tests=ALL_TRUSTED=-1, BAYES_00=-1.9 autolearn=ham X-IsSubscribed: yes Mailing-List: contact crossgcc-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: crossgcc-owner@sourceware.org Delivered-To: mailing list crossgcc@sourceware.org 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 --- For unsubscribe information see http://sourceware.org/lists.html#faq 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 CT_DoEnd()