From patchwork Tue Feb 3 17:24:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 4900 Received: (qmail 15771 invoked by alias); 3 Feb 2015 17:25:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 15746 invoked by uid 89); 3 Feb 2015 17:25:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 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, 03 Feb 2015 17:25:03 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t13HOvdJ024574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Feb 2015 12:24:57 -0500 Received: from host1.jankratochvil.net (ovpn-116-113.ams2.redhat.com [10.36.116.113]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t13HOrgl022585 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 3 Feb 2015 12:24:55 -0500 Date: Tue, 3 Feb 2015 18:24:52 +0100 From: Jan Kratochvil To: Joel Brobecker Cc: gdb-patches@sourceware.org Subject: [commit+7.9] [patchv2+7.9] compile: Filter out -fpreprocessed Message-ID: <20150203172452.GA20561@host1.jankratochvil.net> References: <20150116224234.GA6176@host2.jankratochvil.net> <20150117100222.GA19319@host2.jankratochvil.net> <20150203075639.GK4525@adacore.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150203075639.GK4525@adacore.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Tue, 03 Feb 2015 08:56:39 +0100, Joel Brobecker wrote: > > gdb/ChangeLog > > 2015-01-17 Jan Kratochvil > > > > Filter out inferior gcc option -fpreprocessed. > > * compile/compile.c (filter_args): New function. > > (get_args): Use it. > > Looks good to me; and OK for both master and branch. Checked in: a7606d8083c9e217294f6e47a8d2903716c6337c master c8b16901e05a15e018394ecefe7348c94b43a4f8 7.9 https://sourceware.org/gdb/wiki/GDB_7.9_Release?action=diff&rev2=27&rev1=26 In the meantime ccache fix has been submitted (no reply) and gcc fix has been posted+checked-in as referenced in the attached GDB commit. Thanks, Jan With global system gcc-5.0 if one also installs ccache (needing a different patch https://bugzilla.samba.org/show_bug.cgi?id=11060 for -fplugin=libcc1plugin) it breaks as GDB will read from inferior DW_AT_producer containing -fpreprocessed (due to ccache used to compile the inferior). DW_AT_producer : (indirect string, offset: 0x52): GNU C11 5.0.0 20150114 (Red Hat 5.0.0-0.1) -fpreprocessed -mtune=generic - march=x86-64 -g It is wrong that gcc puts -fpreprocessed into DW_AT_producer - fixed it in trunk GCCs: https://gcc.gnu.org/ml/gcc-patches/2015-01/msg01495.html But even with that fix there are already built inferiors out there which GDB could be compatible (for the 'compile' mode) with. gdb/ChangeLog 2015-02-03 Jan Kratochvil Filter out inferior gcc option -fpreprocessed. * compile/compile.c (filter_args): New function. (get_args): Use it. --- gdb/ChangeLog | 6 ++++++ gdb/compile/compile.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 44dc1ea..2266c11 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2015-02-03 Jan Kratochvil + + Filter out inferior gcc option -fpreprocessed. + * compile/compile.c (filter_args): New function. + (get_args): Use it. + 2015-02-03 Pedro Alves * event-loop.c: Don't declare nor define a queue type for diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 70b6d44..c204a13 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -324,6 +324,27 @@ get_selected_pc_producer_options (void) return cs; } +/* Filter out unwanted options from *ARGCP and ARGV. */ + +static void +filter_args (int *argcp, char **argv) +{ + char **destv; + + for (destv = argv; *argv != NULL; argv++) + { + /* -fpreprocessed may get in commonly from ccache. */ + if (strcmp (*argv, "-fpreprocessed") == 0) + { + xfree (*argv); + (*argcp)--; + continue; + } + *destv++ = *argv; + } + *destv = NULL; +} + /* Produce final vector of GCC compilation options. First element is target size ("-m64", "-m32" etc.), optionally followed by DW_AT_producer options and then compile-args string GDB variable. */ @@ -346,6 +367,7 @@ get_args (const struct compile_instance *compiler, struct gdbarch *gdbarch, char **argv_producer; build_argc_argv (cs_producer_options, &argc_producer, &argv_producer); + filter_args (&argc_producer, argv_producer); append_args (argcp, argvp, argc_producer, argv_producer); freeargv (argv_producer); }