From patchwork Tue Apr 21 21:41:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 463496 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 24CAD1400DE for ; Wed, 22 Apr 2015 07:41:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=FWrUTJTm; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=utq0w2/StVgoW1/eeJHcp48rKsYV1e2Y9zYQ66EoxE2IkZE3eZBuS BZbvqsrMD8r6Y643NPIBOWVGRZZCVMoOU7qXYf52f/1Zm62IYsNY69Vk6L0Ve6IH kkB//T+JuzwnrQKLewhNQYV14rh045sAXWCTV4zxWvBjcbTXhson40= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=/EPWpt7ji+TJ1ahcIcgykc6bMXM=; b=FWrUTJTm4ycFBU/lyBsmp5S2X5lf z7PUcZwdAxWhBEP92gEnej8E0Owl64HQiaLg5vinn+KMeuivc2tjcKZLFWHvjJ8S Vmpf/LkxBWcNHgAuPqMKRKCinP0fgvxSkIw9mQ6wIwPy01pfDIlYr1Y4gMo6GJ6W n2Z7TlruGYwUVGU= Received: (qmail 11008 invoked by alias); 21 Apr 2015 21:41:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10954 invoked by uid 89); 21 Apr 2015 21:41:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 21 Apr 2015 21:41:27 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3LLfQIZ005028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 21 Apr 2015 17:41:26 -0400 Received: from host1.jankratochvil.net (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3LLfOsF004436; Tue, 21 Apr 2015 17:41:25 -0400 Subject: [PATCH 3/5] libcc1: set debug compile: Display GCC driver filename From: Jan Kratochvil To: gcc-patches@gcc.gnu.org Cc: Phil Muldoon Date: Tue, 21 Apr 2015 23:41:24 +0200 Message-ID: <20150421214124.14972.97552.stgit@host1.jankratochvil.net> In-Reply-To: <20150421214109.14972.34388.stgit@host1.jankratochvil.net> References: <20150421214109.14972.34388.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes Hi, as discussed in How to use compile & execute function in GDB https://sourceware.org/ml/gdb/2015-04/msg00026.html GDB currently searches for /usr/bin/ARCH-OS-gcc and chooses one but it does not display which one. It cannot, GCC method set_arguments() does not yet know whether 'set debug compile' is enabled or not. Unfortunately this changes libcc1 API in an incompatible way. There is a possibility of a hack to keep the API the same - one could pass "-v" option explicitly to set_arguments(), set_arguments() could compare the "-v" string and print the GCC filename accordingly. Then the 'verbose' parameter of compile() would lose its meaning. What do you think? GDB counterpart: [PATCH 3/4] compile: set debug compile: Display GCC driver filename https://sourceware.org/ml/gdb-patches/2015-04/msg00807.html Message-ID: <20150421213649.14147.79719.stgit@host1.jankratochvil.net> Jan include/ChangeLog 2015-04-21 Jan Kratochvil * gcc-interface.h (enum gcc_base_api_version): Add comment to GCC_FE_VERSION_1. (struct gcc_base_vtable): Move parameter verbose from compile to set_arguments. libcc1/ChangeLog 2015-04-21 Jan Kratochvil * libcc1.cc: Include intl.h. (struct libcc1): Add field verbose. (libcc1::libcc1): Initialize it. (libcc1_set_arguments): Add parameter verbose, implement it. (libcc1_compile): Remove parameter verbose, use self's field instead. --- include/gcc-interface.h | 14 +++++++------- libcc1/libcc1.cc | 22 +++++++++++++++++----- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/include/gcc-interface.h b/include/gcc-interface.h index dcfa6ce..dd9fd50 100644 --- a/include/gcc-interface.h +++ b/include/gcc-interface.h @@ -45,6 +45,8 @@ struct gcc_base_context; enum gcc_base_api_version { GCC_FE_VERSION_0 = 0, + + /* Parameter verbose has been moved from compile to set_arguments. */ GCC_FE_VERSION_1 = 1, }; @@ -71,14 +73,15 @@ struct gcc_base_vtable The arguments are copied by GCC. ARGV need not be NULL-terminated. The arguments must be set separately for each compilation; that is, after a compile is requested, the - previously-set arguments cannot be reused. + previously-set arguments cannot be reused. VERBOSE can be set + to cause GCC to print some information as it works. This returns NULL on success. On failure, returns a malloc()d error message. The caller is responsible for freeing it. */ char *(*set_arguments) (struct gcc_base_context *self, const char *triplet_regexp, - int argc, char **argv); + int argc, char **argv, int /* bool */ verbose); /* Set the file name of the program to compile. The string is copied by the method implementation, but the caller must @@ -95,13 +98,10 @@ struct gcc_base_vtable void *datum); /* Perform the compilation. FILENAME is the name of the resulting - object file. VERBOSE can be set to cause GCC to print some - information as it works. Returns true on success, false on - error. */ + object file. Returns true on success, false on error. */ int /* bool */ (*compile) (struct gcc_base_context *self, - const char *filename, - int /* bool */ verbose); + const char *filename); /* Destroy this object. */ diff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc index afda023..d36073d 100644 --- a/libcc1/libcc1.cc +++ b/libcc1/libcc1.cc @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see #include "xregex.h" #include "findcomp.hh" #include "compiler-name.h" +#include "intl.h" struct libcc1; @@ -66,6 +67,9 @@ struct libcc1 : public gcc_c_context std::vector args; std::string source_file; + + /* Non-zero as an equivalent to gcc driver option "-v". */ + bool verbose; }; // A local subclass of connection that holds a back-pointer to the @@ -97,7 +101,8 @@ libcc1::libcc1 (const gcc_base_vtable *v, print_function (NULL), print_datum (NULL), args (), - source_file () + source_file (), + verbose (false) { base.ops = v; c_ops = cv; @@ -309,13 +314,19 @@ make_regexp (const char *triplet_regexp, const char *compiler) static char * libcc1_set_arguments (struct gcc_base_context *s, const char *triplet_regexp, - int argc, char **argv) + int argc, char **argv, int verbose) { libcc1 *self = (libcc1 *) s; regex_t triplet; int code; + self->verbose = verbose != 0; + std::string rx = make_regexp (triplet_regexp, COMPILER_NAME); + // Simulate fnotice by fprintf. + if (self->verbose) + fprintf (stderr, _("searching for compiler matching regex %s\n"), + rx.c_str()); code = regcomp (&triplet, rx.c_str (), REG_EXTENDED | REG_NOSUB); if (code != 0) { @@ -341,6 +352,8 @@ libcc1_set_arguments (struct gcc_base_context *s, (char *) NULL); } regfree (&triplet); + if (self->verbose) + fprintf (stderr, _("found compiler %s\n"), compiler.c_str()); self->args.push_back (compiler); @@ -434,8 +447,7 @@ fork_exec (libcc1 *self, char **argv, int spair_fds[2], int stderr_fds[2]) static int libcc1_compile (struct gcc_base_context *s, - const char *filename, - int verbose) + const char *filename) { libcc1 *self = (libcc1 *) s; @@ -466,7 +478,7 @@ libcc1_compile (struct gcc_base_context *s, self->args.push_back ("-c"); self->args.push_back ("-o"); self->args.push_back (filename); - if (verbose) + if (self->verbose) self->args.push_back ("-v"); self->connection = new libcc1_connection (fds[0], stderr_fds[0], self);