From patchwork Sun May 24 18:55:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 475991 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 3F26E14029C for ; Mon, 25 May 2015 04:56:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=JOG07xyT; 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=kIc6nMWbbqMDEG7K9AVig61lWL/JHYyfOypR5Fznz5A/M83TXMLXJ tNiMzHGguiks19DoIKJQ6bADMcHG8esOxsyKneI8iynh0iNjmWwF3ISP8+XhgjQM 7Yz0BNoM1ffXVP1fKBF+AtRqwTveA5758KmwCgDtlqFOBut8Q3Qr3I= 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=eGtC96JXCXt/RO/6dg22YA/GBHc=; b=JOG07xyTR23JQ1R/h5Ll1yVUV0sg P9upoOEiXjVnm8uWIZ2v8WLk4C64SGHdr+hEqfDci7rBXBTZIPZmCGwUhkkk5AWW Nuz2q5leW0qy/XUvdI2o7jjIKEEw6fz7UFDIOlQsBW8Jc46BfDU2H68DApwZJUoF LEZRtPEkErJT3SE= Received: (qmail 22676 invoked by alias); 24 May 2015 18:55:43 -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 22652 invoked by uid 89); 24 May 2015 18:55:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no 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; Sun, 24 May 2015 18:55:40 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4OItcFD001113 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sun, 24 May 2015 14:55:38 -0400 Received: from host1.jankratochvil.net (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4OItaEN029183; Sun, 24 May 2015 14:55:37 -0400 Subject: [PATCH v3 2/4] libcc1: set debug compile: Display GCC driver filename From: Jan Kratochvil To: gcc-patches@gcc.gnu.org Cc: Phil Muldoon Date: Sun, 24 May 2015 20:55:36 +0200 Message-ID: <20150524185536.31662.12779.stgit@host1.jankratochvil.net> In-Reply-To: <20150524185528.31662.76343.stgit@host1.jankratochvil.net> References: <20150524185528.31662.76343.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes Hi, 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. Jan include/ChangeLog 2015-05-24 Jan Kratochvil * gcc-interface.h (enum gcc_base_api_version): Add comment to GCC_FE_VERSION_1. (struct gcc_base_vtable): Rename compile to compile_v0. Update comment for compile. New methods set_verbose and compile. libcc1/ChangeLog 2015-05-24 Jan Kratochvil * libcc1.cc: Include intl.h. (struct libcc1): Add field verbose. (libcc1::libcc1): Initialize it. (libcc1_set_verbose): New function. (libcc1_set_arguments): Print messages for VERBOSE. (libcc1_compile): Remove parameter verbose. Use VERBOSE from SELF. (libcc1_compile_v0): New function. (vtable): Use libcc1_compile_v0 and add libcc1_compile and libcc1_set_verbose. --- include/gcc-interface.h | 33 ++++++++++++++++++++++++++------- libcc1/libcc1.cc | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/include/gcc-interface.h b/include/gcc-interface.h index dcfa6ce..0b409d0 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, + + /* Deprecated method compile_v0. Added method set_verbose and compile. */ GCC_FE_VERSION_1 = 1, }; @@ -94,18 +96,35 @@ struct gcc_base_vtable const char *message), 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. */ + /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1 + compile method. GCC_FE_VERSION_0 version verbose parameter has + been replaced by the set_verbose method. */ - int /* bool */ (*compile) (struct gcc_base_context *self, - const char *filename, - int /* bool */ verbose); + int /* bool */ (*compile_v0) (struct gcc_base_context *self, + const char *filename, + int /* bool */ verbose); /* Destroy this object. */ void (*destroy) (struct gcc_base_context *self); + + /* VERBOSE can be set to non-zero to cause GCC to print some + information as it works. Calling this method overrides its + possible previous calls. + + This method is only available since GCC_FE_VERSION_1. */ + + void (*set_verbose) (struct gcc_base_context *self, + int /* bool */ verbose); + + /* Perform the compilation. FILENAME is the name of the resulting + object file. Either set_triplet_regexp or set_driver_filename must + be called before. Returns true on success, false on error. + + This method is only available since GCC_FE_VERSION_1. */ + + int /* bool */ (*compile) (struct gcc_base_context *self, + const char *filename); }; /* The GCC object. */ diff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc index 99a0fa1..6fda5b9 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; @@ -306,6 +311,14 @@ make_regexp (const char *triplet_regexp, const char *compiler) return buf.str (); } +static void +libcc1_set_verbose (struct gcc_base_context *s, int /* bool */ verbose) +{ + libcc1 *self = (libcc1 *) s; + + self->verbose = verbose != 0; +} + static char * libcc1_set_arguments (struct gcc_base_context *s, const char *triplet_regexp, @@ -316,6 +329,10 @@ libcc1_set_arguments (struct gcc_base_context *s, int code; 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 +358,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 +453,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 +484,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); @@ -494,6 +512,14 @@ libcc1_compile (struct gcc_base_context *s, return fork_exec (self, argv, fds, stderr_fds); } +static int +libcc1_compile_v0 (struct gcc_base_context *s, const char *filename, + int verbose) +{ + libcc1_set_verbose (s, verbose); + return libcc1_compile (s, filename); +} + static void libcc1_destroy (struct gcc_base_context *s) { @@ -508,8 +534,10 @@ static const struct gcc_base_vtable vtable = libcc1_set_arguments, libcc1_set_source_file, libcc1_set_print_callback, + libcc1_compile_v0, + libcc1_destroy, + libcc1_set_verbose, libcc1_compile, - libcc1_destroy }; extern "C" gcc_c_fe_context_function gcc_c_fe_context;