From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29393 invoked by alias); 17 Jan 2015 10:02:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 29368 invoked by uid 89); 17 Jan 2015 10:02:29 -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; Sat, 17 Jan 2015 10:02:29 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0HA2RD9019411 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sat, 17 Jan 2015 05:02:27 -0500 Received: from host2.jankratochvil.net (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0HA2NUs000719 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Sat, 17 Jan 2015 05:02:26 -0500 Date: Sat, 17 Jan 2015 10:02:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patchv2+7.9] compile: Filter out -fpreprocessed Message-ID: <20150117100222.GA19319@host2.jankratochvil.net> References: <20150116224234.GA6176@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="17pEHd4RhPHOinZp" Content-Disposition: inline In-Reply-To: <20150116224234.GA6176@host2.jankratochvil.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00497.txt.bz2 --17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 85 Hi, fix-up, I forgot in C one had to free() (or xfree()) some of the strings. Jan --17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="filter2.patch" Content-length: 1395 gdb/ChangeLog 2015-01-17 Jan Kratochvil Filter out inferior gcc option -fpreprocessed. * compile/compile.c (filter_args): New function. (get_args): Use it. diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index ccac49d..6cd401d 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); } --17pEHd4RhPHOinZp--