From patchwork Wed Sep 4 21:35:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 272736 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 280002C00E1 for ; Thu, 5 Sep 2013 07:36:29 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4CB458C7A4; Wed, 4 Sep 2013 21:36:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yeejNvyyXN8a; Wed, 4 Sep 2013 21:36:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 07B5D8C8A2; Wed, 4 Sep 2013 21:36:16 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id EE7001C2ACF for ; Wed, 4 Sep 2013 21:36:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id E3FCB8C7DC for ; Wed, 4 Sep 2013 21:36:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qhgF7KblJYfg for ; Wed, 4 Sep 2013 21:36:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5DADE8C656 for ; Wed, 4 Sep 2013 21:36:09 +0000 (UTC) Received: by mail-wi0-f178.google.com with SMTP id hn9so1027162wib.11 for ; Wed, 04 Sep 2013 14:36:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=jdWXyt5PJeJvg6/ejZC596CmGYNlh1johSGfSx3rIdQ=; b=UJ0lbWOef2+8rlB0pj7C64lRYKYEUBRgOVQcjgH4gc0BOM42MNQ4tIHUVbiydKBK/U V3PN1UmjGixaGoO1Ydiyv0rcCe1oSn2afn5FNIENzEWMHluqXrtUnBNo7NK1ZwmO9wsG ebakQrhQVp75yk0fvC/9xDWJcT92f50+7alzrmTrJrkU1a3ZMtn4LzyrKxTBDytyMhau WjlQ5wNph6XMTCniFIkMvqlBi9olDQGhCe99zp8w2vamGQuEzrWWRMjQTa77+2CAjDT1 CuX2LxFhKUElJcQxiGm0wIzd/bL+NA01cEAVqesaTudXO7VmNx3/3nvpkvQLltdR0K6B kucQ== X-Received: by 10.194.109.68 with SMTP id hq4mr4276544wjb.12.1378330567934; Wed, 04 Sep 2013 14:36:07 -0700 (PDT) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id a8sm7147831wie.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 14:36:07 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@busybox.net Date: Wed, 4 Sep 2013 23:35:56 +0200 Message-Id: X-Mailer: git-send-email 1.8.1.2 In-Reply-To: References: In-Reply-To: References: Cc: "Yann E. MORIN" Subject: [Buildroot] [PATCH 4/4] toolchain/wrapper: add option to print one argument per line X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net From: "Yann E. MORIN" In case there are many arguments passed to the tools, the command line can get very long, and difficult to parse visually. For example, the Linux kernel passes a lot of arguments to gcc (at least 45, which gives 53 with our hard-coded args). Looking at such a command line is daunting. So, add the possibility to print each argument on its own line. Also, enclose all args between single quotes, so the command line can be safely copy-pasted without special chars (spaces, $) being inrerpreted by the shell. Signed-off-by: "Yann E. MORIN" Acked-by: Luca Ceresoli Tested-by: Luca Ceresoli --- .../toolchain-external/ext-toolchain-wrapper.c | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c index 565e36b..dfdfcff 100644 --- a/toolchain/toolchain-external/ext-toolchain-wrapper.c +++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c @@ -74,7 +74,8 @@ int main(int argc, char **argv) char *relbasedir, *absbasedir; char *progpath = argv[0]; char *basename; - int ret, i, count = 0; + char *env_debug; + int ret, i, count = 0, debug; /* Calculate the relative paths */ basename = strrchr(progpath, '/'); @@ -157,13 +158,21 @@ int main(int argc, char **argv) /* finish with NULL termination */ *cur = NULL; - if (getenv("BR_DEBUG_WRAPPER")) { - fprintf(stderr, "Executing"); - - for (i = 0; args[i]; i++) - fprintf(stderr, " %s", args[i]); - - fprintf(stderr, "\n"); + /* Debug the wrapper to see actual arguments passed to + * the compiler: + * unset, empty, or 0: do not trace + * set to 1 : trace all arguments on a single line + * set to 2 : trace one argument per line + */ + if ((env_debug = getenv("BR_DEBUG_WRAPPER"))) { + debug = atoi(env_debug); + if (debug > 0) { + fprintf(stderr, "Toolchain wrapper executing:"); + for (i = 0; args[i]; i++) + fprintf(stderr, "%s'%s'", + (debug == 2)?"\n ":" ", args[i]); + fprintf(stderr, "\n"); + } } if (execv(path, args))