[patchv2+7.9] compile: Filter out -fpreprocessed

Message ID 20150117100222.GA19319@host2.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil Jan. 17, 2015, 10:02 a.m. UTC
  Hi,

fix-up, I forgot in C one had to free() (or xfree()) some of the strings.


Jan
gdb/ChangeLog
2015-01-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Filter out inferior gcc option -fpreprocessed.
	* compile/compile.c (filter_args): New function.
	(get_args): Use it.
  

Comments

Joel Brobecker Feb. 3, 2015, 7:56 a.m. UTC | #1
> gdb/ChangeLog
> 2015-01-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	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.

Thank you,
  

Patch

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);
     }