public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch+7.9] compile: Filter out -fpreprocessed
@ 2015-01-16 22:42 Jan Kratochvil
  2015-01-17 10:02 ` [patchv2+7.9] " Jan Kratochvil
  2015-02-03 18:50 ` [patch+7.9] " Doug Evans
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Kratochvil @ 2015-01-16 22:42 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

Hi,

with global system gcc-5.0 if one also installs ccache (needing a different
patch for -fplugin=libcc1plugin) it breaks as GDB will read from inferior
DW_AT_producer containing -fpreprocessed (due to ccache used to compile the
inferior).
    <c>   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 - I may post a gcc
patch for it.  But even if it gets accepted there are already built inferiors
out there which GDB could be compatible (for the 'compile' mode) with.

gdb.compile/*.exp PASSes for it on {x86_64,x86_64-m32}-fedora22pre-linux-gnu.


Thanks,
Jan

[-- Attachment #2: filter.patch --]
[-- Type: text/plain, Size: 1376 bytes --]

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

	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..ecbd15c 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -324,6 +324,26 @@ 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)
+	{
+	  (*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 +366,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);
     }

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-02-04 18:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-16 22:42 [patch+7.9] compile: Filter out -fpreprocessed Jan Kratochvil
2015-01-17 10:02 ` [patchv2+7.9] " Jan Kratochvil
2015-02-03  7:56   ` Joel Brobecker
2015-02-03 17:25     ` [commit+7.9] " Jan Kratochvil
2015-02-03 18:50 ` [patch+7.9] " Doug Evans
2015-02-03 18:59   ` Jan Kratochvil
2015-02-03 19:10     ` Mark Wielaard
2015-02-04 18:15       ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).